Skip to content

Commit

Permalink
Merge pull request #40 from projectdiscovery/feat-error-msg
Browse files Browse the repository at this point in the history
Improving error message when all ips fail
  • Loading branch information
ehsandeep committed Jun 9, 2022
2 parents c6be86f + 7e3c7dc commit aa5b048
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
8 changes: 4 additions & 4 deletions fastdialer/dialer.go
Expand Up @@ -6,7 +6,6 @@ import (
"crypto/tls"
"encoding/json"
"fmt"
"log"
"net"
"strings"

Expand Down Expand Up @@ -203,9 +202,7 @@ func (d *Dialer) dial(ctx context.Context, network, address string, shouldUseTLS
}
hostPort := net.JoinHostPort(ip, port)
if shouldUseTLS {
log.Println(tlsconfig.MinVersion)
tlsconfigCopy := tlsconfig.Clone()
log.Println(tlsconfigCopy.MinVersion)
switch {
case d.options.SNIName != "":
tlsconfigCopy.ServerName = d.options.SNIName
Expand Down Expand Up @@ -255,15 +252,18 @@ func (d *Dialer) dial(ctx context.Context, network, address string, shouldUseTLS
break
}
}

if conn == nil {
if numInvalidIPS == len(IPS) {
return nil, NoAddressAllowedError
}
return nil, NoAddressFoundError
return nil, CouldNotConnectError
}

if err != nil {
return nil, err
}

return
}

Expand Down
1 change: 1 addition & 0 deletions fastdialer/error.go
Expand Up @@ -5,6 +5,7 @@ import (
)

var (
CouldNotConnectError = errors.New("could not connect to any address found for host")
NoAddressFoundError = errors.New("no address found for host")
NoAddressAllowedError = errors.New("denied address found for host")
NoPortSpecifiedError = errors.New("port was not specified")
Expand Down

0 comments on commit aa5b048

Please sign in to comment.