support multiple STUN servers

This commit is contained in:
David Zhao
2020-10-08 00:12:57 -07:00
parent 0a4ce6e742
commit 32af882b99
2 changed files with 11 additions and 4 deletions
+6 -1
View File
@@ -1,6 +1,8 @@
package node
import (
"errors"
"github.com/google/uuid"
"github.com/google/wire"
"github.com/pion/stun"
@@ -45,7 +47,10 @@ func NewLocalNode(conf *config.Config) (*Node, error) {
}
func (n *Node) DiscoverNetworkInfo() error {
c, err := stun.Dial("udp", n.config.StunServer)
if len(n.config.StunServers) == 0 {
return errors.New("STUN servers are required but not defined")
}
c, err := stun.Dial("udp", n.config.StunServers[0])
if err != nil {
return err
}