limt download size

This commit is contained in:
Michel Oosterhof
2015-11-22 11:10:57 +04:00
parent beea231bfa
commit 81d2b3a403

View File

@@ -375,6 +375,12 @@ class LoggingServerProtocol(insults.ServerProtocol):
def __init__(self, prot=None, *a, **kw):
insults.ServerProtocol.__init__(self, prot, *a, **kw)
self.cfg = a[0].cfg
self.dataReceived = 0
try:
self.dataReceivedLimit = int(self.cfg.get('honeypot', 'download_limit_size'))
except:
self.dataReceivedLimit = 0
def connectionMade(self):
@@ -417,6 +423,10 @@ class LoggingServerProtocol(insults.ServerProtocol):
def dataReceived(self, data):
"""
"""
self.dataReceived += len(data)
if self.dataReceivedLimit and self.dataReceived > self.dataReceivedLimit:
self.transport.loseConnection()
if self.stdinlog_open:
with file(self.stdinlog_file, 'ab') as f:
f.write(data)