This commit is contained in:
Simon Zolin
2020-05-20 12:13:40 +03:00
parent cdb00a5db7
commit 2a9b87c672
6 changed files with 291 additions and 208 deletions

View File

@@ -126,10 +126,6 @@ var config = configuration{
PortHTTPS: 443,
PortDNSOverTLS: 853, // needs to be passed through to dnsproxy
},
DHCP: dhcpd.ServerConfig{
LeaseDuration: 86400,
ICMPTimeout: 1000,
},
SchemaVersion: currentSchemaVersion,
}

View File

@@ -1,36 +0,0 @@
package home
import (
"github.com/joomcode/errorx"
)
func startDHCPServer() error {
if !config.DHCP.Enabled {
// not enabled, don't do anything
return nil
}
err := Context.dhcpServer.Init(config.DHCP)
if err != nil {
return errorx.Decorate(err, "Couldn't init DHCP server")
}
err = Context.dhcpServer.Start()
if err != nil {
return errorx.Decorate(err, "Couldn't start DHCP server")
}
return nil
}
func stopDHCPServer() error {
if !config.DHCP.Enabled {
return nil
}
err := Context.dhcpServer.Stop()
if err != nil {
return errorx.Decorate(err, "Couldn't stop DHCP server")
}
return nil
}

View File

@@ -296,7 +296,7 @@ func run(args options) {
}
}()
err = startDHCPServer()
err = Context.dhcpServer.Start()
if err != nil {
log.Fatal(err)
}
@@ -447,7 +447,7 @@ func cleanup() {
if err != nil {
log.Error("Couldn't stop DNS server: %s", err)
}
err = stopDHCPServer()
err = Context.dhcpServer.Stop()
if err != nil {
log.Error("Couldn't stop DHCP server: %s", err)
}