Fix a missing IPv6 bracket

This commit is contained in:
Qian Wang 2019-03-24 16:24:17 +11:00
parent 2af372254f
commit ebd7e6b1bd
1 changed files with 6 additions and 1 deletions

View File

@ -167,7 +167,12 @@ func dispatchConnection(conn net.Conn, sta *server.State) {
continue
}
}
ssConn, err := net.Dial("tcp", sta.SS_LOCAL_HOST+":"+sta.SS_LOCAL_PORT)
ssIP := sta.SS_LOCAL_HOST
if net.ParseIP(ssIP).To4() == nil {
// IPv6 needs square brackets
ssIP = "[" + ssIP + "]"
}
ssConn, err := net.Dial("tcp", ssIP+":"+sta.SS_LOCAL_PORT)
if err != nil {
log.Printf("Failed to connect to ssserver: %v\n", err)
continue