mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-08-23 01:56:48 +08:00
v1.0.0
This commit is contained in:
38
transport/internet/memory_settings.go
Normal file
38
transport/internet/memory_settings.go
Normal file
@@ -0,0 +1,38 @@
|
||||
package internet
|
||||
|
||||
// MemoryStreamConfig is a parsed form of StreamConfig. This is used to reduce number of Protobuf parsing.
|
||||
type MemoryStreamConfig struct {
|
||||
ProtocolName string
|
||||
ProtocolSettings interface{}
|
||||
SecurityType string
|
||||
SecuritySettings interface{}
|
||||
SocketSettings *SocketConfig
|
||||
}
|
||||
|
||||
// ToMemoryStreamConfig converts a StreamConfig to MemoryStreamConfig. It returns a default non-nil MemoryStreamConfig for nil input.
|
||||
func ToMemoryStreamConfig(s *StreamConfig) (*MemoryStreamConfig, error) {
|
||||
ets, err := s.GetEffectiveTransportSettings()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
mss := &MemoryStreamConfig{
|
||||
ProtocolName: s.GetEffectiveProtocol(),
|
||||
ProtocolSettings: ets,
|
||||
}
|
||||
|
||||
if s != nil {
|
||||
mss.SocketSettings = s.SocketSettings
|
||||
}
|
||||
|
||||
if s != nil && s.HasSecuritySettings() {
|
||||
ess, err := s.GetEffectiveSecuritySettings()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
mss.SecurityType = s.SecurityType
|
||||
mss.SecuritySettings = ess
|
||||
}
|
||||
|
||||
return mss, nil
|
||||
}
|
Reference in New Issue
Block a user