From 7e3c7dcecf161dd1d3b536e443cd6d7620ce5429 Mon Sep 17 00:00:00 2001 From: mzack Date: Thu, 9 Jun 2022 11:27:37 +0200 Subject: [PATCH] Improving error message when all ips fail --- fastdialer/dialer.go | 8 ++++---- fastdialer/error.go | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/fastdialer/dialer.go b/fastdialer/dialer.go index 13ec31f..59d2c11 100644 --- a/fastdialer/dialer.go +++ b/fastdialer/dialer.go @@ -6,7 +6,6 @@ import ( "crypto/tls" "encoding/json" "fmt" - "log" "net" "strings" @@ -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 @@ -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 } diff --git a/fastdialer/error.go b/fastdialer/error.go index 8ceb2c9..c37980e 100644 --- a/fastdialer/error.go +++ b/fastdialer/error.go @@ -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")