diff options
author | vieira <vieira@yubo.be> | 2016-01-05 22:32:20 +0000 |
---|---|---|
committer | Brian May <brian@linuxpenguins.xyz> | 2016-01-07 14:16:03 +1100 |
commit | 1c46f25e1349e0f4cbacbd97d478fab73ac03b07 (patch) | |
tree | ebd7bc0052916ffcda871006588eac3a53461a95 | |
parent | 11838d65c2e5b48827bef560c793f6667a7d6b22 (diff) |
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
-rw-r--r-- | sshuttle/hostwatch.py | 4 | ||||
-rw-r--r-- | sshuttle/server.py | 8 |
2 files changed, 6 insertions, 6 deletions
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') |