-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsteamproxy.py
53 lines (39 loc) · 1.34 KB
/
steamproxy.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/python
import sys
import port_forward
import threading
if sys.version_info >= (3, 0):
from http.server import SimpleHTTPRequestHandler
from http.server import HTTPServer
else:
from SimpleHTTPServer import SimpleHTTPRequestHandler
from SocketServer import TCPServer as HTTPServer
# forward all https tcp packages
class https_proxy(object):
def __init__(self, target_host='104.122.255.229', source_port=443, target_port=443):
self.__source_port = source_port
self.__target_host = target_host
self.__target_port = target_port
def run(self):
t = threading.Thread(target=port_forward.server, args=(
[self.__source_port, self.__target_host, self.__target_port]))
t.start()
return t
class http_handler(SimpleHTTPRequestHandler):
def do_GET(self):
self.send_response(301)
self.send_header('Location', 'https://steamcommunity.com' + self.path)
self.end_headers()
class http_proxy(object):
def __init__(self, port=80):
self.__port = port
def run(self):
httpd = HTTPServer(("", self.__port), http_handler)
t = threading.Thread(target=httpd.serve_forever)
t.start()
return t
if __name__ == '__main__':
httpd = http_proxy()
httpsd = https_proxy()
t1 = httpd.run()
t2 = httpsd.run()