diff --git a/websockify/token_plugins.py b/websockify/token_plugins.py index 92494eb..a986e57 100644 --- a/websockify/token_plugins.py +++ b/websockify/token_plugins.py @@ -34,9 +34,9 @@ class ReadOnlyTokenFile(BasePlugin): if self._targets is None: self._load_targets() - if token in self._targets: + try: return self._targets[token] - else: + except KeyError: return None diff --git a/websockify/websocketproxy.py b/websockify/websocketproxy.py index 46ab545..6daa3a2 100755 --- a/websockify/websocketproxy.py +++ b/websockify/websocketproxy.py @@ -108,7 +108,7 @@ Traffic Legend: # in the form of token: host:port # Extract the token parameter from url - args = parse_qs(urlparse(path)[4]) # 4 is the query from url + args = parse_qs(urlparse(path).query) if not 'token' in args or not len(args['token']): raise self.server.EClose("Token not present") @@ -152,9 +152,9 @@ Traffic Legend: ins, outs, excepts = select.select(rlist, wlist, [], 1) except (select.error, OSError): exc = sys.exc_info()[1] - if hasattr(exc, 'errno'): + try: err = exc.errno - else: + except AttributeError: err = exc[0] if err != errno.EINTR: