Support accessing ZeroNet via a transparent proxy.
This commit is contained in:
parent
efcb1715ee
commit
4ffd642732
3 changed files with 7 additions and 2 deletions
|
@ -204,6 +204,7 @@ class Config(object):
|
|||
self.parser.add_argument('--ui_port', help='Web interface bind port', default=43110, type=int, metavar='port')
|
||||
self.parser.add_argument('--ui_restrict', help='Restrict web access', default=False, metavar='ip', nargs='*')
|
||||
self.parser.add_argument('--ui_host', help='Allow access using this hosts', metavar='host', nargs='*')
|
||||
self.parser.add_argument('--ui_trans_proxy', help='Allow access using a transparent proxy', action='store_true')
|
||||
|
||||
self.parser.add_argument('--open_browser', help='Open homepage in web browser automatically',
|
||||
nargs='?', const="default_browser", metavar='browser_name')
|
||||
|
|
|
@ -74,6 +74,9 @@ class UiRequest(object):
|
|||
if not self.isHostAllowed(self.env.get("HTTP_HOST")):
|
||||
return self.error403("Invalid host: %s" % self.env.get("HTTP_HOST"), details=False)
|
||||
|
||||
# Prepend .bit host for transparent proxy
|
||||
if self.server.site_manager.isDomain(self.env.get("HTTP_HOST")):
|
||||
path = re.sub("^/", "/" + self.env.get("HTTP_HOST") + "/", path)
|
||||
path = re.sub("^http://zero[/]+", "/", path) # Remove begining http://zero/ for chrome extension
|
||||
path = re.sub("^http://", "/", path) # Remove begining http for chrome extension .bit access
|
||||
|
||||
|
@ -141,9 +144,9 @@ class UiRequest(object):
|
|||
else:
|
||||
return self.error404(path)
|
||||
|
||||
# The request is proxied by chrome extension
|
||||
# The request is proxied by chrome extension or a transparent proxy
|
||||
def isProxyRequest(self):
|
||||
return self.env["PATH_INFO"].startswith("http://")
|
||||
return self.env["PATH_INFO"].startswith("http://") or (self.server.allow_trans_proxy and self.server.site_manager.isDomain(self.env.get("HTTP_HOST")))
|
||||
|
||||
def isWebSocketRequest(self):
|
||||
return self.env.get("HTTP_UPGRADE") == "websocket"
|
||||
|
|
|
@ -67,6 +67,7 @@ class UiServer:
|
|||
else:
|
||||
self.allowed_hosts = set([])
|
||||
self.learn_allowed_host = True # It will pin to the first http request's host
|
||||
self.allow_trans_proxy = config.ui_trans_proxy
|
||||
|
||||
self.wrapper_nonces = []
|
||||
self.add_nonces = []
|
||||
|
|
Loading…
Reference in a new issue