diff --git a/client/internal/peer/worker_ice.go b/client/internal/peer/worker_ice.go index 22808f53644..ba3967f6231 100644 --- a/client/internal/peer/worker_ice.go +++ b/client/internal/peer/worker_ice.go @@ -126,7 +126,7 @@ func (w *WorkerICE) OnNewOffer(remoteOfferAnswer *OfferAnswer) { w.log.Debugf("failed to dial the remote peer: %s", err) return } - if remoteConnNil(remoteConn) { + if w.remoteConnNil(remoteConn) { w.log.Errorf("unexpected remote conn state") return } @@ -331,6 +331,19 @@ func (w *WorkerICE) turnAgentDial(ctx context.Context, remoteOfferAnswer *OfferA return w.agent.Accept(ctx, remoteOfferAnswer.IceCredentials.UFrag, remoteOfferAnswer.IceCredentials.Pwd) } } +func (w *WorkerICE) remoteConnNil(conn *ice.Conn) bool { + if conn == nil { + w.log.Errorf("ice conn is nil") + return true + } + + if conn.RemoteAddr() == nil { + w.log.Errorf("ICE remote address is nil") + return true + } + + return false +} func extraSrflxCandidate(candidate ice.Candidate) (*ice.CandidateServerReflexive, error) { relatedAdd := candidate.RelatedAddress() @@ -382,7 +395,3 @@ func isRelayed(pair *ice.CandidatePair) bool { } return false } - -func remoteConnNil(conn *ice.Conn) bool { - return conn == nil || conn.RemoteAddr() == nil -}