mirror of
https://github.com/Control-D-Inc/ctrld.git
synced 2026-08-10 13:20:33 +02:00
internal/router: log invalid ip address entry
This commit is contained in:
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user