1 Commits

Author SHA1 Message Date
Toby Chui
52f652fbaf Enable SNI offload in HTTPS proxy connections
Updated the ReverseProxy's ProxyHTTPS method to use tls.Dial with SNI support when connecting to upstream servers. Also incremented SYSTEM_VERSION to 3.2.7.
2025-09-17 07:37:21 +08:00
2 changed files with 15 additions and 5 deletions

View File

@@ -44,7 +44,7 @@ import (
const (
/* Build Constants */
SYSTEM_NAME = "Zoraxy"
SYSTEM_VERSION = "3.2.6"
SYSTEM_VERSION = "3.2.7"
DEVELOPMENT_BUILD = false
/* System Constants */

View File

@@ -2,10 +2,10 @@ package dpcore
import (
"context"
"crypto/tls"
"errors"
"io"
"log"
"net"
"net/http"
"net/url"
"strings"
@@ -391,7 +391,6 @@ func (p *ReverseProxy) ProxyHTTP(rw http.ResponseWriter, req *http.Request, rrr
return res.StatusCode, nil
}
func (p *ReverseProxy) ProxyHTTPS(rw http.ResponseWriter, req *http.Request) (int, error) {
hij, ok := rw.(http.Hijacker)
if !ok {
@@ -407,12 +406,23 @@ func (p *ReverseProxy) ProxyHTTPS(rw http.ResponseWriter, req *http.Request) (in
return http.StatusInternalServerError, err
}
proxyConn, err := net.Dial("tcp", req.URL.Host)
// Extract SNI/hostname for TLS handshake
host := req.URL.Host
if !strings.Contains(host, ":") {
host += ":443"
}
serverName := req.URL.Hostname()
// Connect with SNI offload
tlsConfig := &tls.Config{
ServerName: serverName,
}
proxyConn, err := tls.Dial("tcp", host, tlsConfig)
if err != nil {
if p.Verbal {
p.logf("http: proxy error: %v", err)
}
clientConn.Close()
return http.StatusInternalServerError, err
}