kdhcp/cmd/kdhcpd/main.go

37 lines
729 B
Go
Raw Normal View History

2023-04-22 08:25:13 +00:00
package main
import (
"flag"
2023-05-01 14:37:52 +00:00
"git.wntrmute.dev/kyle/kdhcp/log"
2023-04-22 08:25:13 +00:00
"git.wntrmute.dev/kyle/kdhcp/server"
"github.com/davecgh/go-spew/spew"
2023-04-22 08:25:13 +00:00
)
func main() {
2023-05-01 14:37:52 +00:00
cfg := server.DefaultConfig()
var level, tag string
flag.StringVar(&level, "l", "DEBUG", "log level") // TODO(kyle): change this warning later
flag.IntVar(&cfg.Port, "p", cfg.Port, "port to listen on")
flag.StringVar(&tag, "t", "kdhcpd", "logging tag")
2023-04-22 08:25:13 +00:00
flag.Parse()
2023-05-01 14:37:52 +00:00
log.Setup(level, tag)
srv, err := server.NewServer(cfg)
2023-04-22 08:25:13 +00:00
if err != nil {
log.Fatal(err)
}
2023-05-01 14:37:52 +00:00
for {
packet, err := srv.ReadFrom()
if err != nil {
log.Warning(err)
continue
}
log.Debugf("receive %d byte packet from %s", len(packet.Data), packet.Addr)
spew.Dump(packet.Data)
2023-05-01 14:37:52 +00:00
}
2023-04-22 08:25:13 +00:00
}