summaryrefslogtreecommitdiffhomepage
path: root/dhcpv4
diff options
context:
space:
mode:
Diffstat (limited to 'dhcpv4')
-rw-r--r--dhcpv4/nclient4/client.go10
1 files changed, 7 insertions, 3 deletions
diff --git a/dhcpv4/nclient4/client.go b/dhcpv4/nclient4/client.go
index 3c97a60..099be3f 100644
--- a/dhcpv4/nclient4/client.go
+++ b/dhcpv4/nclient4/client.go
@@ -94,13 +94,17 @@ type Client struct {
}
// New returns a client usable with an unconfigured interface.
-func New(ifaceName string, ifaceHWAddr net.HardwareAddr, opts ...ClientOpt) (*Client, error) {
- c := NewWithConn(nil, ifaceHWAddr, opts...)
+func New(iface string, opts ...ClientOpt) (*Client, error) {
+ i, err := net.InterfaceByName(iface)
+ if err != nil {
+ return nil, err
+ }
+ c := NewWithConn(nil, i.HardwareAddr, opts...)
// Do this after so that a caller can still use a WithConn to override
// the connection.
if c.conn == nil {
- pc, err := NewRawUDPConn(ifaceName, ClientPort)
+ pc, err := NewRawUDPConn(iface, ClientPort)
if err != nil {
return nil, err
}