jrouter/main.go

34 lines
546 B
Go
Raw Normal View History

2024-03-10 11:57:03 +11:00
package main
2024-03-15 15:17:21 +11:00
import (
"log"
"net"
"gitea.drjosh.dev/josh/jrouter/aurp"
)
2024-03-10 11:57:03 +11:00
func main() {
2024-03-15 15:17:21 +11:00
log.Println("jrouter")
ln, err := net.ListenUDP("udp4", &net.UDPAddr{Port: 387})
if err != nil {
log.Fatalf("Couldn't listen on udp4:387: %v", err)
}
// Incoming packet loop
pb := make([]byte, 65536)
for {
plen, _, err := ln.ReadFromUDP(pb)
if err != nil {
log.Printf("Failed to read packet: %v", err)
continue
}
_, err = aurp.ParsePacket(pb[:plen])
if err != nil {
log.Printf("Failed to parse packet: %v", err)
}
2024-03-10 11:57:03 +11:00
2024-03-15 15:17:21 +11:00
}
2024-03-10 11:57:03 +11:00
}