Fail IP lookup with STUN failure (#289)

Resolves #226
This commit is contained in:
David Zhao
2021-12-27 16:43:13 -08:00
committed by GitHub
parent 554baa54f6
commit 472f51cdba
+10 -6
View File
@@ -6,7 +6,6 @@ import (
"net" "net"
"time" "time"
"github.com/livekit/protocol/logger"
"github.com/pion/stun" "github.com/pion/stun"
"github.com/pkg/errors" "github.com/pkg/errors"
) )
@@ -17,12 +16,17 @@ func (conf *Config) determineIP() (string, error) {
if len(stunServers) == 0 { if len(stunServers) == 0 {
stunServers = DefaultStunServers stunServers = DefaultStunServers
} }
ip, err := GetExternalIP(stunServers) var err error
if err == nil { for i := 0; i < 3; i++ {
return ip, nil var ip string
} else { ip, err = GetExternalIP(stunServers)
logger.Errorw("could not get external IP", err) if err == nil {
return ip, nil
} else {
time.Sleep(500 * time.Millisecond)
}
} }
return "", errors.Errorf("could not resolve external IP: %v", err)
} }
// use local ip instead // use local ip instead