Check upstream address with net.SplitHostPort

Looking for a colon is incorrect, IPv6 addresses can contain colons too.
This commit is contained in:
Simon Ser 2020-07-06 16:04:56 +02:00
parent c490705fee
commit b46a2554e1
No known key found for this signature in database
GPG Key ID: 0FDE7BE0E88F5E48

View File

@ -98,7 +98,7 @@ func connectToUpstream(network *network) (*upstreamConn, error) {
var err error var err error
switch scheme { switch scheme {
case "ircs": case "ircs":
if !strings.ContainsRune(addr, ':') { if _, _, err := net.SplitHostPort(addr); err != nil {
addr = addr + ":6697" addr = addr + ":6697"
} }
@ -129,7 +129,7 @@ func connectToUpstream(network *network) (*upstreamConn, error) {
netConn, err = tls.DialWithDialer(&dialer, "tcp", addr, cfg) netConn, err = tls.DialWithDialer(&dialer, "tcp", addr, cfg)
case "irc+insecure": case "irc+insecure":
if !strings.ContainsRune(addr, ':') { if _, _, err := net.SplitHostPort(addr); err != nil {
addr = addr + ":6667" addr = addr + ":6667"
} }