Skip to content

Commit

Permalink
feat: fixed networkpolicy logic to return as one found
Browse files Browse the repository at this point in the history
  • Loading branch information
Ice3man543 committed Apr 11, 2024
1 parent 09139e3 commit df32b07
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions fastdialer/dialer.go
Expand Up @@ -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 != "" {
Expand All @@ -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 {
Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit df32b07

Please sign in to comment.