From 0a8f75d6c93479d64bdf8d3f0e766caf48e55641 Mon Sep 17 00:00:00 2001 From: Juliusz Chroboczek Date: Fri, 26 Feb 2021 13:22:47 +0100 Subject: [PATCH] Make RelayTest take the timeout as parameter. --- galene.go | 2 +- ice/ice.go | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/galene.go b/galene.go index 3c895c4..842c520 100644 --- a/galene.go +++ b/galene.go @@ -130,7 +130,7 @@ func main() { func relayTest() { now := time.Now() - d, err := ice.RelayTest() + d, err := ice.RelayTest(20 * time.Second) if err != nil { log.Printf("Relay test failed: %v", err) log.Printf("Perhaps you didn't configure a TURN server?") diff --git a/ice/ice.go b/ice/ice.go index 9a49ed5..47b4e94 100644 --- a/ice/ice.go +++ b/ice/ice.go @@ -137,7 +137,7 @@ func ICEConfiguration() *webrtc.Configuration { return &conf.conf } -func RelayTest() (time.Duration, error) { +func RelayTest(timeout time.Duration) (time.Duration, error) { conf := ICEConfiguration() conf2 := *conf @@ -223,7 +223,7 @@ func RelayTest() (time.Duration, error) { }) }) - timer := time.NewTimer(20 * time.Second) + timer := time.NewTimer(timeout) defer timer.Stop() select { case err := <-ch1: @@ -235,6 +235,6 @@ func RelayTest() (time.Duration, error) { } return time.Now().Sub(tm), nil case <-timer.C: - return 0, errors.New("timeout") + return 0, os.ErrDeadlineExceeded } }