internal/router: log invalid ip address entry

This commit is contained in:
Cuong Manh Le
2023-04-27 00:55:37 +07:00
committed by Cuong Manh Le
parent 411e23ecfe
commit 5528ac8bf1

View File

@@ -3,6 +3,7 @@ package router
import (
"bytes"
"log"
"net"
"os"
"strings"
"time"
@@ -82,6 +83,10 @@ func readClientInfoFile(name string) error {
fields := bytes.Fields(line)
mac := string(fields[1])
ip := normalizeIP(string(fields[2]))
if net.ParseIP(ip) == nil {
log.Printf("invalid ip address entry: %q", ip)
ip = ""
}
hostname := string(fields[3])
r.mac.Store(mac, &ctrld.ClientInfo{Mac: mac, IP: ip, Hostname: hostname})
return nil