SHARE
TWEET

Untitled

a guest Dec 11th, 2019 87 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import socket
  2. from threading import Thread
  3. from time import sleep
  4.  
  5. GAME_HOST = '3.93.128.89'
  6. GAME_PORT = 12021
  7. CLIENT_HOST = '3.93.128.89'
  8. CLIENT_PORT = 12022
  9.  
  10. class Proxy(Thread):
  11.  
  12.     def __init__(self, host, port, name, isClient=False):
  13.         super(Proxy, self).__init__()
  14.         self.host = host
  15.         self.port = port
  16.         self.to = None
  17.         self.name = name
  18.         self.work = True
  19.         self.isClient = isClient
  20.         self.incomming = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  21.         if isClient:
  22.             self.incomming.connect((self.host, self.port))
  23.             data = self.incomming.recv(4096)
  24.             print("[from: ", self.name," ]", data)
  25.  
  26.     def run(self):
  27.         if not self.isClient:
  28.             self.incomming.connect((self.host, self.port))
  29.         while self.work:
  30.             data = self.incomming.recv(4096)
  31.             if data:
  32.                 self.to.sendall(data)
  33.                 print("[from: ", self.name," ]", data)
  34.  
  35. c2p = Proxy(CLIENT_HOST, CLIENT_PORT, "client", isClient=True)
  36. input("Press enter when ready to create server proxy")
  37. g2p = Proxy(GAME_HOST, GAME_PORT, "server")
  38. c2p.to = g2p.incomming
  39. g2p.to = c2p.incomming
  40. c2p.daemon = True
  41. g2p.daemon = True
  42. c2p.start()
  43. g2p.start()
  44. while True:
  45.     sleep(1000)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top