* dhcp: fail on startup if couldn't initialize DHCP module

This commit is contained in:
Simon Zolin 2020-08-04 14:18:35 +03:00
parent a3317c08c4
commit 89c3926ba5
2 changed files with 8 additions and 0 deletions

View File

@ -119,6 +119,11 @@ func Create(config ServerConfig) *Server {
return nil
}
if s.conf.Enabled && !v4conf.Enabled && !v6conf.Enabled {
log.Error("Can't enable DHCP server because neither DHCPv4 nor DHCPv6 servers are configured")
return nil
}
// we can't delay database loading until DHCP server is started,
// because we need static leases functionality available beforehand
s.dbLoad()

View File

@ -221,6 +221,9 @@ func run(args options) {
config.DHCP.ConfigModified = onConfigModified
if runtime.GOOS != "windows" {
Context.dhcpServer = dhcpd.Create(config.DHCP)
if Context.dhcpServer == nil {
log.Fatalf("Can't initialize DHCP module")
}
}
Context.autoHosts.Init("")