mirror of
https://github.com/sshuttle/sshuttle.git
synced 2024-11-26 18:04:00 +01:00
Fix get_tcp_dstip with MacOSX/Python3.5
This commit is contained in:
parent
3367124e6b
commit
118171af7f
@ -156,14 +156,15 @@ class Method(BaseMethod):
|
|||||||
proxy = sock.getsockname()
|
proxy = sock.getsockname()
|
||||||
|
|
||||||
argv = (sock.family, socket.IPPROTO_TCP,
|
argv = (sock.family, socket.IPPROTO_TCP,
|
||||||
peer[0], peer[1], proxy[0], proxy[1])
|
peer[0].encode("ASCII"), peer[1],
|
||||||
pfile.write("QUERY_PF_NAT %d,%d,%s,%d,%s,%d\n" % argv)
|
proxy[0].encode("ASCII"), proxy[1])
|
||||||
|
pfile.write(b"QUERY_PF_NAT %d,%d,%s,%d,%s,%d\n" % argv)
|
||||||
pfile.flush()
|
pfile.flush()
|
||||||
line = pfile.readline()
|
line = pfile.readline()
|
||||||
debug2("QUERY_PF_NAT %d,%d,%s,%d,%s,%d" % argv + ' > ' + line)
|
debug2(b"QUERY_PF_NAT %d,%d,%s,%d,%s,%d" % argv + b' > ' + line)
|
||||||
if line.startswith('QUERY_PF_NAT_SUCCESS '):
|
if line.startswith(b'QUERY_PF_NAT_SUCCESS '):
|
||||||
(ip, port) = line[21:].split(',')
|
(ip, port) = line[21:].split(b',')
|
||||||
return (ip, int(port))
|
return (ip.decode("ASCII"), int(port))
|
||||||
|
|
||||||
return sock.getsockname()
|
return sock.getsockname()
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ def test_get_tcp_dstip():
|
|||||||
|
|
||||||
firewall = Mock()
|
firewall = Mock()
|
||||||
firewall.pfile.readline.return_value = \
|
firewall.pfile.readline.return_value = \
|
||||||
"QUERY_PF_NAT_SUCCESS 127.0.0.3,1026\n"
|
b"QUERY_PF_NAT_SUCCESS 127.0.0.3,1026\n"
|
||||||
|
|
||||||
method = get_method('pf')
|
method = get_method('pf')
|
||||||
method.set_firewall(firewall)
|
method.set_firewall(firewall)
|
||||||
@ -31,7 +31,7 @@ def test_get_tcp_dstip():
|
|||||||
call.getsockname(),
|
call.getsockname(),
|
||||||
]
|
]
|
||||||
assert firewall.mock_calls == [
|
assert firewall.mock_calls == [
|
||||||
call.pfile.write('QUERY_PF_NAT 2,6,127.0.0.1,1024,127.0.0.2,1025\n'),
|
call.pfile.write(b'QUERY_PF_NAT 2,6,127.0.0.1,1024,127.0.0.2,1025\n'),
|
||||||
call.pfile.flush(),
|
call.pfile.flush(),
|
||||||
call.pfile.readline()
|
call.pfile.readline()
|
||||||
]
|
]
|
||||||
|
Loading…
Reference in New Issue
Block a user