webssh

Web based ssh client https://github.com/huashengdun/webssh webssh.huashengdun.org/
git clone http://git.hanabi.in/repos/webssh.git
Log | Files | Refs | README | LICENSE

commit e55e7e6898f4ec6d634d541a68e59dbd365b965a
parent ce3c70c41978e71ca3d70d06bd76bf71d6b64eab
Author: Sheng <webmaster0115@gmail.com>
Date:   Wed, 11 Apr 2018 21:06:03 +0800

Rewrote get_real_client_addr

Diffstat:
Mhandler.py | 16++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/handler.py b/handler.py @@ -24,14 +24,18 @@ class MixinHandler(object): def get_real_client_addr(self): ip = self.request.headers.get('X-Real-Ip') port = self.request.headers.get('X-Real-Port') - addr = None - if ip and port: - addr = (ip, int(port)) - elif ip or port: - logging.warn('Wrong nginx configuration.') + if ip is None and port is None: + return - return addr + try: + port = int(port) + except (TypeError, ValueError): + pass + else: + if ip: # does not validate ip and port here + return (ip, port) + logging.warn('Bad nginx configuration.') class IndexHandler(MixinHandler, tornado.web.RequestHandler):