mirror of
https://github.com/TeaOSLab/EdgeNode.git
synced 2025-11-30 20:31:01 +08:00
回源TLS/HTTPS携带ServerName信息
This commit is contained in:
@@ -10,7 +10,7 @@ import (
|
||||
)
|
||||
|
||||
// OriginConnect 连接源站
|
||||
func OriginConnect(origin *serverconfigs.OriginConfig, remoteAddr string) (net.Conn, error) {
|
||||
func OriginConnect(origin *serverconfigs.OriginConfig, remoteAddr string, tlsHost string) (net.Conn, error) {
|
||||
if origin.Addr == nil {
|
||||
return nil, errors.New("origin server address should not be empty")
|
||||
}
|
||||
@@ -58,6 +58,9 @@ func OriginConnect(origin *serverconfigs.OriginConfig, remoteAddr string) (net.C
|
||||
}
|
||||
}
|
||||
}
|
||||
if len(tlsHost) > 0 {
|
||||
tlsConfig.ServerName = tlsHost
|
||||
}
|
||||
|
||||
conn, err = tls.DialWithDialer(&dialer, "tcp", origin.Addr.Host+":"+origin.Addr.PortRange, tlsConfig)
|
||||
}
|
||||
@@ -95,6 +98,9 @@ func OriginConnect(origin *serverconfigs.OriginConfig, remoteAddr string) (net.C
|
||||
}
|
||||
}
|
||||
}
|
||||
if len(tlsHost) > 0 {
|
||||
tlsConfig.ServerName = tlsHost
|
||||
}
|
||||
|
||||
return tls.Dial("tcp", origin.Addr.Host+":"+origin.Addr.PortRange, tlsConfig)
|
||||
case serverconfigs.ProtocolUDP:
|
||||
|
||||
Reference in New Issue
Block a user