2023-02-15 16:07:12 +00:00
|
|
|
package reality
|
|
|
|
|
|
|
|
import (
|
2023-02-26 11:26:57 +00:00
|
|
|
"net"
|
2023-02-15 16:07:12 +00:00
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/xtls/reality"
|
|
|
|
"github.com/xtls/xray-core/transport/internet"
|
|
|
|
)
|
|
|
|
|
|
|
|
func (c *Config) GetREALITYConfig() *reality.Config {
|
2023-02-26 11:26:57 +00:00
|
|
|
var dialer net.Dialer
|
2023-02-15 16:07:12 +00:00
|
|
|
config := &reality.Config{
|
2023-02-26 11:26:57 +00:00
|
|
|
DialContext: dialer.DialContext,
|
|
|
|
|
2023-02-15 16:07:12 +00:00
|
|
|
Show: c.Show,
|
|
|
|
Type: c.Type,
|
|
|
|
Dest: c.Dest,
|
|
|
|
Xver: byte(c.Xver),
|
|
|
|
|
|
|
|
PrivateKey: c.PrivateKey,
|
|
|
|
MinClientVer: c.MinClientVer,
|
|
|
|
MaxClientVer: c.MaxClientVer,
|
|
|
|
MaxTimeDiff: time.Duration(c.MaxTimeDiff) * time.Millisecond,
|
|
|
|
|
|
|
|
NextProtos: nil, // should be nil
|
|
|
|
SessionTicketsDisabled: true,
|
|
|
|
}
|
|
|
|
config.ServerNames = make(map[string]bool)
|
|
|
|
for _, serverName := range c.ServerNames {
|
|
|
|
config.ServerNames[serverName] = true
|
|
|
|
}
|
|
|
|
config.ShortIds = make(map[[8]byte]bool)
|
|
|
|
for _, shortId := range c.ShortIds {
|
|
|
|
config.ShortIds[*(*[8]byte)(shortId)] = true
|
|
|
|
}
|
|
|
|
return config
|
|
|
|
}
|
|
|
|
|
|
|
|
func ConfigFromStreamSettings(settings *internet.MemoryStreamConfig) *Config {
|
|
|
|
if settings == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
config, ok := settings.SecuritySettings.(*Config)
|
|
|
|
if !ok {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return config
|
|
|
|
}
|