2019-06-10 08:33:19 +00:00
|
|
|
package home
|
2018-12-12 17:22:45 +00:00
|
|
|
|
|
|
|
import (
|
2018-12-28 18:01:16 +00:00
|
|
|
"github.com/joomcode/errorx"
|
2018-12-12 17:22:45 +00:00
|
|
|
)
|
|
|
|
|
2018-12-28 18:01:16 +00:00
|
|
|
func startDHCPServer() error {
|
2019-01-25 13:01:27 +00:00
|
|
|
if !config.DHCP.Enabled {
|
2018-12-29 12:04:14 +00:00
|
|
|
// not enabled, don't do anything
|
|
|
|
return nil
|
|
|
|
}
|
2019-05-14 13:59:21 +00:00
|
|
|
|
2019-07-09 15:57:41 +00:00
|
|
|
err := config.dhcpServer.Init(config.DHCP)
|
2019-05-14 13:59:21 +00:00
|
|
|
if err != nil {
|
|
|
|
return errorx.Decorate(err, "Couldn't init DHCP server")
|
|
|
|
}
|
|
|
|
|
2019-07-09 15:57:41 +00:00
|
|
|
err = config.dhcpServer.Start()
|
2018-12-28 18:01:16 +00:00
|
|
|
if err != nil {
|
|
|
|
return errorx.Decorate(err, "Couldn't start DHCP server")
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
2019-02-04 10:54:53 +00:00
|
|
|
|
|
|
|
func stopDHCPServer() error {
|
|
|
|
if !config.DHCP.Enabled {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2019-07-09 15:57:41 +00:00
|
|
|
err := config.dhcpServer.Stop()
|
2019-02-04 10:54:53 +00:00
|
|
|
if err != nil {
|
|
|
|
return errorx.Decorate(err, "Couldn't stop DHCP server")
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|