+ dhcpv6 server; rewrite dhcpv4 server; changed API

This commit is contained in:
Simon Zolin
2020-07-03 18:20:01 +03:00
parent c3123473cf
commit a3317c08c4
27 changed files with 2384 additions and 1280 deletions

View File

@@ -219,10 +219,8 @@ func run(args options) {
config.DHCP.WorkDir = Context.workDir
config.DHCP.HTTPRegister = httpRegister
config.DHCP.ConfigModified = onConfigModified
Context.dhcpServer = dhcpd.Create(config.DHCP)
if Context.dhcpServer == nil {
log.Error("Failed to initialize DHCP server, exiting")
os.Exit(1)
if runtime.GOOS != "windows" {
Context.dhcpServer = dhcpd.Create(config.DHCP)
}
Context.autoHosts.Init("")
@@ -317,9 +315,8 @@ func run(args options) {
}
}()
err = startDHCPServer()
if err != nil {
log.Fatal(err)
if Context.dhcpServer != nil {
_ = Context.dhcpServer.Start()
}
}
@@ -505,9 +502,9 @@ func cleanup() {
if err != nil {
log.Error("Couldn't stop DNS server: %s", err)
}
err = stopDHCPServer()
if err != nil {
log.Error("Couldn't stop DHCP server: %s", err)
if Context.dhcpServer != nil {
Context.dhcpServer.Stop()
}
Context.autoHosts.Close()