]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Reject accepted connections if we don't want conns
authorMatt Joiner <anacrolix@gmail.com>
Wed, 23 Jun 2021 02:41:25 +0000 (12:41 +1000)
committerMatt Joiner <anacrolix@gmail.com>
Wed, 23 Jun 2021 02:41:25 +0000 (12:41 +1000)
This prevents unnecessarily stalling peers dialling us if we have no intention to ever accept.

client.go

index e009255689a28e11892f98aeb778cc99dbbcc05a..1f2af67fa30082b0ee1d3e98b7f5a129fd6b9d99 100644 (file)
--- 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 {