Skip to content

Commit

Permalink
Fixes for hpfeeds reconnection
Browse files Browse the repository at this point in the history
  • Loading branch information
Jc2k committed Feb 1, 2021
1 parent e041620 commit efd63af
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions modules/python/dionaea/hpfeeds.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ class FeedUnpack(object):
def __init__(self):
self.buf = bytearray()

def reset(self):
self.buf = bytearray()

def __iter__(self):
return self

Expand Down Expand Up @@ -163,6 +166,7 @@ def handle_io_in(self, indata):
logger.debug('hpclient server name {0} rand {1}'.format(name, rand))
self.send(msgauth(rand, self.ident, self.secret))
self.authenticated = True
self.handle_io_out()

elif opcode == OP_PUBLISH:
ident, data = strunpack8(data)
Expand All @@ -180,6 +184,9 @@ def handle_io_in(self, indata):
return len(indata)

def handle_io_out(self):
if not self.authenticated:
return

if self.filehandle:
self.sendfiledata()
else:
Expand Down Expand Up @@ -227,16 +234,20 @@ def sendfiledata(self):
def handle_timeout_idle(self):
pass

def handle_disconnect(self):
logger.info('hpclient disconnect')
def _reset_connection_state(self):
self.connected = False
self.authenticated = False
self.filehandle = None
self.unpacker.reset()

def handle_disconnect(self):
logger.info('hpclient disconnect')
self._reset_connection_state()
return 1

def handle_error(self, err):
logger.warn(str(err))
self.connected = False
self.authenticated = False
self._reset_connection_state()
return 1


Expand Down

0 comments on commit efd63af

Please sign in to comment.