mirror of
https://github.com/sshuttle/sshuttle.git
synced 2024-11-08 17:14:43 +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:
|
try:
|
||||||
f = open(tmpname, 'wb')
|
f = open(tmpname, 'wb')
|
||||||
for name, ip in sorted(hostnames.items()):
|
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()
|
f.close()
|
||||||
os.chmod(tmpname, 0o600)
|
os.chmod(tmpname, 0o600)
|
||||||
os.rename(tmpname, CACHEFILE)
|
os.rename(tmpname, CACHEFILE)
|
||||||
@ -122,7 +122,7 @@ def _check_netstat():
|
|||||||
argv = ['netstat', '-n']
|
argv = ['netstat', '-n']
|
||||||
try:
|
try:
|
||||||
p = ssubprocess.Popen(argv, stdout=ssubprocess.PIPE, stderr=null)
|
p = ssubprocess.Popen(argv, stdout=ssubprocess.PIPE, stderr=null)
|
||||||
content = p.stdout.read()
|
content = p.stdout.read().decode("ASCII")
|
||||||
p.wait()
|
p.wait()
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
log('%r failed: %r\n' % (argv, e))
|
log('%r failed: %r\n' % (argv, e))
|
||||||
|
@ -247,20 +247,20 @@ def main(latency_control):
|
|||||||
mux.send(0, ssnet.CMD_ROUTES, routepkt)
|
mux.send(0, ssnet.CMD_ROUTES, routepkt)
|
||||||
|
|
||||||
hw = Hostwatch()
|
hw = Hostwatch()
|
||||||
hw.leftover = ''
|
hw.leftover = b''
|
||||||
|
|
||||||
def hostwatch_ready(sock):
|
def hostwatch_ready(sock):
|
||||||
assert(hw.pid)
|
assert(hw.pid)
|
||||||
content = hw.sock.recv(4096)
|
content = hw.sock.recv(4096)
|
||||||
if content:
|
if content:
|
||||||
lines = (hw.leftover + content).split('\n')
|
lines = (hw.leftover + content).split(b'\n')
|
||||||
if lines[-1]:
|
if lines[-1]:
|
||||||
# no terminating newline: entry isn't complete yet!
|
# no terminating newline: entry isn't complete yet!
|
||||||
hw.leftover = lines.pop()
|
hw.leftover = lines.pop()
|
||||||
lines.append('')
|
lines.append('')
|
||||||
else:
|
else:
|
||||||
hw.leftover = ''
|
hw.leftover = b''
|
||||||
mux.send(0, ssnet.CMD_HOST_LIST, '\n'.join(lines))
|
mux.send(0, ssnet.CMD_HOST_LIST, b'\n'.join(lines))
|
||||||
else:
|
else:
|
||||||
raise Fatal('hostwatch process died')
|
raise Fatal('hostwatch process died')
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user