mirror of
https://github.com/TeaOSLab/EdgeNode.git
synced 2025-11-07 18:50:27 +08:00
优化代码
This commit is contained in:
@@ -34,22 +34,23 @@ func (this *BaseListener) CountActiveConnections() 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(configInfo *tls.ClientHelloInfo) (config *tls.Config, e error) {
|
GetConfigForClient: func(clientInfo *tls.ClientHelloInfo) (config *tls.Config, e error) {
|
||||||
ssl, _, err := this.matchSSL(configInfo.ServerName)
|
ssl, _, err := this.matchSSL(clientInfo.ServerName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return ssl.TLSConfig(), nil
|
return ssl.TLSConfig(), nil
|
||||||
},
|
},
|
||||||
GetCertificate: func(certInfo *tls.ClientHelloInfo) (certificate *tls.Certificate, e error) {
|
GetCertificate: func(clientInfo *tls.ClientHelloInfo) (certificate *tls.Certificate, e error) {
|
||||||
_, cert, err := this.matchSSL(certInfo.ServerName)
|
_, cert, err := this.matchSSL(clientInfo.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 '" + certInfo.ServerName + "'")
|
return nil, errors.New("no ssl certs found for '" + clientInfo.ServerName + "'")
|
||||||
}
|
}
|
||||||
|
|
||||||
return cert, nil
|
return cert, nil
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user