add geoip country/asn labels and ipv6

This commit is contained in:
Abel Luck 2026-05-05 13:57:12 +02:00
parent 8318f9fe70
commit 4710df2523
12 changed files with 559 additions and 43 deletions

View file

@ -9,7 +9,7 @@ import (
// OpenRawSocket creates an AF_PACKET raw socket for sniffing IPv4 packets.
func OpenRawSocket() (int, error) {
fd, err := syscall.Socket(syscall.AF_PACKET, syscall.SOCK_DGRAM, int(htons(syscall.ETH_P_IP)))
fd, err := syscall.Socket(syscall.AF_PACKET, syscall.SOCK_DGRAM, int(htons(ethPAll)))
if err != nil {
return -1, fmt.Errorf("open raw socket: %w", err)
}
@ -36,7 +36,7 @@ func CaptureLoop(fd int, port int, collector *Collector, stop <-chan struct{}) {
}
return
}
ProcessIPv4Packet(buf[:n], port, collector)
ProcessPacket(buf[:n], port, collector)
}
}
@ -48,3 +48,5 @@ func CloseRawSocket(fd int) error {
func htons(v uint16) uint16 {
return (v << 8) | (v >> 8)
}
const ethPAll = 0x0003