mirror of
https://github.com/netbirdio/netbird.git
synced 2025-06-30 22:50:22 +02:00
Add nil value check
This commit is contained in:
@ -333,10 +333,11 @@ func (conn *Conn) iCEConnectionIsReady(priority ConnPriority, iceConnInfo ICECon
|
|||||||
ep = wgProxy.EndpointAddr()
|
ep = wgProxy.EndpointAddr()
|
||||||
conn.wgProxyICE = wgProxy
|
conn.wgProxyICE = wgProxy
|
||||||
} else {
|
} 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())
|
directEp, err := net.ResolveUDPAddr("udp", iceConnInfo.RemoteConn.RemoteAddr().String())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("failed to resolveUDPaddr")
|
conn.log.Errorf("failed to resolveUDPaddr")
|
||||||
conn.handleConfigurationFailure(err, nil)
|
conn.handleConfigurationFailure(err, nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
23
client/internal/peer/nilcheck.go
Normal file
23
client/internal/peer/nilcheck.go
Normal 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")
|
||||||
|
}
|
||||||
|
}
|
@ -128,6 +128,7 @@ func (w *WorkerICE) OnNewOffer(remoteOfferAnswer *OfferAnswer) {
|
|||||||
}
|
}
|
||||||
w.log.Infof("check remoteConn: %v", remoteConn)
|
w.log.Infof("check remoteConn: %v", remoteConn)
|
||||||
w.log.Infof("check remoteConn.RemoteAddr: %v", remoteConn.RemoteAddr())
|
w.log.Infof("check remoteConn.RemoteAddr: %v", remoteConn.RemoteAddr())
|
||||||
|
nilCheck(w.log, remoteConn)
|
||||||
w.log.Debugf("agent dial succeeded")
|
w.log.Debugf("agent dial succeeded")
|
||||||
|
|
||||||
pair, err := w.agent.GetSelectedCandidatePair()
|
pair, err := w.agent.GetSelectedCandidatePair()
|
||||||
|
Reference in New Issue
Block a user