internal/router: log invalid ip address entry

This commit is contained in:
Cuong Manh Le
2023-05-13 12:06:26 +07:00
committed by Cuong Manh Le
parent 411e23ecfe
commit 5528ac8bf1
+5
View File
@@ -3,6 +3,7 @@ package router
import ( import (
"bytes" "bytes"
"log" "log"
"net"
"os" "os"
"strings" "strings"
"time" "time"
@@ -82,6 +83,10 @@ func readClientInfoFile(name string) error {
fields := bytes.Fields(line) fields := bytes.Fields(line)
mac := string(fields[1]) mac := string(fields[1])
ip := normalizeIP(string(fields[2])) ip := normalizeIP(string(fields[2]))
if net.ParseIP(ip) == nil {
log.Printf("invalid ip address entry: %q", ip)
ip = ""
}
hostname := string(fields[3]) hostname := string(fields[3])
r.mac.Store(mac, &ctrld.ClientInfo{Mac: mac, IP: ip, Hostname: hostname}) r.mac.Store(mac, &ctrld.ClientInfo{Mac: mac, IP: ip, Hostname: hostname})
return nil return nil