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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

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