From ad4f0a6fdfae53a569cf20b78610567a78f83f02 Mon Sep 17 00:00:00 2001 From: Zoltan Papp Date: Thu, 31 Oct 2024 23:18:35 +0100 Subject: [PATCH] [client] Nil check on ICE remote conn (#2806) --- client/internal/peer/conn.go | 5 +++++ client/internal/peer/nilcheck.go | 21 +++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 client/internal/peer/nilcheck.go diff --git a/client/internal/peer/conn.go b/client/internal/peer/conn.go index 56b772759..84a8c221f 100644 --- a/client/internal/peer/conn.go +++ b/client/internal/peer/conn.go @@ -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 { diff --git a/client/internal/peer/nilcheck.go b/client/internal/peer/nilcheck.go new file mode 100644 index 000000000..058fe9a26 --- /dev/null +++ b/client/internal/peer/nilcheck.go @@ -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 +}