move handling of interactive sessions completely to protocol.py

This commit is contained in:
Michel Oosterhof
2016-01-11 14:13:29 +04:00
parent 403916397f
commit 381ef822da
2 changed files with 4 additions and 6 deletions

View File

@@ -107,8 +107,6 @@ class HoneyPotBaseProtocol(insults.TerminalProtocol, TimeoutMixin):
def connectionLost(self, reason):
"""
this is only called on explicit logout, not on disconnect
this indicates the closing of the channel/session, not the closing of the transport
"""
self.setTimeout(None)
insults.TerminalProtocol.connectionLost(self, reason)
@@ -273,9 +271,11 @@ class HoneyPotInteractiveProtocol(HoneyPotBaseProtocol, recvline.HistoricRecvLin
def connectionLost(self, reason):
"""
this doesn't seem to be called upon disconnect, so please use
HoneyPotTransport.connectionLost instead
"""
transport = self.terminal.transport.session.conn.transport
if transport.transport.sessionno in transport.factory.sessions:
del transport.factory.sessions[transport.transport.sessionno]
self.lastlogExit()
HoneyPotBaseProtocol.connectionLost(self, reason)
recvline.HistoricRecvLine.connectionLost(self, reason)

View File

@@ -264,8 +264,6 @@ class HoneyPotTransport(transport.SSHServerTransport, TimeoutMixin):
This seems to be the only reliable place of catching lost connection
"""
self.setTimeout(None)
if self.transport.sessionno in self.factory.sessions:
del self.factory.sessions[self.transport.sessionno]
transport.SSHServerTransport.connectionLost(self, reason)
self.transport.connectionLost(reason)
self.transport = None