diff --git a/cmd/dstp/main.go b/cmd/dstp/main.go index da06d46..09e2dc8 100644 --- a/cmd/dstp/main.go +++ b/cmd/dstp/main.go @@ -3,11 +3,11 @@ package main import ( "context" "flag" + "fmt" "github.com/ycd/dstp/config" "github.com/ycd/dstp/pkg/dstp" "os" "path/filepath" - "fmt" ) func main() { diff --git a/pkg/dstp/dstp.go b/pkg/dstp/dstp.go index 47e763d..1384c83 100644 --- a/pkg/dstp/dstp.go +++ b/pkg/dstp/dstp.go @@ -25,6 +25,10 @@ func RunAllTests(ctx context.Context, config config.Config) error { return err } + if config.Timeout == -1 { + config.Timeout = 2 * config.PingCount + } + var wg sync.WaitGroup wg.Add(5) @@ -64,6 +68,7 @@ func testTLS(ctx context.Context, wg *sync.WaitGroup, address common.Address, t result.Mu.Unlock() return err } + err = conn.VerifyHostname(string(address)) if err != nil { result.Mu.Lock() diff --git a/pkg/ping/dns.go b/pkg/ping/dns.go index b701e2f..437ff1c 100644 --- a/pkg/ping/dns.go +++ b/pkg/ping/dns.go @@ -17,11 +17,8 @@ func RunDNSTest(ctx context.Context, wg *sync.WaitGroup, addr common.Address, co } pinger.Count = count - if timeout == -1 { - pinger.Timeout = time.Duration(2*count) * time.Second - } else { - pinger.Timeout = time.Duration(timeout) * time.Second - } + pinger.Timeout = time.Duration(timeout) * time.Second + err = pinger.Run() if err != nil { return fmt.Errorf("failed to run ping: %v", err.Error()) diff --git a/pkg/ping/ping.go b/pkg/ping/ping.go index 47b7359..d190026 100644 --- a/pkg/ping/ping.go +++ b/pkg/ping/ping.go @@ -5,14 +5,13 @@ import ( "bytes" "context" "fmt" + "github.com/ycd/dstp/pkg/common" "log" "os/exec" "runtime" "strings" "sync" "time" - - "github.com/ycd/dstp/pkg/common" ) func RunTest(ctx context.Context, wg *sync.WaitGroup, addr common.Address, count int, timeout int, result *common.Result) error { @@ -29,11 +28,8 @@ func runPing(ctx context.Context, wg *sync.WaitGroup, addr common.Address, count } pinger.Count = count - if timeout == -1 { - pinger.Timeout = time.Duration(2*count) * time.Second - } else { - pinger.Timeout = time.Duration(timeout) * time.Second - } + pinger.Timeout = time.Duration(timeout) * time.Second + err = pinger.Run() if err != nil { if out, err := runPingFallback(ctx, addr, count); err == nil {