badguardhome/home/dhcp.go

37 lines
620 B
Go
Raw Normal View History

package home
2018-12-12 17:22:45 +00:00
import (
"github.com/joomcode/errorx"
2018-12-12 17:22:45 +00:00
)
func startDHCPServer() error {
if !config.DHCP.Enabled {
// not enabled, don't do anything
return nil
}
2019-07-09 15:57:41 +00:00
err := config.dhcpServer.Init(config.DHCP)
if err != nil {
return errorx.Decorate(err, "Couldn't init DHCP server")
}
2019-07-09 15:57:41 +00:00
err = config.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
}
2019-07-09 15:57:41 +00:00
err := config.dhcpServer.Stop()
if err != nil {
return errorx.Decorate(err, "Couldn't stop DHCP server")
}
return nil
}