mirror of
https://github.com/sshuttle/sshuttle.git
synced 2024-11-09 01:24:03 +01:00
Fixed str being used as bytes in hostwatch
This should solve the TypeError reported in #53 and some others I found while testing the fix. Closes: #53
This commit is contained in:
parent
11838d65c2
commit
1c46f25e13
@ -36,7 +36,7 @@ def write_host_cache():
|
||||
try:
|
||||
f = open(tmpname, 'wb')
|
||||
for name, ip in sorted(hostnames.items()):
|
||||
f.write('%s,%s\n' % (name, ip))
|
||||
f.write(('%s,%s\n' % (name, ip)).encode("ASCII"))
|
||||
f.close()
|
||||
os.chmod(tmpname, 0o600)
|
||||
os.rename(tmpname, CACHEFILE)
|
||||
@ -122,7 +122,7 @@ def _check_netstat():
|
||||
argv = ['netstat', '-n']
|
||||
try:
|
||||
p = ssubprocess.Popen(argv, stdout=ssubprocess.PIPE, stderr=null)
|
||||
content = p.stdout.read()
|
||||
content = p.stdout.read().decode("ASCII")
|
||||
p.wait()
|
||||
except OSError as e:
|
||||
log('%r failed: %r\n' % (argv, e))
|
||||
|
@ -247,20 +247,20 @@ def main(latency_control):
|
||||
mux.send(0, ssnet.CMD_ROUTES, routepkt)
|
||||
|
||||
hw = Hostwatch()
|
||||
hw.leftover = ''
|
||||
hw.leftover = b''
|
||||
|
||||
def hostwatch_ready(sock):
|
||||
assert(hw.pid)
|
||||
content = hw.sock.recv(4096)
|
||||
if content:
|
||||
lines = (hw.leftover + content).split('\n')
|
||||
lines = (hw.leftover + content).split(b'\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))
|
||||
hw.leftover = b''
|
||||
mux.send(0, ssnet.CMD_HOST_LIST, b'\n'.join(lines))
|
||||
else:
|
||||
raise Fatal('hostwatch process died')
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user