From b46a2554e144ae93a56d8535b95546f16081076b Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Mon, 6 Jul 2020 16:04:56 +0200 Subject: [PATCH] Check upstream address with net.SplitHostPort Looking for a colon is incorrect, IPv6 addresses can contain colons too. --- upstream.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/upstream.go b/upstream.go index 76479a8..b24d78b 100644 --- a/upstream.go +++ b/upstream.go @@ -98,7 +98,7 @@ func connectToUpstream(network *network) (*upstreamConn, error) { var err error switch scheme { case "ircs": - if !strings.ContainsRune(addr, ':') { + if _, _, err := net.SplitHostPort(addr); err != nil { addr = addr + ":6697" } @@ -129,7 +129,7 @@ func connectToUpstream(network *network) (*upstreamConn, error) { netConn, err = tls.DialWithDialer(&dialer, "tcp", addr, cfg) case "irc+insecure": - if !strings.ContainsRune(addr, ':') { + if _, _, err := net.SplitHostPort(addr); err != nil { addr = addr + ":6667" }