diff --git a/balancer.go b/balancer.go index 8b89f39..d50a0c9 100644 --- a/balancer.go +++ b/balancer.go @@ -36,7 +36,7 @@ func (r *roundRobin) DialContext(ctx context.Context, s *Subnet, network, addres ii := s.SourceIPs[(i+next)%len(s.SourceIPs)] dd := r.d.dialer dd.LocalAddr = &net.TCPAddr{IP: net.IP(ii.AsSlice())} - return r.d.dialContext(&dd, ctx, network, address) + return r.d.dialContext(ctx, &dd, network, address) } return nil, fmt.Errorf("(*roundRobin).DialContext: %w", errNoSuitableNodeFound) } @@ -50,7 +50,7 @@ func (r *firstEnabled) DialContext(ctx context.Context, s *Subnet, network, addr ii := s.SourceIPs[i] dd := r.d.dialer dd.LocalAddr = &net.TCPAddr{IP: net.IP(ii.AsSlice())} - return r.d.dialContext(&dd, ctx, network, address) + return r.d.dialContext(ctx, &dd, network, address) } return nil, fmt.Errorf("(*firstEnabled).DialContext: %w", errNoSuitableNodeFound) } diff --git a/dialer.go b/dialer.go index bc16fce..f027d08 100644 --- a/dialer.go +++ b/dialer.go @@ -54,8 +54,8 @@ type Config struct { // If true, the only configurd subnets available through this dialer. // Otherwise, a failback to the net.DefaultDialer. Restrict bool - // Dialer containes default options for the net.Dialer to use. - // LocalAddr is overriden. + // Dialer contains default options for the net.Dialer to use. + // LocalAddr is overridden. Dialer net.Dialer // Balancer specifies algorithm used to pick source address. Balancer BalancerType @@ -275,10 +275,10 @@ func (d *dialer) dialAddr(ctx context.Context, network, address string, addr net if d.restrict { return nil, fmt.Errorf("no suitable interface for: [%s]%s", network, address) } - return d.dialContext(&d.dialer, ctx, network, address) + return d.dialContext(ctx, &d.dialer, network, address) } -func (d *dialer) dialContext(nd *net.Dialer, ctx context.Context, network, address string) (net.Conn, error) { +func (d *dialer) dialContext(ctx context.Context, nd *net.Dialer, network, address string) (net.Conn, error) { if h := d.customDialContext; h != nil { return h(nd, ctx, network, address) }