summaryrefslogtreecommitdiffhomepage
path: root/dhcpv4
diff options
context:
space:
mode:
authorChristopher Koch <chrisko@google.com>2019-04-07 15:28:59 -0700
committerinsomniac <insomniacslk@users.noreply.github.com>2019-04-07 23:41:22 +0100
commit73a6b7ffe80ca04462acde3883dbd811f3ab5461 (patch)
treed1691b8b53277e1227474cbf11ffef5056672752 /dhcpv4
parent175868d67987770d2d729186f7676e0b98f925df (diff)
nclient4: simplify New interface
Signed-off-by: Christopher Koch <chrisko@google.com>
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
}