@@ -42,8 +42,7 @@ class ProxyHandler(WebSocketHandlerMixin, IPythonHandler):
4242 def __init__ (self , * args , ** kwargs ):
4343 self .proxy_base = ''
4444 self .absolute_url = kwargs .pop ('absolute_url' , False )
45- self .host_whitelist_hook = kwargs .pop ('host_whitelist_hook' ,
46- lambda handler , host : host in ['localhost' , '127.0.0.1' ])
45+ self .host_whitelist = kwargs .pop ('host_whitelist' , ['localhost' , '127.0.0.1' ])
4746 super ().__init__ (* args , ** kwargs )
4847
4948 # Support all the methods that torando does by default except for GET which
@@ -169,7 +168,10 @@ def _build_proxy_request(self, host, port, proxied_path, body):
169168 return req
170169
171170 def _check_host_whitelist (self , host ):
172- return self .host_whitelist_hook (self , host )
171+ if callable (self .host_whitelist ):
172+ return self .host_whitelist (self , host )
173+ else :
174+ return host in self .host_whitelist
173175
174176 @web .authenticated
175177 async def proxy (self , host , port , proxied_path ):
@@ -520,13 +522,13 @@ def options(self, path):
520522 return self .proxy (self .port , path )
521523
522524
523- def setup_handlers (web_app , host_whitelist_hook ):
525+ def setup_handlers (web_app , host_whitelist ):
524526 host_pattern = '.*$'
525527 web_app .add_handlers ('.*' , [
526528 (url_path_join (web_app .settings ['base_url' ], r'/proxy/(.*):(\d+)(.*)' ),
527- RemoteProxyHandler , {'absolute_url' : False , 'host_whitelist_hook ' : host_whitelist_hook }),
529+ RemoteProxyHandler , {'absolute_url' : False , 'host_whitelist ' : host_whitelist }),
528530 (url_path_join (web_app .settings ['base_url' ], r'/proxy/absolute/(.*):(\d+)(.*)' ),
529- RemoteProxyHandler , {'absolute_url' : True , 'host_whitelist_hook ' : host_whitelist_hook }),
531+ RemoteProxyHandler , {'absolute_url' : True , 'host_whitelist ' : host_whitelist }),
530532 (url_path_join (web_app .settings ['base_url' ], r'/proxy/(\d+)(.*)' ),
531533 LocalProxyHandler , {'absolute_url' : False }),
532534 (url_path_join (web_app .settings ['base_url' ], r'/proxy/absolute/(\d+)(.*)' ),
0 commit comments