github.com/v2fly/v2ray-core/v4@v4.45.2/transport/internet/memory_settings.go (about) 1 package internet 2 3 // MemoryStreamConfig is a parsed form of StreamConfig. This is used to reduce number of Protobuf parsing. 4 type MemoryStreamConfig struct { 5 ProtocolName string 6 ProtocolSettings interface{} 7 SecurityType string 8 SecuritySettings interface{} 9 SocketSettings *SocketConfig 10 } 11 12 // ToMemoryStreamConfig converts a StreamConfig to MemoryStreamConfig. It returns a default non-nil MemoryStreamConfig for nil input. 13 func ToMemoryStreamConfig(s *StreamConfig) (*MemoryStreamConfig, error) { 14 ets, err := s.GetEffectiveTransportSettings() 15 if err != nil { 16 return nil, err 17 } 18 19 mss := &MemoryStreamConfig{ 20 ProtocolName: s.GetEffectiveProtocol(), 21 ProtocolSettings: ets, 22 } 23 24 if s != nil { 25 mss.SocketSettings = s.SocketSettings 26 } 27 28 if s != nil && s.HasSecuritySettings() { 29 ess, err := s.GetEffectiveSecuritySettings() 30 if err != nil { 31 return nil, err 32 } 33 mss.SecurityType = s.SecurityType 34 mss.SecuritySettings = ess 35 } 36 37 return mss, nil 38 }