Refine ipv6 support (#4352)
* Refine ipv6 support * go mod * check ipv4 is set in turn
This commit is contained in:
@@ -796,7 +796,7 @@ func (conf *Config) updateFromCLI(c *cli.Command, baseFlags []cli.Flag) error {
|
||||
conf.TURN.KeyFile = c.String("turn-key")
|
||||
}
|
||||
if c.IsSet("node-ip") {
|
||||
conf.RTC.NodeIP = c.String("node-ip")
|
||||
conf.RTC.NodeIP.UnmarshalString(c.String("node-ip"))
|
||||
}
|
||||
if c.IsSet("udp-port") {
|
||||
conf.RTC.UDPPort.UnmarshalString(c.String("udp-port"))
|
||||
|
||||
+2
-2
@@ -48,7 +48,7 @@ type LocalNodeImpl struct {
|
||||
|
||||
func NewLocalNode(conf *config.Config) (*LocalNodeImpl, error) {
|
||||
nodeID := guid.New(utils.NodePrefix)
|
||||
if conf != nil && conf.RTC.NodeIP == "" {
|
||||
if conf != nil && conf.RTC.NodeIP.IsEmpty() {
|
||||
return nil, ErrIPNotSet
|
||||
}
|
||||
nowUnix := time.Now().Unix()
|
||||
@@ -65,7 +65,7 @@ func NewLocalNode(conf *config.Config) (*LocalNodeImpl, error) {
|
||||
}
|
||||
var nsc *config.NodeStatsConfig
|
||||
if conf != nil {
|
||||
l.node.Ip = conf.RTC.NodeIP
|
||||
l.node.Ip = conf.RTC.NodeIP.PrimaryIP()
|
||||
l.node.Region = conf.Region
|
||||
|
||||
nsc = &conf.NodeStats
|
||||
|
||||
+4
-1
@@ -53,6 +53,9 @@ func NewTurnServer(conf *config.Config, authHandler turn.AuthHandler, standalone
|
||||
if turnConf.TLSPort <= 0 && turnConf.UDPPort <= 0 {
|
||||
return nil, errors.New("invalid TURN ports")
|
||||
}
|
||||
if conf.RTC.NodeIP.V4 == "" {
|
||||
return nil, errors.New("invalid node IPv4 for relay")
|
||||
}
|
||||
|
||||
serverConfig := turn.ServerConfig{
|
||||
Realm: LivekitRealm,
|
||||
@@ -60,7 +63,7 @@ func NewTurnServer(conf *config.Config, authHandler turn.AuthHandler, standalone
|
||||
LoggerFactory: pionlogger.NewLoggerFactory(logger.GetLogger()),
|
||||
}
|
||||
var relayAddrGen turn.RelayAddressGenerator = &turn.RelayAddressGeneratorPortRange{
|
||||
RelayAddress: net.ParseIP(conf.RTC.NodeIP),
|
||||
RelayAddress: net.ParseIP(conf.RTC.NodeIP.V4),
|
||||
Address: "0.0.0.0",
|
||||
MinPort: turnConf.RelayPortRangeStart,
|
||||
MaxPort: turnConf.RelayPortRangeEnd,
|
||||
|
||||
Reference in New Issue
Block a user