Fix logging with pf method and Python 3.5

This commit is contained in:
Brian May 2015-12-07 13:16:47 +11:00
parent 118171af7f
commit 1ae4fce6b3
2 changed files with 7 additions and 5 deletions

View File

@ -158,12 +158,13 @@ class Method(BaseMethod):
argv = (sock.family, socket.IPPROTO_TCP,
peer[0].encode("ASCII"), peer[1],
proxy[0].encode("ASCII"), proxy[1])
pfile.write(b"QUERY_PF_NAT %d,%d,%s,%d,%s,%d\n" % argv)
out_line = b"QUERY_PF_NAT %d,%d,%s,%d,%s,%d\n" % argv
pfile.write(out_line)
pfile.flush()
line = pfile.readline()
debug2(b"QUERY_PF_NAT %d,%d,%s,%d,%s,%d" % argv + b' > ' + line)
if line.startswith(b'QUERY_PF_NAT_SUCCESS '):
(ip, port) = line[21:].split(b',')
in_line = pfile.readline()
debug2(out_line.decode("ASCII") + ' > ' + in_line.decode("ASCII"))
if in_line.startswith(b'QUERY_PF_NAT_SUCCESS '):
(ip, port) = in_line[21:].split(b',')
return (ip.decode("ASCII"), int(port))
return sock.getsockname()

View File

@ -12,6 +12,7 @@ def test_get_supported_features():
assert not features.udp
@patch('sshuttle.helpers.verbose', new=3)
def test_get_tcp_dstip():
sock = Mock()
sock.getpeername.return_value = ("127.0.0.1", 1024)