Skip to content

Commit

Permalink
return some changes after rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
ashellunts committed Nov 2, 2022
1 parent 834a2d5 commit eb3aaee
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 33 deletions.
2 changes: 1 addition & 1 deletion agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,7 @@ func (a *Agent) addPair(local, remote Candidate) *CandidatePair {
}

localCandidateHost := local.(*CandidateHost)
localCandidateHost.port = localPort // FIXME: this causes a data race with candidateBase.Port()
localCandidateHost.port = localPort // FIXME: this causes a data race with candidateBase.Port() artur

local.start(a, packetConn, a.startedCh)
}
Expand Down
68 changes: 36 additions & 32 deletions gather.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,44 +182,48 @@ func (a *Agent) gatherCandidatesLocal(ctx context.Context, networkTypes []Networ

switch network {
case tcp:
// Handle ICE TCP passive mode
var muxConns []net.PacketConn
if multi, ok := a.tcpMux.(AllConnsGetter); ok {
a.log.Debugf("GetAllConns by ufrag: %s", a.localUfrag)
muxConns, err = multi.GetAllConns(a.localUfrag, mappedIP.To4() == nil, ip)
if err != nil {
if !errors.Is(err, ErrTCPMuxNotInitialized) {
a.log.Warnf("error getting all tcp conns by ufrag: %s %s %s", network, ip, a.localUfrag)
}
continue
}
if a.activeTCP {
tcpType = TCPTypeActive
} else {
a.log.Debugf("GetConn by ufrag: %s", a.localUfrag)
conn, err := a.tcpMux.GetConnByUfrag(a.localUfrag, mappedIP.To4() == nil, ip)
if err != nil {
if !errors.Is(err, ErrTCPMuxNotInitialized) {
a.log.Warnf("error getting tcp conn by ufrag: %s %s %s", network, ip, a.localUfrag)
// Handle ICE TCP passive mode
var muxConns []net.PacketConn
if multi, ok := a.tcpMux.(AllConnsGetter); ok {
a.log.Debugf("GetAllConns by ufrag: %s", a.localUfrag)
muxConns, err = multi.GetAllConns(a.localUfrag, mappedIP.To4() == nil, ip)
if err != nil {
if !errors.Is(err, ErrTCPMuxNotInitialized) {
a.log.Warnf("error getting all tcp conns by ufrag: %s %s %s", network, ip, a.localUfrag)
}
continue
}
continue
} else {
a.log.Debugf("GetConn by ufrag: %s", a.localUfrag)
conn, err := a.tcpMux.GetConnByUfrag(a.localUfrag, mappedIP.To4() == nil, ip)
if err != nil {
if !errors.Is(err, ErrTCPMuxNotInitialized) {
a.log.Warnf("error getting tcp conn by ufrag: %s %s %s", network, ip, a.localUfrag)
}
continue
}
muxConns = []net.PacketConn{conn}
}
muxConns = []net.PacketConn{conn}
}

// Extract the port for each PacketConn we got.
for _, conn := range muxConns {
if tcpConn, ok := conn.LocalAddr().(*net.TCPAddr); ok {
conns = append(conns, connAndPort{conn, tcpConn.Port})
} else {
a.log.Warnf("failed to get port of conn from TCPMux: %s %s %s", network, ip, a.localUfrag)
// Extract the port for each PacketConn we got.
for _, conn := range muxConns {
if tcpConn, ok := conn.LocalAddr().(*net.TCPAddr); ok {
conns = append(conns, connAndPort{conn, tcpConn.Port})
} else {
a.log.Warnf("failed to get port of conn from TCPMux: %s %s %s", network, ip, a.localUfrag)
}
}
if len(conns) == 0 {
// Didn't succeed with any, try the next network.
continue
}
tcpType = TCPTypePassive
// is there a way to verify that the listen address is even
// accessible from the current interface.
}
if len(conns) == 0 {
// Didn't succeed with any, try the next network.
continue
}
tcpType = TCPTypePassive
// is there a way to verify that the listen address is even
// accessible from the current interface.
case udp:
conn, err := listenUDPInPortRange(a.net, a.log, int(a.portmax), int(a.portmin), network, &net.UDPAddr{IP: ip, Port: 0})
if err != nil {
Expand Down

0 comments on commit eb3aaee

Please sign in to comment.