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