mirror of
https://github.com/sshuttle/sshuttle.git
synced 2025-01-31 18:49:15 +01:00
server.py: don't send partial hostwatch lists.
If hostwatch has a lot of stuff to say all at once, it would come in more than one recv() packet, and server.py would send each packet individually as a CMD_HOST_LIST message. Unfortunately, client.py (rightly) expects each CMD_HOST_LIST message to be complete, ie. a correct sequence of rows. So now server.py makes sure of this. If there's a leftover bit (ie. an unterminated line), it saves it for later. Bug reported by user "Duke" on the mailing list.
This commit is contained in:
parent
ae32fe2a59
commit
a32305a275
10
server.py
10
server.py
@ -133,12 +133,20 @@ def main():
|
|||||||
mux.send(0, ssnet.CMD_ROUTES, routepkt)
|
mux.send(0, ssnet.CMD_ROUTES, routepkt)
|
||||||
|
|
||||||
hw = Hostwatch()
|
hw = Hostwatch()
|
||||||
|
hw.leftover = ''
|
||||||
|
|
||||||
def hostwatch_ready():
|
def hostwatch_ready():
|
||||||
assert(hw.pid)
|
assert(hw.pid)
|
||||||
content = hw.sock.recv(4096)
|
content = hw.sock.recv(4096)
|
||||||
if content:
|
if content:
|
||||||
mux.send(0, ssnet.CMD_HOST_LIST, content)
|
lines = (hw.leftover + content).split('\n')
|
||||||
|
if lines[-1]:
|
||||||
|
# no terminating newline: entry isn't complete yet!
|
||||||
|
hw.leftover = lines.pop()
|
||||||
|
lines.append('')
|
||||||
|
else:
|
||||||
|
hw.leftover = ''
|
||||||
|
mux.send(0, ssnet.CMD_HOST_LIST, '\n'.join(lines))
|
||||||
else:
|
else:
|
||||||
raise Fatal('hostwatch process died')
|
raise Fatal('hostwatch process died')
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user