mirror of
https://github.com/nadoo/glider.git
synced 2026-11-19 07:09:42 +08:00
tls, trojan: use 443 as default port if not specified
This commit is contained in:
1 parent
e7ebcbcde5
commit
8495f16a76
11 files changed
+91
-127
No files matched your search
+11
-18
@@ -5,7 +5,6 @@ import (
|
||||
"errors"
|
||||
"net"
|
||||
"net/url"
|
||||
"strings"
|
||||
|
||||
"github.com/nadoo/glider/log"
|
||||
"github.com/nadoo/glider/proxy"
|
||||
@@ -39,26 +38,20 @@ func NewWS(s string, d proxy.Dialer) (*WS, error) {
|
||||
addr = d.Addr()
|
||||
}
|
||||
|
||||
host := u.Query().Get("host")
|
||||
if host == "" {
|
||||
colonPos := strings.LastIndex(addr, ":")
|
||||
if colonPos == -1 {
|
||||
colonPos = len(addr)
|
||||
}
|
||||
host = addr[:colonPos]
|
||||
}
|
||||
|
||||
client, err := NewClient(host, u.Path)
|
||||
if err != nil {
|
||||
log.F("[ws] create ws client error: %s", err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
p := &WS{
|
||||
dialer: d,
|
||||
addr: addr,
|
||||
host: host,
|
||||
client: client,
|
||||
host: u.Query().Get("host"),
|
||||
}
|
||||
|
||||
if p.host == "" {
|
||||
p.host, _, _ = net.SplitHostPort(addr)
|
||||
}
|
||||
|
||||
p.client, err = NewClient(p.host, u.Path)
|
||||
if err != nil {
|
||||
log.F("[ws] create ws client error: %s", err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return p, nil
|
||||
|
||||
Reference in new issue
Block a user