Skip to content
This repository has been archived by the owner on Mar 16, 2022. It is now read-only.

Commit

Permalink
Fix IceAgent improperly returning XorAddress
Browse files Browse the repository at this point in the history
IceAgent improperly returns XorAddress when finding ports.
This would cause the portManager to fail finding the relevant port
since we are bound on the local (and not our public XorAddress)

Resolves pion#140
  • Loading branch information
Sean-Der committed Sep 15, 2018
1 parent 0b55046 commit b489b33
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions pkg/ice/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,19 @@ type CandidatePair struct {
local Candidate
}

// GetAddrs returns network addresses for the candidate pair
func (c CandidatePair) GetAddrs() (local *stun.TransportAddr, remote *net.UDPAddr) {
func (c CandidatePair) getAddrs() (local *stun.TransportAddr, remote *net.UDPAddr) {
localIP := net.ParseIP(c.local.GetBase().Address)
localPort := c.local.GetBase().Port

switch c := c.local.(type) {
case *CandidateSrflx:
localIP = net.ParseIP(c.RemoteAddress)
localPort = c.RemotePort
}

return &stun.TransportAddr{
IP: net.ParseIP(c.local.GetBase().Address),
Port: c.local.GetBase().Port,
IP: localIP,
Port: localPort,
}, &net.UDPAddr{
IP: net.ParseIP(c.remote.GetBase().Address),
Port: c.remote.GetBase().Port,
Expand Down Expand Up @@ -364,10 +372,10 @@ func (a *Agent) SelectedPair() (local *stun.TransportAddr, remote *net.UDPAddr)

if a.selectedPair.remote == nil || a.selectedPair.local == nil {
for _, p := range a.validPairs {
return p.GetAddrs()
return p.getAddrs()
}
return nil, nil
}

return a.selectedPair.GetAddrs()
return a.selectedPair.getAddrs()
}

0 comments on commit b489b33

Please sign in to comment.