mitmproxy/libmproxy/platform/linux.py
Maximilian Hils 858b0af0bb fix #270
2014-08-10 16:10:49 +02:00

13 lines
388 B
Python

import socket, struct
# Python socket module does not have this constant
SO_ORIGINAL_DST = 80
class Resolver(object):
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