From: Matt Joiner Date: Wed, 23 Jun 2021 02:41:25 +0000 (+1000) Subject: Reject accepted connections if we don't want conns X-Git-Tag: v1.29.0~14 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=99f3e9ad3dc0fad1cc71e479719681418c3189b5;p=btrtrc.git Reject accepted connections if we don't want conns This prevents unnecessarily stalling peers dialling us if we have no intention to ever accept. --- 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 {