Answer the question
In order to leave comments, you need to log in
How to pass real ip of connected client to python proxy?
Good day. I'm new to python, I recently got to sockets, it became necessary to write a proxy application that would proxy any traffic.
So, there is a proxy application that listens on a specific port, it must transmit information (traffic) to a given target, to its IP and port.
A small piece of server code:
HOST, PORT = "", 9091
server = ThreadedTCPServer((HOST, PORT), ThreadedTCPRequestHandler)
SocketServer.ThreadingTCPServer.allow_reuse_address = True
ip, port = server.server_address
server_thread = threading.Thread(target=server.serve_forever)
server_thread.daemon = True
server_thread.start()
class Forwarder(threading.Thread):
def __init__(self, source):
threading.Thread.__init__(self)
self.source = source
self.dest = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.dest.connect (("target ip", 20000))
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question