Skip to content

Commit e2ab28f

Browse files
committed
server: Direct peer banning for old cfilter reqs.
This modifies the logic that bans peers for knowingly violating the protocol by sending old committed filter requests to make use of the newer BanPeer function directly and gives it a more descriptive ban reason while here.
1 parent dba8047 commit e2ab28f

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

server.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1663,12 +1663,15 @@ func (sp *serverPeer) enforceNodeCFFlag(cmd string) {
16631663
// Ban the peer if the protocol version is high enough that the peer is
16641664
// knowingly violating the protocol and banning is enabled.
16651665
//
1666-
// NOTE: Even though the addBanScore function already examines whether
1667-
// or not banning is enabled, it is checked here as well to ensure the
1668-
// violation is logged and the peer is disconnected regardless.
1666+
// NOTE: Even though BanPeer already examines whether or not banning is
1667+
// enabled, it is checked here as well to ensure the violation is logged and
1668+
// the peer is disconnected regardless.
16691669
if sp.ProtocolVersion() >= wire.NodeCFVersion && !cfg.DisableBanning {
1670-
// Disconnect the peer regardless of whether it was banned.
1671-
sp.addBanScore(100, 0, cmd)
1670+
reason := fmt.Sprintf("sent %s request with protocol version %d >= %d",
1671+
cmd, sp.ProtocolVersion(), wire.NodeCFVersion)
1672+
sp.server.BanPeer(sp, reason)
1673+
1674+
// Disconnect the peer regardless of whether it gets banned.
16721675
sp.Disconnect()
16731676
return
16741677
}

0 commit comments

Comments
 (0)