From 063182e0bdcc3c08d50455010973e8ac5a7685e0 Mon Sep 17 00:00:00 2001 From: kenshinx Date: Thu, 1 Feb 2018 17:43:28 +0800 Subject: [PATCH] use net.JoinHostPort instead of string join --- resolver.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/resolver.go b/resolver.go index 0789453..555def0 100644 --- a/resolver.go +++ b/resolver.go @@ -3,6 +3,7 @@ package main import ( "bufio" "fmt" + "net" "os" "strconv" "strings" @@ -37,7 +38,6 @@ func NewResolver(c ResolvSettings) *Resolver { if len(c.ServerListFile) > 0 { r.ReadServerListFile(c.ServerListFile) - // Debug("%v", r.servers) } if len(c.ResolvFile) > 0 { @@ -48,7 +48,7 @@ func NewResolver(c ResolvSettings) *Resolver { panic(err) } for _, server := range clientConfig.Servers { - nameserver := server + ":" + clientConfig.Port + nameserver := net.JoinHostPort(server, clientConfig.Port) r.servers = append(r.servers, nameserver) } } @@ -104,8 +104,7 @@ func (r *Resolver) ReadServerListFile(file string) { } port = srv_port[1] } - r.servers = append(r.servers, ip+":"+port) - + r.servers = append(r.servers, net.JoinHostPort(ip, port)) } }