github.com/moqsien/xraycore@v1.8.5/transport/internet/reality/config.go (about) 1 package reality 2 3 import ( 4 "net" 5 "time" 6 7 "github.com/xtls/reality" 8 "github.com/moqsien/xraycore/transport/internet" 9 ) 10 11 func (c *Config) GetREALITYConfig() *reality.Config { 12 var dialer net.Dialer 13 config := &reality.Config{ 14 DialContext: dialer.DialContext, 15 16 Show: c.Show, 17 Type: c.Type, 18 Dest: c.Dest, 19 Xver: byte(c.Xver), 20 21 PrivateKey: c.PrivateKey, 22 MinClientVer: c.MinClientVer, 23 MaxClientVer: c.MaxClientVer, 24 MaxTimeDiff: time.Duration(c.MaxTimeDiff) * time.Millisecond, 25 26 NextProtos: nil, // should be nil 27 SessionTicketsDisabled: true, 28 } 29 config.ServerNames = make(map[string]bool) 30 for _, serverName := range c.ServerNames { 31 config.ServerNames[serverName] = true 32 } 33 config.ShortIds = make(map[[8]byte]bool) 34 for _, shortId := range c.ShortIds { 35 config.ShortIds[*(*[8]byte)(shortId)] = true 36 } 37 return config 38 } 39 40 func ConfigFromStreamSettings(settings *internet.MemoryStreamConfig) *Config { 41 if settings == nil { 42 return nil 43 } 44 config, ok := settings.SecuritySettings.(*Config) 45 if !ok { 46 return nil 47 } 48 return config 49 }