Add cipherSuites setting for TLS & XTLS (#78)

This commit is contained in:
eMeab 2020-12-16 20:53:55 +08:00 committed by GitHub
parent 19ce0e99a5
commit 88dfed931b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 212 additions and 110 deletions

View file

@ -185,11 +185,12 @@ func (c *Config) GetTLSConfig(opts ...Option) *tls.Config {
}
config := &tls.Config{
ClientSessionCache: globalSessionCache,
RootCAs: root,
InsecureSkipVerify: c.AllowInsecure,
NextProtos: c.NextProtocol,
SessionTicketsDisabled: c.DisableSessionResumption,
ClientSessionCache: globalSessionCache,
RootCAs: root,
InsecureSkipVerify: c.AllowInsecure,
NextProtos: c.NextProtocol,
SessionTicketsDisabled: c.DisableSessionResumption,
PreferServerCipherSuites: c.PreferServerCipherSuites,
}
for _, opt := range opts {
@ -223,6 +224,22 @@ func (c *Config) GetTLSConfig(opts ...Option) *tls.Config {
config.NextProtos = []string{"h2", "http/1.1"}
}
var cipherSuites []uint16
if c.PreferServerCipherSuites && len(c.CipherSuites) > 0 {
cipherSuitesArray := strings.Split(c.CipherSuites, ":")
if len(cipherSuitesArray) > 0 {
all := tls.CipherSuites()
for _, suite := range cipherSuitesArray {
for _, s := range all {
if s.Name == suite {
cipherSuites = append(cipherSuites, s.ID)
}
}
}
}
}
config.CipherSuites = cipherSuites
return config
}