What is the proper way to limit connections?

I’m trying to limit the number of peers to n, so I have found the connection manager library which trims down peer connections to some threshold, but the peers just connect again after discovering the peer in the DHT.

How can I simply reject connections, once i have hit the limit, rather than waiting for them to be trimmed in the connection manager?


Still looking for help on this one. There are two parts to this issue:

  • Stop dialing peers once a certain number of peers have been met.
  • Refuse new connections from peers immediately if certain number of peers is met.