Skip to content

Commit 1ae4fce

Browse files
committed
Fix logging with pf method and Python 3.5
1 parent 118171a commit 1ae4fce

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

sshuttle/methods/pf.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -158,12 +158,13 @@ def get_tcp_dstip(self, sock):
158158
argv = (sock.family, socket.IPPROTO_TCP,
159159
peer[0].encode("ASCII"), peer[1],
160160
proxy[0].encode("ASCII"), proxy[1])
161-
pfile.write(b"QUERY_PF_NAT %d,%d,%s,%d,%s,%d\n" % argv)
161+
out_line = b"QUERY_PF_NAT %d,%d,%s,%d,%s,%d\n" % argv
162+
pfile.write(out_line)
162163
pfile.flush()
163-
line = pfile.readline()
164-
debug2(b"QUERY_PF_NAT %d,%d,%s,%d,%s,%d" % argv + b' > ' + line)
165-
if line.startswith(b'QUERY_PF_NAT_SUCCESS '):
166-
(ip, port) = line[21:].split(b',')
164+
in_line = pfile.readline()
165+
debug2(out_line.decode("ASCII") + ' > ' + in_line.decode("ASCII"))
166+
if in_line.startswith(b'QUERY_PF_NAT_SUCCESS '):
167+
(ip, port) = in_line[21:].split(b',')
167168
return (ip.decode("ASCII"), int(port))
168169

169170
return sock.getsockname()

sshuttle/tests/test_methods_pf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ def test_get_supported_features():
1212
assert not features.udp
1313

1414

15+
@patch('sshuttle.helpers.verbose', new=3)
1516
def test_get_tcp_dstip():
1617
sock = Mock()
1718
sock.getpeername.return_value = ("127.0.0.1", 1024)

0 commit comments

Comments
 (0)