Add nil value check

This commit is contained in:
Zoltán Papp 2024-10-31 16:48:10 +01:00
parent 2a3262f5a8
commit 9ccc6c6547
3 changed files with 27 additions and 2 deletions

View File

@ -333,10 +333,11 @@ func (conn *Conn) iCEConnectionIsReady(priority ConnPriority, iceConnInfo ICECon
ep = wgProxy.EndpointAddr()
conn.wgProxyICE = wgProxy
} else {
log.Infof("direct iceConnInfo: %v", iceConnInfo.RemoteConn)
conn.log.Infof("direct iceConnInfo: %v", iceConnInfo.RemoteConn)
nilCheck(conn.log, iceConnInfo.RemoteConn)
directEp, err := net.ResolveUDPAddr("udp", iceConnInfo.RemoteConn.RemoteAddr().String())
if err != nil {
log.Errorf("failed to resolveUDPaddr")
conn.log.Errorf("failed to resolveUDPaddr")
conn.handleConfigurationFailure(err, nil)
return
}

View File

@ -0,0 +1,23 @@
package peer
import (
"net"
"reflect"
log "github.com/sirupsen/logrus"
)
func nilCheck(log *log.Entry, conn net.Conn) {
if conn == nil {
log.Infof("conn is nil")
return
}
if conn.RemoteAddr() == nil {
log.Infof("conn.RemoteAddr() is nil")
}
if reflect.ValueOf(conn.RemoteAddr()).IsNil() {
log.Infof("value of conn.RemoteAddr() is nil")
}
}

View File

@ -128,6 +128,7 @@ func (w *WorkerICE) OnNewOffer(remoteOfferAnswer *OfferAnswer) {
}
w.log.Infof("check remoteConn: %v", remoteConn)
w.log.Infof("check remoteConn.RemoteAddr: %v", remoteConn.RemoteAddr())
nilCheck(w.log, remoteConn)
w.log.Debugf("agent dial succeeded")
pair, err := w.agent.GetSelectedCandidatePair()