mirror of
https://github.com/netbirdio/netbird.git
synced 2024-12-13 10:21:10 +01:00
Sonar fix
This commit is contained in:
parent
f0c829afac
commit
6553d8ce03
@ -65,26 +65,7 @@ func (p *Peer) Work() {
|
||||
case messages.MsgTypeHealthCheck:
|
||||
hc.OnHCResponse()
|
||||
case messages.MsgTypeTransport:
|
||||
peerID, err := messages.UnmarshalTransportID(msg)
|
||||
if err != nil {
|
||||
p.log.Errorf("failed to unmarshal transport message: %s", err)
|
||||
continue
|
||||
}
|
||||
stringPeerID := messages.HashIDToString(peerID)
|
||||
dp, ok := p.store.Peer(stringPeerID)
|
||||
if !ok {
|
||||
p.log.Errorf("peer not found: %s", stringPeerID)
|
||||
continue
|
||||
}
|
||||
err = messages.UpdateTransportMsg(msg, p.idB)
|
||||
if err != nil {
|
||||
p.log.Errorf("failed to update transport message: %s", err)
|
||||
continue
|
||||
}
|
||||
_, err = dp.Write(msg)
|
||||
if err != nil {
|
||||
p.log.Errorf("failed to write transport message to: %s", dp.String())
|
||||
}
|
||||
p.handleTransportMsg(msg)
|
||||
case messages.MsgTypeClose:
|
||||
p.log.Infof("peer exited gracefully")
|
||||
_ = p.conn.Close()
|
||||
@ -161,3 +142,26 @@ func (p *Peer) healthcheck(ctx context.Context, hc *healthcheck.Sender) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (p *Peer) handleTransportMsg(msg []byte) {
|
||||
peerID, err := messages.UnmarshalTransportID(msg)
|
||||
if err != nil {
|
||||
p.log.Errorf("failed to unmarshal transport message: %s", err)
|
||||
return
|
||||
}
|
||||
stringPeerID := messages.HashIDToString(peerID)
|
||||
dp, ok := p.store.Peer(stringPeerID)
|
||||
if !ok {
|
||||
p.log.Errorf("peer not found: %s", stringPeerID)
|
||||
return
|
||||
}
|
||||
err = messages.UpdateTransportMsg(msg, p.idB)
|
||||
if err != nil {
|
||||
p.log.Errorf("failed to update transport message: %s", err)
|
||||
return
|
||||
}
|
||||
_, err = dp.Write(msg)
|
||||
if err != nil {
|
||||
p.log.Errorf("failed to write transport message to: %s", dp.String())
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user