fix: only block peer id if we can get the id
This commit is contained in:
parent
0ce9b139b1
commit
def05376f5
|
@ -192,15 +192,19 @@ func (p *P2PImpl) ConnectToNode(connectionUris []*url.URL, retried bool, fromPee
|
||||||
if p.outgoingPeerBlocklist.Contains(idString) {
|
if p.outgoingPeerBlocklist.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()))
|
||||||
|
|
||||||
|
var fromPeerId string
|
||||||
|
|
||||||
if fromPeer != nil {
|
if fromPeer != nil {
|
||||||
fromPeerId, err := fromPeer.Id().ToString()
|
if fromPeer.Id() != nil {
|
||||||
if err != nil {
|
fromPeerId, err = fromPeer.Id().ToString()
|
||||||
return err
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
p.incomingPeerBlockList.Put(fromPeerId, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
fromPeerIP := fromPeer.GetIP()
|
fromPeerIP := fromPeer.GetIP()
|
||||||
|
|
||||||
p.incomingPeerBlockList.Put(fromPeerId, true)
|
|
||||||
p.incomingIPBlocklist.Put(fromPeerIP, true)
|
p.incomingIPBlocklist.Put(fromPeerIP, true)
|
||||||
err = fromPeer.End()
|
err = fromPeer.End()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -239,13 +243,18 @@ func (p *P2PImpl) ConnectToNode(connectionUris []*url.URL, retried bool, fromPee
|
||||||
p.outgoingPeerFailures.Put(idString, counter)
|
p.outgoingPeerFailures.Put(idString, counter)
|
||||||
|
|
||||||
if counter >= p.maxOutgoingPeerFailures {
|
if counter >= p.maxOutgoingPeerFailures {
|
||||||
|
|
||||||
if fromPeer != nil {
|
if fromPeer != nil {
|
||||||
fromPeerId, err := fromPeer.Id().ToString()
|
var fromPeerId string
|
||||||
if err != nil {
|
if fromPeer.Id() != nil {
|
||||||
return err
|
fromPeerId, err = fromPeer.Id().ToString()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
p.incomingPeerBlockList.Put(fromPeerId, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
fromPeerIP := fromPeer.GetIP()
|
fromPeerIP := fromPeer.GetIP()
|
||||||
p.incomingPeerBlockList.Put(fromPeerId, true)
|
|
||||||
p.incomingIPBlocklist.Put(fromPeerIP, true)
|
p.incomingIPBlocklist.Put(fromPeerIP, true)
|
||||||
err = fromPeer.End()
|
err = fromPeer.End()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in New Issue