mirror of
https://github.com/netbirdio/ice.git
synced 2026-05-22 17:10:58 -07:00
Fix duplicate TCP candidates
Duplicate TCP candidates share the same candidateConn, which would be closed if started before checking.
This commit is contained in:
@@ -808,11 +808,10 @@ func (a *Agent) addRemoteCandidate(c Candidate) {
|
||||
|
||||
func (a *Agent) addCandidate(ctx context.Context, c Candidate, candidateConn net.PacketConn) error {
|
||||
return a.run(ctx, func(ctx context.Context, agent *Agent) {
|
||||
c.start(a, candidateConn, a.startedCh)
|
||||
|
||||
set := a.localCandidates[c.NetworkType()]
|
||||
for _, candidate := range set {
|
||||
if candidate.Equal(c) {
|
||||
a.log.Debugf("Ignore duplicate candidate: %s", c.String())
|
||||
if err := c.close(); err != nil {
|
||||
a.log.Warnf("Failed to close duplicate candidate: %v", err)
|
||||
}
|
||||
@@ -820,6 +819,8 @@ func (a *Agent) addCandidate(ctx context.Context, c Candidate, candidateConn net
|
||||
}
|
||||
}
|
||||
|
||||
c.start(a, candidateConn, a.startedCh)
|
||||
|
||||
set = append(set, c)
|
||||
a.localCandidates[c.NetworkType()] = set
|
||||
|
||||
|
||||
+1
-1
@@ -159,7 +159,7 @@ func (m *TCPMuxDefault) handleConn(conn net.Conn) {
|
||||
|
||||
n, err := readStreamingPacket(conn, buf)
|
||||
if err != nil {
|
||||
m.params.Logger.Warnf("Error reading first packet: %s", err)
|
||||
m.params.Logger.Warnf("Error reading first packet from %s: %s", conn.RemoteAddr().String(), err)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user