From 7fd1d6a4e848fa1f0da4709e16585c956098b84f Mon Sep 17 00:00:00 2001
From: ed
Date: Sun, 11 Dec 2022 21:09:50 +0000
Subject: [PATCH] rename --webroot to --rp-loc and fix related bugs
---
copyparty/__main__.py | 9 ++++++---
copyparty/httpcli.py | 9 +++++----
copyparty/svchub.py | 4 ++--
copyparty/web/browser.js | 3 ++-
copyparty/web/splash.js | 4 ++--
copyparty/web/util.js | 2 +-
6 files changed, 18 insertions(+), 13 deletions(-)
diff --git a/copyparty/__main__.py b/copyparty/__main__.py
index 479d569d..5c60d610 100755
--- a/copyparty/__main__.py
+++ b/copyparty/__main__.py
@@ -673,7 +673,7 @@ def run_argparse(
ap2.add_argument("-p", metavar="PORT", type=u, default="3923", help="ports to bind (comma/range)")
ap2.add_argument("--ll", action="store_true", help="include link-local IPv4/IPv6 even if the NIC has routable IPs (breaks some mdns clients)")
ap2.add_argument("--rproxy", metavar="DEPTH", type=int, default=1, help="which ip to keep; [\033[32m0\033[0m]=tcp, [\033[32m1\033[0m]=origin (first x-fwd), [\033[32m2\033[0m]=cloudflare, [\033[32m3\033[0m]=nginx, [\033[32m-1\033[0m]=closest proxy")
- ap2.add_argument("--webroot", metavar="PATH", type=u, default="", help="if reverse-proxying on a location instead of a dedicated subdomain, provide the location here")
+ ap2.add_argument("--rp-loc", metavar="PATH", type=u, default="", help="if reverse-proxying on a location instead of a dedicated domain/subdomain, provide the base location here (eg. /foo/bar)")
if ANYWIN:
ap2.add_argument("--reuseaddr", action="store_true", help="set reuseaddr on listening sockets on windows; allows rapid restart of copyparty at the expense of being able to accidentally start multiple instances")
ap2.add_argument("--s-wr-sz", metavar="B", type=int, default=256*1024, help="socket write size in bytes")
@@ -1008,8 +1008,11 @@ def main(argv: Optional[list[str]] = None) -> None:
retry = True
lprint("\n[ {} ]:\n{}\n".format(fmtr, min_ex()))
- assert al # type: ignore
- al.E = E # __init__ is not shared when oxidized
+ try:
+ assert al # type: ignore
+ al.E = E # __init__ is not shared when oxidized
+ except:
+ sys.exit(1)
if WINDOWS and not al.keep_qem:
try:
diff --git a/copyparty/httpcli.py b/copyparty/httpcli.py
index 0190aec3..e64466a8 100644
--- a/copyparty/httpcli.py
+++ b/copyparty/httpcli.py
@@ -327,7 +327,7 @@ class HttpCli(object):
if vpath.startswith(self.args.R):
vpath = vpath[len(self.args.R) + 1 :]
else:
- t = "incorrect --webroot or webserver config; expected vpath starting with [{}] but got [{}]"
+ t = "incorrect --rp-loc or webserver config; expected vpath starting with [{}] but got [{}]"
self.log(t.format(self.args.R, vpath), 1)
self.ouparam = {k: zs for k, zs in uparam.items()}
@@ -2719,13 +2719,14 @@ class HttpCli(object):
def tx_404(self, is_403: bool = False) -> bool:
rc = 404
if self.args.vague_403:
- t = '404 not found ┐( ´ -`)┌
or maybe you don\'t have access -- try logging in or go home
' + t = 'or maybe you don\'t have access -- try logging in or go home
' elif is_403: - t = 'you\'ll have to log in or go home
' + t = 'you\'ll have to log in or go home
' rc = 403 else: - t = '