From df32b07d1bb3a9c74b54605a2d1676dcb1d45033 Mon Sep 17 00:00:00 2001 From: Ice3man Date: Thu, 11 Apr 2024 23:46:28 +0530 Subject: [PATCH] feat: fixed networkpolicy logic to return as one found --- fastdialer/dialer.go | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/fastdialer/dialer.go b/fastdialer/dialer.go index 0c3f024..ab7c3de 100644 --- a/fastdialer/dialer.go +++ b/fastdialer/dialer.go @@ -191,7 +191,6 @@ func (d *Dialer) dial(ctx context.Context, network, address string, shouldUseTLS return nil, NoAddressFoundError } - var numInvalidIPS int var IPS []string // use fixed ip as first if fixedIP != "" { @@ -203,8 +202,7 @@ func (d *Dialer) dial(ctx context.Context, network, address string, shouldUseTLS for _, ip := range IPS { // check if we have allow/deny list if !d.networkpolicy.Validate(ip) { - numInvalidIPS++ - continue + return nil, NoAddressAllowedError } hostPort := net.JoinHostPort(ip, port) if shouldUseTLS { @@ -288,9 +286,6 @@ func (d *Dialer) dial(ctx context.Context, network, address string, shouldUseTLS } if conn == nil { - if numInvalidIPS == len(IPS) { - return nil, NoAddressAllowedError - } return nil, CouldNotConnectError }