fix: if peer sends us someone we have blocked outbound, block them inbound too

This commit is contained in:
Derrick Hammer 2024-01-15 11:04:41 -05:00
parent 3f0af1587b
commit e7026459b4
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 18 additions and 0 deletions

View File

@ -191,6 +191,24 @@ func (p *P2PImpl) ConnectToNode(connectionUris []*url.URL, retried bool, fromPee
if p.outgoingPeerFailures.Contains(idString) { if p.outgoingPeerFailures.Contains(idString) {
p.logger.Error("outgoing peer is on blocklist", zap.String("node", connectionUri.String())) p.logger.Error("outgoing peer is on blocklist", zap.String("node", connectionUri.String()))
if fromPeer != nil {
fromPeerId, err := fromPeer.Id().ToString()
if err != nil {
return err
}
fromPeerIP := fromPeer.GetIP()
p.incomingPeerBlockList.Put(fromPeerId, true)
p.incomingIPBlocklist.Put(fromPeerIP, true)
err = fromPeer.End()
if err != nil {
return err
}
p.logger.Info("blocking peer for sending peer on blocklist", zap.String("node", connectionUri.String()), zap.String("peer", fromPeerId), zap.String("ip", fromPeerIP))
}
return nil return nil
} }