Reject accepted connections if we don't want conns

This prevents unnecessarily stalling peers dialling us if we have no intention to ever accept.
This commit is contained in:
Matt Joiner 2021-06-23 12:41:25 +10:00
parent 42a2fb445f
commit 99f3e9ad3d
1 changed files with 3 additions and 0 deletions

View File

@ -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 {