mirror of
https://github.com/nadoo/glider.git
synced 2026-11-19 07:09:42 +08:00
tls,trojan: optimize the default port handling
This commit is contained in:
1 parent
93728c6378
commit
2d16870803
6 files changed
+17
-19
No files matched your search
+5
-6
@@ -52,13 +52,12 @@ func NewTLS(s string, d proxy.Dialer, p proxy.Proxy) (*TLS, error) {
|
||||
keyFile: query.Get("key"),
|
||||
}
|
||||
|
||||
if _, p, _ := net.SplitHostPort(t.addr); p == "" {
|
||||
t.addr = net.JoinHostPort(t.addr, "443")
|
||||
}
|
||||
|
||||
if t.serverName == "" {
|
||||
idx := strings.LastIndex(t.addr, ":")
|
||||
if idx == -1 {
|
||||
idx = len(t.addr)
|
||||
t.addr = net.JoinHostPort(t.addr, "443")
|
||||
}
|
||||
t.serverName = t.addr[:idx]
|
||||
t.serverName = t.addr[:strings.LastIndex(t.addr, ":")]
|
||||
}
|
||||
|
||||
return t, nil
|
||||
|
||||
@@ -58,13 +58,12 @@ func NewTrojan(s string, d proxy.Dialer, p proxy.Proxy) (*Trojan, error) {
|
||||
// fallback: "127.0.0.1:80",
|
||||
}
|
||||
|
||||
if _, p, _ := net.SplitHostPort(t.addr); p == "" {
|
||||
t.addr = net.JoinHostPort(t.addr, "443")
|
||||
}
|
||||
|
||||
if t.serverName == "" {
|
||||
idx := strings.LastIndex(t.addr, ":")
|
||||
if idx == -1 {
|
||||
idx = len(t.addr)
|
||||
t.addr = net.JoinHostPort(t.addr, "443")
|
||||
}
|
||||
t.serverName = t.addr[:idx]
|
||||
t.serverName = t.addr[:strings.LastIndex(t.addr, ":")]
|
||||
}
|
||||
|
||||
// pass
|
||||
|
||||
Reference in new issue
Block a user