From e6cdbefb3b741e0123ef76273566a5aaadc706b8 Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Tue, 26 Jun 2012 20:49:34 +1200 Subject: Add transparent mode platform module for Linux. --- libmproxy/platform/linux.py | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 libmproxy/platform/linux.py (limited to 'libmproxy/platform/linux.py') diff --git a/libmproxy/platform/linux.py b/libmproxy/platform/linux.py new file mode 100644 index 00000000..d37f0fe8 --- /dev/null +++ b/libmproxy/platform/linux.py @@ -0,0 +1,11 @@ +import socket, struct + +# Python socket module does not have this constant +SO_ORIGINAL_DST = 80 + +class Resolver: + def original_addr(self, csock): + odestdata = csock.getsockopt(socket.SOL_IP, SO_ORIGINAL_DST, 16) + _, port, a1, a2, a3, a4 = struct.unpack("!HHBBBBxxxxxxxx", odestdata) + address = "%d.%d.%d.%d" % (a1, a2, a3, a4) + return address, port -- cgit v1.2.3