Skip to content

Commit

Permalink
[client] Nil check on ICE remote conn (#2806)
Browse files Browse the repository at this point in the history
  • Loading branch information
pappz authored Oct 31, 2024
1 parent 4c758c6 commit ad4f0a6
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
5 changes: 5 additions & 0 deletions client/internal/peer/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,11 @@ func (conn *Conn) iCEConnectionIsReady(priority ConnPriority, iceConnInfo ICECon
return
}

if remoteConnNil(conn.log, iceConnInfo.RemoteConn) {
conn.log.Errorf("remote ICE connection is nil")
return
}

conn.log.Debugf("ICE connection is ready")

if conn.currentConnPriority > priority {
Expand Down
21 changes: 21 additions & 0 deletions client/internal/peer/nilcheck.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package peer

import (
"net"

log "github.com/sirupsen/logrus"
)

func remoteConnNil(log *log.Entry, conn net.Conn) bool {
if conn == nil {
log.Errorf("ice conn is nil")
return true
}

if conn.RemoteAddr() == nil {
log.Errorf("ICE remote address is nil")
return true
}

return false
}

0 comments on commit ad4f0a6

Please sign in to comment.