diff --git a/sshuttle/hostwatch.py b/sshuttle/hostwatch.py index 66d93ea..95a539a 100644 --- a/sshuttle/hostwatch.py +++ b/sshuttle/hostwatch.py @@ -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)) diff --git a/sshuttle/server.py b/sshuttle/server.py index dc37695..9ecce93 100644 --- a/sshuttle/server.py +++ b/sshuttle/server.py @@ -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')