mirror of
https://github.com/netbirdio/netbird.git
synced 2026-03-31 06:34:19 -04:00
Compare commits
4 Commits
feature/us
...
debug
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8ac5e9d866 | ||
|
|
954e038da0 | ||
|
|
9ccc6c6547 | ||
|
|
2a3262f5a8 |
@@ -333,9 +333,12 @@ func (conn *Conn) iCEConnectionIsReady(priority ConnPriority, iceConnInfo ICECon
|
||||
ep = wgProxy.EndpointAddr()
|
||||
conn.wgProxyICE = wgProxy
|
||||
} else {
|
||||
conn.log.Infof("direct iceConnInfo: %v", iceConnInfo.RemoteConn)
|
||||
agentCheck(conn.log, iceConnInfo.Agent)
|
||||
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
|
||||
}
|
||||
|
||||
54
client/internal/peer/nilcheck.go
Normal file
54
client/internal/peer/nilcheck.go
Normal file
@@ -0,0 +1,54 @@
|
||||
package peer
|
||||
|
||||
import (
|
||||
"net"
|
||||
"reflect"
|
||||
|
||||
"github.com/pion/ice/v3"
|
||||
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")
|
||||
return
|
||||
}
|
||||
|
||||
if reflect.ValueOf(conn.RemoteAddr()).IsNil() {
|
||||
log.Infof("value of conn.RemoteAddr() is nil")
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
func agentCheck(log *log.Entry, agent *ice.Agent) {
|
||||
if agent == nil {
|
||||
log.Errorf("agent is nil")
|
||||
return
|
||||
}
|
||||
|
||||
pair, err := agent.GetSelectedCandidatePair()
|
||||
if err != nil {
|
||||
log.Errorf("error getting selected candidate pair: %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
if pair == nil {
|
||||
log.Errorf("pair is nil")
|
||||
return
|
||||
}
|
||||
|
||||
if pair.Remote == nil {
|
||||
log.Errorf("pair.Remote is nil")
|
||||
return
|
||||
}
|
||||
|
||||
if pair.Remote.Address() == "" {
|
||||
log.Errorf("address is empty")
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -29,6 +29,7 @@ type ICEConnInfo struct {
|
||||
LocalIceCandidateEndpoint string
|
||||
Relayed bool
|
||||
RelayedOnLocal bool
|
||||
Agent *ice.Agent
|
||||
}
|
||||
|
||||
type WorkerICECallbacks struct {
|
||||
@@ -126,6 +127,9 @@ func (w *WorkerICE) OnNewOffer(remoteOfferAnswer *OfferAnswer) {
|
||||
w.log.Debugf("failed to dial the remote peer: %s", err)
|
||||
return
|
||||
}
|
||||
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()
|
||||
@@ -154,6 +158,7 @@ func (w *WorkerICE) OnNewOffer(remoteOfferAnswer *OfferAnswer) {
|
||||
RemoteIceCandidateEndpoint: fmt.Sprintf("%s:%d", pair.Remote.Address(), pair.Remote.Port()),
|
||||
Relayed: isRelayed(pair),
|
||||
RelayedOnLocal: isRelayCandidate(pair.Local),
|
||||
Agent: agent,
|
||||
}
|
||||
w.log.Debugf("on ICE conn read to use ready")
|
||||
go w.conn.OnConnReady(w.selectedPriority, ci)
|
||||
@@ -322,8 +327,10 @@ func (w *WorkerICE) shouldSendExtraSrflxCandidate(candidate ice.Candidate) bool
|
||||
func (w *WorkerICE) turnAgentDial(ctx context.Context, remoteOfferAnswer *OfferAnswer) (*ice.Conn, error) {
|
||||
isControlling := w.config.LocalKey > w.config.Key
|
||||
if isControlling {
|
||||
w.log.Infof("dialing remote peer %s as controlling", w.config.Key)
|
||||
return w.agent.Dial(ctx, remoteOfferAnswer.IceCredentials.UFrag, remoteOfferAnswer.IceCredentials.Pwd)
|
||||
} else {
|
||||
w.log.Infof("dialing remote peer %s as controlled", w.config.Key)
|
||||
return w.agent.Accept(ctx, remoteOfferAnswer.IceCredentials.UFrag, remoteOfferAnswer.IceCredentials.Pwd)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user