basic UDP server bound to an interface
This commit is contained in:
@@ -6,8 +6,10 @@ go_library(
|
||||
importpath = "git.wntrmute.dev/kyle/kdhcp/cmd/kdhcpd",
|
||||
visibility = ["//visibility:private"],
|
||||
deps = [
|
||||
"//config",
|
||||
"//log",
|
||||
"//server",
|
||||
"@com_github_peterbourgon_ff_v3//ffcli",
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
@@ -4,19 +4,25 @@ import (
|
||||
"context"
|
||||
"flag"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"git.wntrmute.dev/kyle/kdhcp/bazel-kdhcp/external/com_github_davecgh_go_spew/spew"
|
||||
"git.wntrmute.dev/kyle/kdhcp/config"
|
||||
"git.wntrmute.dev/kyle/kdhcp/log"
|
||||
"git.wntrmute.dev/kyle/kdhcp/server"
|
||||
"github.com/peterbourgon/ff/v3/ffcli"
|
||||
)
|
||||
|
||||
func main() {
|
||||
var configPath string
|
||||
logLevel := "DEBUG"
|
||||
|
||||
flag.StringVar(&configPath, "f", "kdhcpd.yaml", "path to `config file`")
|
||||
flag.StringVar(&configPath, "f", "", "path to `config file`")
|
||||
flag.StringVar(&logLevel, "l", logLevel, "log level")
|
||||
flag.Parse()
|
||||
|
||||
logLevel = strings.ToUpper(logLevel)
|
||||
log.Setup(logLevel, "kdhcpd")
|
||||
|
||||
root := &ffcli.Command{
|
||||
Exec: func(ctx context.Context, args []string) error {
|
||||
cfg, err := config.Load(configPath)
|
||||
@@ -24,8 +30,15 @@ func main() {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
log.Debugf("read configuration file with version=%d", cfg.Version)
|
||||
spew.Dump(*cfg)
|
||||
srv, err := server.New(cfg)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
defer srv.Close()
|
||||
|
||||
srv.Listen()
|
||||
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user