|
@@ -143,6 +143,8 @@ func CustomTLSDial(network, addr string, config *CustomTLSConfig) (*tls.Conn, er
|
|
|
dialAddr := addr
|
|
dialAddr := addr
|
|
|
if config.HttpProxyAddress != "" {
|
|
if config.HttpProxyAddress != "" {
|
|
|
dialAddr = config.HttpProxyAddress
|
|
dialAddr = config.HttpProxyAddress
|
|
|
|
|
+ } else if config.FrontingAddr != "" {
|
|
|
|
|
+ dialAddr = config.FrontingAddr
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
rawConn, err := config.Dial(network, dialAddr)
|
|
rawConn, err := config.Dial(network, dialAddr)
|
|
@@ -150,16 +152,16 @@ func CustomTLSDial(network, addr string, config *CustomTLSConfig) (*tls.Conn, er
|
|
|
return nil, err
|
|
return nil, err
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- tlsAddr := addr
|
|
|
|
|
|
|
+ targetAddr := addr
|
|
|
if config.FrontingAddr != "" {
|
|
if config.FrontingAddr != "" {
|
|
|
- tlsAddr = config.FrontingAddr
|
|
|
|
|
|
|
+ targetAddr = config.FrontingAddr
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- colonPos := strings.LastIndex(tlsAddr, ":")
|
|
|
|
|
|
|
+ colonPos := strings.LastIndex(targetAddr, ":")
|
|
|
if colonPos == -1 {
|
|
if colonPos == -1 {
|
|
|
- colonPos = len(tlsAddr)
|
|
|
|
|
|
|
+ colonPos = len(targetAddr)
|
|
|
}
|
|
}
|
|
|
- hostname := tlsAddr[:colonPos]
|
|
|
|
|
|
|
+ hostname := targetAddr[:colonPos]
|
|
|
|
|
|
|
|
tlsConfig := config.TlsConfig
|
|
tlsConfig := config.TlsConfig
|
|
|
if tlsConfig == nil {
|
|
if tlsConfig == nil {
|
|
@@ -195,7 +197,7 @@ func CustomTLSDial(network, addr string, config *CustomTLSConfig) (*tls.Conn, er
|
|
|
if config.HttpProxyAddress != "" {
|
|
if config.HttpProxyAddress != "" {
|
|
|
connectRequest := fmt.Sprintf(
|
|
connectRequest := fmt.Sprintf(
|
|
|
"CONNECT %s HTTP/1.1\r\nHost: %s\r\nConnection: Keep-Alive\r\n\r\n",
|
|
"CONNECT %s HTTP/1.1\r\nHost: %s\r\nConnection: Keep-Alive\r\n\r\n",
|
|
|
- tlsAddr, hostname)
|
|
|
|
|
|
|
+ targetAddr, hostname)
|
|
|
_, err := rawConn.Write([]byte(connectRequest))
|
|
_, err := rawConn.Write([]byte(connectRequest))
|
|
|
if err != nil {
|
|
if err != nil {
|
|
|
return err
|
|
return err
|