MCPcopy Index your code
hub / github.com/HelloZeroNet/ZeroNet / testFloodProtection

Method testFloodProtection

src/Test/TestConnectionServer.py:101–118  ·  view source on GitHub ↗
(self, file_server)

Source from the content-addressed store, hash-verified

99 client.stop()
100
101 def testFloodProtection(self, file_server):
102 whitelist = file_server.whitelist # Save for reset
103 file_server.whitelist = [] # Disable 127.0.0.1 whitelist
104 client = ConnectionServer(file_server.ip, 1545)
105
106 # Only allow 6 connection in 1 minute
107 for reconnect in range(6):
108 connection = client.getConnection(file_server.ip, 1544)
109 assert connection.handshake
110 connection.close()
111
112 # The 7. one will timeout
113 with pytest.raises(gevent.Timeout):
114 with gevent.Timeout(0.1):
115 connection = client.getConnection(file_server.ip, 1544)
116
117 # Reset whitelist
118 file_server.whitelist = whitelist

Callers

nothing calls this directly

Calls 3

getConnectionMethod · 0.95
ConnectionServerClass · 0.90
closeMethod · 0.45

Tested by

no test coverage detected