Fix regression when bind-address is not explicitly provided (#1837)
when bind address is set to loopback, it would break RTC IP discovery.
This commit is contained in:
@@ -3,6 +3,7 @@ package main
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
|
"net"
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
"runtime"
|
"runtime"
|
||||||
@@ -204,18 +205,30 @@ func getConfig(c *cli.Context) (*config.Config, error) {
|
|||||||
conf.Keys = map[string]string{
|
conf.Keys = map[string]string{
|
||||||
"devkey": "secret",
|
"devkey": "secret",
|
||||||
}
|
}
|
||||||
|
shouldMatchRTCIP := false
|
||||||
// when dev mode and using shared keys, we'll bind to localhost by default
|
// when dev mode and using shared keys, we'll bind to localhost by default
|
||||||
if conf.BindAddresses == nil {
|
if conf.BindAddresses == nil {
|
||||||
conf.BindAddresses = []string{
|
conf.BindAddresses = []string{
|
||||||
"127.0.0.1",
|
"127.0.0.1",
|
||||||
"::1",
|
"::1",
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// if non-loopback addresses are provided, then we'll match RTC IP to bind address
|
||||||
|
// our IP discovery ignores loopback addresses
|
||||||
|
for _, addr := range conf.BindAddresses {
|
||||||
|
ip := net.ParseIP(addr)
|
||||||
|
if ip != nil && !ip.IsLoopback() {
|
||||||
|
shouldMatchRTCIP = true
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if shouldMatchRTCIP {
|
||||||
for _, bindAddr := range conf.BindAddresses {
|
for _, bindAddr := range conf.BindAddresses {
|
||||||
conf.RTC.IPs.Includes = append(conf.RTC.IPs.Includes, bindAddr+"/24")
|
conf.RTC.IPs.Includes = append(conf.RTC.IPs.Includes, bindAddr+"/24")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return conf, nil
|
return conf, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user