dhcpd: support macOS and freebsd(not tested)

This commit is contained in:
nadoo committed 2021-08-12 19:11:06 +08:00
1 parent 7c50915f20
commit 8b29af3c0c
12 files changed
+51 -30

No files matched your search

-19
View File
@@ -1,7 +1,6 @@
package dhcpd
import (
"context"
"errors"
"net"
"strconv"
@@ -9,7 +8,6 @@ import (
"time"
"github.com/insomniacslk/dhcp/dhcpv4"
"github.com/insomniacslk/dhcp/dhcpv4/nclient4"
"github.com/insomniacslk/dhcp/dhcpv4/server4"
"github.com/nadoo/glider/log"
@@ -137,23 +135,6 @@ func handleDHCP(serverIP net.IP, mask net.IPMask, pool *Pool) server4.Handler {
}
}
func existsServer(iface string) (exists bool) {
client, err := nclient4.New(iface)
if err != nil {
log.F("[dhcpd] failed in dhcp client creation: %s", err)
return
}
defer client.Close()
ctx, _ := context.WithTimeout(context.Background(), 3*time.Second)
_, err = client.Request(ctx)
if err != nil {
return
}
return true
}
func ifaceAddr(iface string) (net.IP, net.IPMask, net.HardwareAddr, error) {
intf, err := net.InterfaceByName(iface)
if err != nil {