mirror of
https://github.com/TeaOSLab/EdgeNode.git
synced 2025-11-09 20:10:27 +08:00
优化代码
This commit is contained in:
@@ -8,7 +8,6 @@ import (
|
|||||||
"github.com/TeaOSLab/EdgeNode/internal/remotelogs"
|
"github.com/TeaOSLab/EdgeNode/internal/remotelogs"
|
||||||
"github.com/iwind/TeaGo/lists"
|
"github.com/iwind/TeaGo/lists"
|
||||||
"github.com/iwind/TeaGo/types"
|
"github.com/iwind/TeaGo/types"
|
||||||
"golang.org/x/net/http2"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type BaseListener struct {
|
type BaseListener struct {
|
||||||
@@ -35,48 +34,21 @@ func (this *BaseListener) CountActiveListeners() int {
|
|||||||
func (this *BaseListener) buildTLSConfig() *tls.Config {
|
func (this *BaseListener) buildTLSConfig() *tls.Config {
|
||||||
return &tls.Config{
|
return &tls.Config{
|
||||||
Certificates: nil,
|
Certificates: nil,
|
||||||
GetConfigForClient: func(info *tls.ClientHelloInfo) (config *tls.Config, e error) {
|
GetConfigForClient: func(configInfo *tls.ClientHelloInfo) (config *tls.Config, e error) {
|
||||||
ssl, _, err := this.matchSSL(info.ServerName)
|
ssl, _, err := this.matchSSL(configInfo.ServerName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
cipherSuites := ssl.TLSCipherSuites()
|
return ssl.TLSConfig(), nil
|
||||||
if !ssl.CipherSuitesIsOn || len(cipherSuites) == 0 {
|
},
|
||||||
cipherSuites = nil
|
GetCertificate: func(certInfo *tls.ClientHelloInfo) (certificate *tls.Certificate, e error) {
|
||||||
}
|
_, cert, err := this.matchSSL(certInfo.ServerName)
|
||||||
|
|
||||||
nextProto := []string{}
|
|
||||||
if ssl.HTTP2Enabled {
|
|
||||||
nextProto = []string{http2.NextProtoTLS}
|
|
||||||
}
|
|
||||||
return &tls.Config{
|
|
||||||
Certificates: nil,
|
|
||||||
MinVersion: ssl.TLSMinVersion(),
|
|
||||||
CipherSuites: cipherSuites,
|
|
||||||
GetCertificate: func(info *tls.ClientHelloInfo) (certificate *tls.Certificate, e error) {
|
|
||||||
_, cert, err := this.matchSSL(info.ServerName)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if cert == nil {
|
if cert == nil {
|
||||||
return nil, errors.New("no ssl certs found for '" + info.ServerName + "'")
|
return nil, errors.New("no ssl certs found for '" + certInfo.ServerName + "'")
|
||||||
}
|
|
||||||
return cert, nil
|
|
||||||
},
|
|
||||||
ClientAuth: sslconfigs.GoSSLClientAuthType(ssl.ClientAuthType),
|
|
||||||
ClientCAs: ssl.CAPool(),
|
|
||||||
|
|
||||||
NextProtos: nextProto,
|
|
||||||
}, nil
|
|
||||||
},
|
|
||||||
GetCertificate: func(info *tls.ClientHelloInfo) (certificate *tls.Certificate, e error) {
|
|
||||||
_, cert, err := this.matchSSL(info.ServerName)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if cert == nil {
|
|
||||||
return nil, errors.New("no ssl certs found for '" + info.ServerName + "'")
|
|
||||||
}
|
}
|
||||||
return cert, nil
|
return cert, nil
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user