From 99f3e9ad3dc0fad1cc71e479719681418c3189b5 Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Wed, 23 Jun 2021 12:41:25 +1000 Subject: [PATCH] Reject accepted connections if we don't want conns This prevents unnecessarily stalling peers dialling us if we have no intention to ever accept. --- client.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/client.go b/client.go index e0092556..1f2af67f 100644 --- a/client.go +++ b/client.go @@ -460,6 +460,9 @@ func (cl *Client) waitAccept() { // TODO: Apply filters for non-standard networks, particularly rate-limiting. func (cl *Client) rejectAccepted(conn net.Conn) error { + if !cl.wantConns() { + return errors.New("don't want conns right now") + } ra := conn.RemoteAddr() if rip := addrIpOrNil(ra); rip != nil { if cl.config.DisableIPv4Peers && rip.To4() != nil { -- 2.48.1