memory_settings.go 737 B

123456789101112131415161718192021222324252627282930313233343536
  1. package internet
  2. type MemoryStreamConfig struct {
  3. ProtocolName string
  4. ProtocolSettings interface{}
  5. SecurityType string
  6. SecuritySettings interface{}
  7. SocketSettings *SocketConfig
  8. }
  9. func ToMemoryStreamConfig(s *StreamConfig) (*MemoryStreamConfig, error) {
  10. ets, err := s.GetEffectiveTransportSettings()
  11. if err != nil {
  12. return nil, err
  13. }
  14. mss := &MemoryStreamConfig{
  15. ProtocolName: s.GetEffectiveProtocol(),
  16. ProtocolSettings: ets,
  17. }
  18. if s != nil {
  19. mss.SocketSettings = s.SocketSettings
  20. }
  21. if s != nil && s.HasSecuritySettings() {
  22. ess, err := s.GetEffectiveSecuritySettings()
  23. if err != nil {
  24. return nil, err
  25. }
  26. mss.SecurityType = s.SecurityType
  27. mss.SecuritySettings = ess
  28. }
  29. return mss, nil
  30. }