webrtc: wire full NAT1To1IPs list into core config, replace single-IP workaround (issue #20)
This commit is contained in:
parent
841335d14b
commit
6ec0328b19
1 changed files with 16 additions and 7 deletions
|
|
@ -67,14 +67,23 @@ func New(dataCfg config.DataWebRTC, logger log.Logger) (*Subsystem, error) {
|
||||||
coreCfg.Enabled = dataCfg.Enable
|
coreCfg.Enabled = dataCfg.Enable
|
||||||
coreCfg.PublicIP = dataCfg.PublicIP
|
coreCfg.PublicIP = dataCfg.PublicIP
|
||||||
|
|
||||||
// If the operator configured multiple NAT1To1 IPs (e.g., dual
|
// Build the NAT1To1IPs list that Pion will use for host candidates.
|
||||||
// LAN/public), they take precedence over PublicIP. Wire them
|
// Strategy: merge PublicIP and NAT1To1IPs, deduplicating.
|
||||||
// through via PublicIP as the first entry; core/webrtc currently
|
// - If PublicIP is set it comes first.
|
||||||
// reads a single PublicIP, so M2 joins the list with the first
|
// - Any entries in NAT1To1IPs that differ from PublicIP are appended.
|
||||||
// entry winning. (Multi-IP NAT1To1 is an M3 enhancement.)
|
// This replaces the old single-IP workaround and allows dual-homed
|
||||||
if len(dataCfg.NAT1To1IPs) > 0 && coreCfg.PublicIP == "" {
|
// servers (e.g., a LAN IP + a public IP) to advertise host candidates
|
||||||
coreCfg.PublicIP = dataCfg.NAT1To1IPs[0]
|
// on all interfaces simultaneously.
|
||||||
|
nat1to1IPs := make([]string, 0, len(dataCfg.NAT1To1IPs)+1)
|
||||||
|
if dataCfg.PublicIP != "" {
|
||||||
|
nat1to1IPs = append(nat1to1IPs, dataCfg.PublicIP)
|
||||||
}
|
}
|
||||||
|
for _, ip := range dataCfg.NAT1To1IPs {
|
||||||
|
if ip != dataCfg.PublicIP {
|
||||||
|
nat1to1IPs = append(nat1to1IPs, ip)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
coreCfg.NAT1To1IPs = nat1to1IPs
|
||||||
|
|
||||||
factory, err := corewebrtc.NewPeerFactory(coreCfg)
|
factory, err := corewebrtc.NewPeerFactory(coreCfg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue