mirror of
https://github.com/aljazceru/cowrie.git
synced 2026-01-31 12:04:24 +01:00
move handling of interactive sessions completely to protocol.py
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user