forked from inaz2/proxy2
- Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathhttps_trasparent.py
More file actions
Latest commit
40 lines (30 loc) · 1.15 KB
/
Copy pathhttps_trasparent.py
File metadata and controls
40 lines (30 loc) · 1.15 KB
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
fromproxy2import*
classThreadingHTTPSServer(ThreadingHTTPServer):
address_family=socket.AF_INET6
daemon_threads=True
cakey='ca.key'
cacert='ca.crt'
defget_request(self):
request, client_address=self.socket.accept()
request=ssl.wrap_socket(request, keyfile=self.cakey, certfile=self.cacert, server_side=True)
returnrequest, client_address
defhandle_error(self, request, client_address):
# surpress socket/ssl related errors
cls, e=sys.exc_info()[:2]
ifclsissocket.errororclsisssl.SSLError:
pass
else:
returnHTTPServer.handle_error(self, request, client_address)
deftest(HandlerClass=ProxyRequestHandler, ServerClass=ThreadingHTTPSServer, protocol="HTTP/1.1"):
ifsys.argv[1:]:
port=int(sys.argv[1])
else:
port=3129
server_address= ('', port)
HandlerClass.protocol_version=protocol
httpd=ServerClass(server_address, HandlerClass)
sa=httpd.socket.getsockname()
print"Serving HTTPS Proxy on", sa[0], "port", sa[1], "..."
httpd.serve_forever()
if__name__=='__main__':
test()