Compare commits
No commits in common. "flake8" and "master" have entirely different histories.
@ -14,7 +14,6 @@ import sys
|
|||||||
listen_port = int(sys.argv[1])
|
listen_port = int(sys.argv[1])
|
||||||
forward_port = int(sys.argv[2])
|
forward_port = int(sys.argv[2])
|
||||||
|
|
||||||
|
|
||||||
class SyncplayRequestHandler(socketserver.BaseRequestHandler):
|
class SyncplayRequestHandler(socketserver.BaseRequestHandler):
|
||||||
def handle(self):
|
def handle(self):
|
||||||
print('Handling connection from:', self.client_address)
|
print('Handling connection from:', self.client_address)
|
||||||
@ -23,7 +22,7 @@ class SyncplayRequestHandler(socketserver.BaseRequestHandler):
|
|||||||
print('Bad connection header from:', self.client_address)
|
print('Bad connection header from:', self.client_address)
|
||||||
try:
|
try:
|
||||||
self.request.close()
|
self.request.close()
|
||||||
except Exception as e:
|
except:
|
||||||
pass
|
pass
|
||||||
return
|
return
|
||||||
print('Opening forwarding connection on behalf of:', self.client_address)
|
print('Opening forwarding connection on behalf of:', self.client_address)
|
||||||
@ -46,21 +45,18 @@ class SyncplayRequestHandler(socketserver.BaseRequestHandler):
|
|||||||
print('Proxying stopped for:', self.client_address)
|
print('Proxying stopped for:', self.client_address)
|
||||||
try:
|
try:
|
||||||
forwarded_conn.close()
|
forwarded_conn.close()
|
||||||
except Exception as e:
|
except:
|
||||||
pass
|
pass
|
||||||
try:
|
try:
|
||||||
self.request.close()
|
self.request.close()
|
||||||
except Exception as e:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class SyncplayServer(socketserver.ThreadingTCPServer):
|
class SyncplayServer(socketserver.ThreadingTCPServer):
|
||||||
address_family = socket.AF_INET6
|
address_family = socket.AF_INET6
|
||||||
|
|
||||||
def server_bind(self):
|
def server_bind(self):
|
||||||
self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
||||||
socketserver.ThreadingTCPServer.server_bind(self)
|
socketserver.ThreadingTCPServer.server_bind(self)
|
||||||
|
|
||||||
|
|
||||||
with SyncplayServer(('', listen_port), SyncplayRequestHandler) as server:
|
with SyncplayServer(('', listen_port), SyncplayRequestHandler) as server:
|
||||||
server.serve_forever()
|
server.serve_forever()
|
||||||
|
Loading…
Reference in New Issue
Block a user