diff --git a/src/Config.py b/src/Config.py index 86c48182..b72cbe5b 100644 --- a/src/Config.py +++ b/src/Config.py @@ -8,7 +8,7 @@ class Config(object): def __init__(self, argv): self.version = "0.3.5" - self.rev = 830 + self.rev = 833 self.argv = argv self.action = None self.createParser() diff --git a/src/Connection/ConnectionServer.py b/src/Connection/ConnectionServer.py index 8e19761b..23f90482 100644 --- a/src/Connection/ConnectionServer.py +++ b/src/Connection/ConnectionServer.py @@ -81,7 +81,7 @@ class ConnectionServer: # Connection flood protection if ip in self.ip_incoming and ip not in self.whitelist: self.ip_incoming[ip] += 1 - if self.ip_incoming[ip] > 3: # Allow 3 in 1 minute from same ip + if self.ip_incoming[ip] > 6: # Allow 6 in 1 minute from same ip self.log.debug("Connection flood detected from %s" % ip) time.sleep(30) sock.close() diff --git a/src/Test/TestConnectionServer.py b/src/Test/TestConnectionServer.py index c2dba481..7492925f 100644 --- a/src/Test/TestConnectionServer.py +++ b/src/Test/TestConnectionServer.py @@ -83,20 +83,13 @@ class TestConnection: file_server.whitelist = [] # Disable 127.0.0.1 whitelist client = ConnectionServer("127.0.0.1", 1545) - # Only allow 3 connection in 1 minute - connection = client.getConnection("127.0.0.1", 1544) - assert connection.handshake - connection.close() + # Only allow 6 connection in 1 minute + for reconnect in range(6): + connection = client.getConnection("127.0.0.1", 1544) + assert connection.handshake + connection.close() - connection = client.getConnection("127.0.0.1", 1544) - assert connection.handshake - connection.close() - - connection = client.getConnection("127.0.0.1", 1544) - assert connection.handshake - connection.close() - - # The 4. one will timeout + # The 7. one will timeout with pytest.raises(gevent.Timeout): with gevent.Timeout(0.1): connection = client.getConnection("127.0.0.1", 1544) diff --git a/src/main.py b/src/main.py index c45dd0e5..2a24b1cc 100644 --- a/src/main.py +++ b/src/main.py @@ -7,14 +7,13 @@ import logging # Third party modules import gevent from gevent import monkey -import ssl -# Fix PROTOCOL_SSLv3 not defined -if "PROTOCOL_SSLv3" not in dir(ssl): - ssl.PROTOCOL_SSLv3 = ssl.PROTOCOL_SSLv23 - -if "patch_subprocess" in dir(monkey): +if "patch_subprocess" in dir(monkey): # New gevent monkey.patch_all(thread=False, subprocess=False) -else: +else: # Old gevent + import ssl + # Fix PROTOCOL_SSLv3 not defined + if "PROTOCOL_SSLv3" not in dir(ssl): + ssl.PROTOCOL_SSLv3 = ssl.PROTOCOL_SSLv23 monkey.patch_all(thread=False) # Not thread: pyfilesystem and systray icon, Not subprocess: Gevent 1.1+