minor
This commit is contained in:
@@ -234,39 +234,45 @@ func (s *Server) setConfig(config ServerConfig) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start will listen on port 67 and serve DHCP requests.
|
func (s *Server) start4(iface net.Interface) error {
|
||||||
func (s *Server) Start() error {
|
|
||||||
// TODO: don't close if interface and addresses are the same
|
// TODO: don't close if interface and addresses are the same
|
||||||
if s.conn != nil {
|
if s.conn != nil {
|
||||||
_ = s.closeConn()
|
_ = s.closeConn()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
c, err := newFilterConn(iface, ":67") // it has to be bound to 0.0.0.0:67, otherwise it won't see DHCP discover/request packets
|
||||||
|
if err != nil {
|
||||||
|
return wrapErrPrint(err, "Couldn't start listening socket on 0.0.0.0:67")
|
||||||
|
}
|
||||||
|
log.Info("DHCP: listening on 0.0.0.0:67")
|
||||||
|
|
||||||
|
s.conn = c
|
||||||
|
s.cond = sync.NewCond(&s.mutex)
|
||||||
|
|
||||||
|
s.running = true
|
||||||
|
go func() {
|
||||||
|
// operate on c instead of c.conn because c.conn can change over time
|
||||||
|
err := dhcp4.Serve(c, s)
|
||||||
|
if err != nil && !s.stopping {
|
||||||
|
log.Printf("dhcp4.Serve() returned with error: %s", err)
|
||||||
|
}
|
||||||
|
_ = c.Close() // in case Serve() exits for other reason than listening socket closure
|
||||||
|
s.running = false
|
||||||
|
s.cond.Signal()
|
||||||
|
}()
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Start will listen on port 67 and serve DHCP requests.
|
||||||
|
func (s *Server) Start() error {
|
||||||
iface, err := net.InterfaceByName(s.conf.InterfaceName)
|
iface, err := net.InterfaceByName(s.conf.InterfaceName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return wrapErrPrint(err, "Couldn't find interface by name %s", s.conf.InterfaceName)
|
return wrapErrPrint(err, "Couldn't find interface by name %s", s.conf.InterfaceName)
|
||||||
}
|
}
|
||||||
|
|
||||||
if false {
|
err = s.start4(*iface)
|
||||||
c, err := newFilterConn(*iface, ":67") // it has to be bound to 0.0.0.0:67, otherwise it won't see DHCP discover/request packets
|
if err != nil {
|
||||||
if err != nil {
|
return err
|
||||||
return wrapErrPrint(err, "Couldn't start listening socket on 0.0.0.0:67")
|
|
||||||
}
|
|
||||||
log.Info("DHCP: listening on 0.0.0.0:67")
|
|
||||||
|
|
||||||
s.conn = c
|
|
||||||
s.cond = sync.NewCond(&s.mutex)
|
|
||||||
|
|
||||||
s.running = true
|
|
||||||
go func() {
|
|
||||||
// operate on c instead of c.conn because c.conn can change over time
|
|
||||||
err := dhcp4.Serve(c, s)
|
|
||||||
if err != nil && !s.stopping {
|
|
||||||
log.Printf("dhcp4.Serve() returned with error: %s", err)
|
|
||||||
}
|
|
||||||
_ = c.Close() // in case Serve() exits for other reason than listening socket closure
|
|
||||||
s.running = false
|
|
||||||
s.cond.Signal()
|
|
||||||
}()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
err = s.srv6.Start(*iface)
|
err = s.srv6.Start(*iface)
|
||||||
|
|||||||
Reference in New Issue
Block a user