tls,trojan: optimize the default port handling

This commit is contained in:
nadoo committed 2021-03-21 00:08:00 +08:00
1 parent 93728c6378
commit 2d16870803
6 files changed
+17 -19

No files matched your search

+5 -6
View File
@@ -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
+5 -6
View File
@@ -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