fix(wss): allow_insecure and sni not work (#165)

This commit is contained in:
mzz
2023-07-09 18:42:59 +08:00
committed by GitHub
parent e39ec7fc05
commit 888a746e85

View File

@ -3,12 +3,13 @@ package ws
import ( import (
"crypto/tls" "crypto/tls"
"fmt" "fmt"
"github.com/gorilla/websocket"
"github.com/mzz2017/softwind/netproxy"
"net" "net"
"net/http" "net/http"
"net/url" "net/url"
"strconv" "strconv"
"github.com/gorilla/websocket"
"github.com/mzz2017/softwind/netproxy"
) )
// Ws is a base Ws struct // Ws is a base Ws struct
@ -44,9 +45,9 @@ func NewWs(s string, d netproxy.Dialer) (*Ws, error) {
} }
t.wsAddr = wsUrl.String() + u.Path t.wsAddr = wsUrl.String() + u.Path
if u.Scheme == "wss" { if u.Scheme == "wss" {
skipVerify, _ := strconv.ParseBool(u.Query().Get("allowInsecure")) skipVerify, _ := strconv.ParseBool(query.Get("allowInsecure"))
t.tlsClientConfig = &tls.Config{ t.tlsClientConfig = &tls.Config{
ServerName: u.Query().Get("sni"), ServerName: query.Get("sni"),
InsecureSkipVerify: skipVerify, InsecureSkipVerify: skipVerify,
} }
} }
@ -72,7 +73,7 @@ func (s *Ws) Dial(network, addr string) (c netproxy.Conn, err error) {
RAddr: nil, RAddr: nil,
}, nil }, nil
}, },
//Subprotocols: []string{"binary"}, TLSClientConfig: s.tlsClientConfig,
} }
rc, _, err := wsDialer.Dial(s.wsAddr, s.header) rc, _, err := wsDialer.Dial(s.wsAddr, s.header)
if err != nil { if err != nil {