ws: use default port if not specified

This commit is contained in:
nadoo committed 2021-07-06 20:31:39 +08:00
1 parent 53fe94251f
commit 879e736f01
6 files changed
+13 -9

No files matched your search

-1
View File
@@ -73,7 +73,6 @@ func NewTLSDialer(s string, d proxy.Dialer) (proxy.Dialer, error) {
p.config = &stdtls.Config{
ServerName: p.serverName,
InsecureSkipVerify: p.skipVerify,
ClientSessionCache: stdtls.NewLRUClientSessionCache(64),
MinVersion: stdtls.VersionTLS12,
}
-1
View File
@@ -34,7 +34,6 @@ func NewTrojanDialer(s string, d proxy.Dialer) (proxy.Dialer, error) {
ServerName: t.serverName,
InsecureSkipVerify: t.skipVerify,
NextProtos: []string{"http/1.1"},
ClientSessionCache: tls.NewLRUClientSessionCache(64),
MinVersion: tls.VersionTLS12,
}
+9 -3
View File
@@ -4,6 +4,7 @@ import (
"crypto/rand"
"crypto/sha1"
"encoding/base64"
"net"
"net/url"
"strings"
@@ -35,17 +36,22 @@ func NewWS(s string, d proxy.Dialer, p proxy.Proxy) (*WS, error) {
}
addr := u.Host
if addr == "" && d != nil {
if addr != "" {
if _, port, _ := net.SplitHostPort(addr); port == "" {
addr = net.JoinHostPort(addr, "80")
}
} else if d != nil {
addr = d.Addr()
}
query := u.Query()
w := &WS{
dialer: d,
proxy: p,
addr: addr,
host: u.Query().Get("host"),
path: u.Path,
origin: u.Query().Get("origin"),
host: query.Get("host"),
origin: query.Get("origin"),
}
if w.host == "" {