handle ipv6 addresses

This commit is contained in:
Chris Lu
2021-09-07 16:43:54 -07:00
parent 35c8ea495f
commit 0128239c0f
16 changed files with 42 additions and 20 deletions

View File

@@ -3,8 +3,10 @@ package stats
import (
"fmt"
"log"
"net"
"net/http"
"os"
"strconv"
"strings"
"time"
@@ -180,5 +182,5 @@ func SourceName(port uint32) string {
if err != nil {
return "unknown"
}
return fmt.Sprintf("%s:%d", hostname, port)
return net.JoinHostPort(hostname, strconv.Itoa(int(port)))
}