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"
|
|
|
|
)
|
|
|
|
|
|
|
|
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)
|
|
|
|
}
|
2023-04-22 08:25:13 +00:00
|
|
|
}
|