Browse Source

Added get_addr to get real client addr

pull/4/head
Sheng 7 years ago
parent
commit
5d0fad48ec
  1. 10
      main.py

10
main.py

@ -206,8 +206,16 @@ class WsockHandler(tornado.websocket.WebSocketHandler):
def check_origin(self, origin):
return True
def get_addr(self):
ip = self.request.headers.get_list('X-Real-Ip')
port = self.request.headers.get_list('X-Real-Port')
addr = ':'.join(ip + port)
if not addr:
addr = '{}:{}'.format(*self.stream.socket.getpeername())
return addr
def open(self):
self.src_addr = '{}:{}'.format(*self.stream.socket.getpeername())
self.src_addr = self.get_addr()
logging.info('Connected from {}'.format(self.src_addr))
worker = workers.pop(self.get_argument('id'), None)
if not worker:

Loading…
Cancel
Save