Since disconnectnode function allows to be used with a subnet, e.g.:
https://github.com/bitcoin/bitcoin/blob/38d06e1561013f4ca845fd5ba6ffcc64de67f9c0/src/net.h#L826-L829
https://github.com/bitcoin/bitcoin/blob/38d06e1561013f4ca845fd5ba6ffcc64de67f9c0/src/net.cpp#L2589-L2601
This PR adds support for subnet in address parameter in disconnectnode RPC. When passing a string with / in address, it is gonna recognize it as a subnet.. It allows us to disconnect multiple nodes from all ports on the same IP. The only way to do it before was banning them for 1sec which seems a bad UX.
Also, when there are multiples nodes connected to a node in a functional test and we want to disconnect them all, we could call disconnectnode with a subnet instead of calling disconnect_nodes multiple times.
A simple example:
- for i in range(1, 6):
- self.disconnect_nodes(i, 0)
-
+ self.nodes[0].disconnectnode(address="127.0.0.1/24")
+ self.wait_until(lambda: len(self.nodes[0].getpeerinfo()) == 0, timeout=10)