mirror of
https://github.com/sshuttle/sshuttle.git
synced 2024-11-14 03:54:40 +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()
|
||||
|
||||
argv = (sock.family, socket.IPPROTO_TCP,
|
||||
peer[0], peer[1], proxy[0], proxy[1])
|
||||
pfile.write("QUERY_PF_NAT %d,%d,%s,%d,%s,%d\n" % argv)
|
||||
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)
|
||||
pfile.flush()
|
||||
line = pfile.readline()
|
||||
debug2("QUERY_PF_NAT %d,%d,%s,%d,%s,%d" % argv + ' > ' + line)
|
||||
if line.startswith('QUERY_PF_NAT_SUCCESS '):
|
||||
(ip, port) = line[21:].split(',')
|
||||
return (ip, int(port))
|
||||
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',')
|
||||
return (ip.decode("ASCII"), int(port))
|
||||
|
||||
return sock.getsockname()
|
||||
|
||||
|
@ -20,7 +20,7 @@ def test_get_tcp_dstip():
|
||||
|
||||
firewall = Mock()
|
||||
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.set_firewall(firewall)
|
||||
@ -31,7 +31,7 @@ def test_get_tcp_dstip():
|
||||
call.getsockname(),
|
||||
]
|
||||
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.readline()
|
||||
]
|
||||
|
Loading…
Reference in New Issue
Block a user