mirror of
https://github.com/XTLS/Xray-core.git
synced 2024-11-26 06:39:20 +02:00
Optimize cipherSuites setting loader
This commit is contained in:
parent
38faac5ffc
commit
ff9bb2d8df
|
@ -234,22 +234,18 @@ func (c *Config) GetTLSConfig(opts ...Option) *tls.Config {
|
||||||
config.MaxVersion = tls.VersionTLS13
|
config.MaxVersion = tls.VersionTLS13
|
||||||
}
|
}
|
||||||
|
|
||||||
var cipherSuites []uint16
|
|
||||||
if len(c.CipherSuites) > 0 {
|
if len(c.CipherSuites) > 0 {
|
||||||
cipherSuitesArray := strings.Split(c.CipherSuites, ":")
|
id := make(map[string]uint16)
|
||||||
if len(cipherSuitesArray) > 0 {
|
for _, s := range tls.CipherSuites() {
|
||||||
all := tls.CipherSuites()
|
id[s.Name] = s.ID
|
||||||
for _, suite := range cipherSuitesArray {
|
}
|
||||||
for _, s := range all {
|
for _, n := range strings.Split(c.CipherSuites, ":") {
|
||||||
if s.Name == suite {
|
if id[n] != 0 {
|
||||||
cipherSuites = append(cipherSuites, s.ID)
|
config.CipherSuites = append(config.CipherSuites, id[n])
|
||||||
break
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
config.CipherSuites = cipherSuites
|
|
||||||
config.PreferServerCipherSuites = c.PreferServerCipherSuites
|
config.PreferServerCipherSuites = c.PreferServerCipherSuites
|
||||||
|
|
||||||
return config
|
return config
|
||||||
|
|
|
@ -225,22 +225,18 @@ func (c *Config) GetXTLSConfig(opts ...Option) *xtls.Config {
|
||||||
config.MaxVersion = xtls.VersionTLS13
|
config.MaxVersion = xtls.VersionTLS13
|
||||||
}
|
}
|
||||||
|
|
||||||
var cipherSuites []uint16
|
|
||||||
if len(c.CipherSuites) > 0 {
|
if len(c.CipherSuites) > 0 {
|
||||||
cipherSuitesArray := strings.Split(c.CipherSuites, ":")
|
id := make(map[string]uint16)
|
||||||
if len(cipherSuitesArray) > 0 {
|
for _, s := range xtls.CipherSuites() {
|
||||||
all := xtls.CipherSuites()
|
id[s.Name] = s.ID
|
||||||
for _, suite := range cipherSuitesArray {
|
}
|
||||||
for _, s := range all {
|
for _, n := range strings.Split(c.CipherSuites, ":") {
|
||||||
if s.Name == suite {
|
if id[n] != 0 {
|
||||||
cipherSuites = append(cipherSuites, s.ID)
|
config.CipherSuites = append(config.CipherSuites, id[n])
|
||||||
break
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
config.CipherSuites = cipherSuites
|
|
||||||
config.PreferServerCipherSuites = c.PreferServerCipherSuites
|
config.PreferServerCipherSuites = c.PreferServerCipherSuites
|
||||||
|
|
||||||
return config
|
return config
|
||||||
|
|
Loading…
Reference in New Issue