kdhcp/cmd/kdhcpd/main.go

37 lines
729 B
Go

package main
import (
"flag"
"git.wntrmute.dev/kyle/kdhcp/log"
"git.wntrmute.dev/kyle/kdhcp/server"
"github.com/davecgh/go-spew/spew"
)
func main() {
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")
flag.Parse()
log.Setup(level, tag)
srv, err := server.NewServer(cfg)
if err != nil {
log.Fatal(err)
}
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)
}
}