Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import socket
- from threading import Thread
- from time import sleep
- GAME_HOST = '3.93.128.89'
- GAME_PORT = 12021
- CLIENT_HOST = '3.93.128.89'
- CLIENT_PORT = 12022
- class Proxy(Thread):
- def __init__(self, host, port, name, isClient=False):
- super(Proxy, self).__init__()
- self.host = host
- self.port = port
- self.to = None
- self.name = name
- self.work = True
- self.isClient = isClient
- self.incomming = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- if isClient:
- self.incomming.connect((self.host, self.port))
- data = self.incomming.recv(4096)
- print("[from: ", self.name," ]", data)
- def run(self):
- if not self.isClient:
- self.incomming.connect((self.host, self.port))
- while self.work:
- data = self.incomming.recv(4096)
- if data:
- self.to.sendall(data)
- print("[from: ", self.name," ]", data)
- c2p = Proxy(CLIENT_HOST, CLIENT_PORT, "client", isClient=True)
- input("Press enter when ready to create server proxy")
- g2p = Proxy(GAME_HOST, GAME_PORT, "server")
- c2p.to = g2p.incomming
- g2p.to = c2p.incomming
- c2p.daemon = True
- g2p.daemon = True
- c2p.start()
- g2p.start()
- while True:
- sleep(1000)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement