diff options
Diffstat (limited to 'dhcpv6/async')
-rw-r--r-- | dhcpv6/async/client.go | 11 | ||||
-rw-r--r-- | dhcpv6/async/client_test.go | 7 |
2 files changed, 10 insertions, 8 deletions
diff --git a/dhcpv6/async/client.go b/dhcpv6/async/client.go index 7a8b9ec..4c73383 100644 --- a/dhcpv6/async/client.go +++ b/dhcpv6/async/client.go @@ -7,8 +7,9 @@ import ( "sync" "time" - "github.com/fanliao/go-promise" + promise "github.com/fanliao/go-promise" "github.com/insomniacslk/dhcp/dhcpv6" + "github.com/insomniacslk/dhcp/dhcpv6/client6" ) // Client implements an asynchronous DHCPv6 client @@ -32,8 +33,8 @@ type Client struct { // NewClient creates an asynchronous client func NewClient() *Client { return &Client{ - ReadTimeout: dhcpv6.DefaultReadTimeout, - WriteTimeout: dhcpv6.DefaultWriteTimeout, + ReadTimeout: client6.DefaultReadTimeout, + WriteTimeout: client6.DefaultWriteTimeout, } } @@ -164,7 +165,7 @@ func (c *Client) receive(_ dhcpv6.DHCPv6) { c.connection.SetReadDeadline(time.Now().Add(c.ReadTimeout)) for { - buffer := make([]byte, dhcpv6.MaxUDPReceivedPacketSize) + buffer := make([]byte, client6.MaxUDPReceivedPacketSize) n, _, _, _, err := c.connection.ReadMsgUDP(buffer, oobdata) if err != nil { if err, ok := err.(net.Error); !ok || !err.Timeout() { @@ -196,7 +197,7 @@ func (c *Client) receive(_ dhcpv6.DHCPv6) { func (c *Client) remoteAddr() (*net.UDPAddr, error) { if c.RemoteAddr == nil { - return &net.UDPAddr{IP: dhcpv6.AllDHCPRelayAgentsAndServers, Port: dhcpv6.DefaultServerPort}, nil + return &net.UDPAddr{IP: client6.AllDHCPRelayAgentsAndServers, Port: dhcpv6.DefaultServerPort}, nil } if addr, ok := c.RemoteAddr.(*net.UDPAddr); ok { diff --git a/dhcpv6/async/client_test.go b/dhcpv6/async/client_test.go index 25a71a8..a49623e 100644 --- a/dhcpv6/async/client_test.go +++ b/dhcpv6/async/client_test.go @@ -7,6 +7,7 @@ import ( "time" "github.com/insomniacslk/dhcp/dhcpv6" + "github.com/insomniacslk/dhcp/dhcpv6/client6" "github.com/insomniacslk/dhcp/iana" "github.com/stretchr/testify/require" ) @@ -37,7 +38,7 @@ func serve(ctx context.Context, addr *net.UDPAddr, response dhcpv6.DHCPv6) error go func() { defer conn.Close() oobdata := []byte{} - buffer := make([]byte, dhcpv6.MaxUDPReceivedPacketSize) + buffer := make([]byte, client6.MaxUDPReceivedPacketSize) for { select { case <-ctx.Done(): @@ -66,8 +67,8 @@ func serve(ctx context.Context, addr *net.UDPAddr, response dhcpv6.DHCPv6) error func TestNewClient(t *testing.T) { c := NewClient() require.NotNil(t, c) - require.Equal(t, c.ReadTimeout, dhcpv6.DefaultReadTimeout) - require.Equal(t, c.ReadTimeout, dhcpv6.DefaultWriteTimeout) + require.Equal(t, c.ReadTimeout, client6.DefaultReadTimeout) + require.Equal(t, c.ReadTimeout, client6.DefaultWriteTimeout) } func TestOpenInvalidAddrFailes(t *testing.T) { |