add sni for mws and ws

This commit is contained in:
wenyifan
2026-06-29 16:38:08 +08:00
parent c2cb8f93d2
commit 55461566bd
4 changed files with 10 additions and 2 deletions
+3 -1
View File
@@ -114,7 +114,9 @@ func (d *wsDialer) Handshake(ctx context.Context, conn net.Conn, options ...dial
urlObj := url.URL{Scheme: "ws", Host: host, Path: d.md.path}
if d.tlsEnabled {
urlObj.Scheme = "wss"
d.options.TLSConfig.ServerName = host
if d.md.sni != "" {
d.options.TLSConfig.ServerName = d.md.sni
}
dialer.TLSClientConfig = d.options.TLSConfig
dialer.NetDialTLSContext = func(ctx context.Context, network, addr string) (net.Conn, error) {
client, err := util.NewUTLSWebSocketClient(conn, d.options.TLSConfig, d.md.useH2)