mirror of
https://github.com/nadoo/glider.git
synced 2025-02-23 17:35:40 +08:00
28 lines
469 B
Go
28 lines
469 B
Go
package dhcpd
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
"github.com/insomniacslk/dhcp/dhcpv4/nclient4"
|
|
|
|
"github.com/nadoo/glider/pkg/log"
|
|
)
|
|
|
|
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
|
|
}
|