diff --git a/README.md b/README.md index ef560e69..2f440e88 100644 --- a/README.md +++ b/README.md @@ -1643,8 +1643,6 @@ safety profiles: * `--hardlink` creates hardlinks instead of symlinks when deduplicating uploads, which is less maintenance * however note if you edit one file it will also affect the other copies * `--vague-403` returns a "404 not found" instead of "401 unauthorized" which is a common enterprise meme - * `--ban-404=50,60,1440` ban client for 1440min (24h) if they hit 50 404's in 60min - * `--turbo=-1` to force-disable turbo-mode in the uploader which could otherwise hit the 404-ban * `--nih` removes the server hostname from directory listings * option `-sss` is a shortcut for the above plus: diff --git a/copyparty/__main__.py b/copyparty/__main__.py index 5f00d31a..a3f26af4 100755 --- a/copyparty/__main__.py +++ b/copyparty/__main__.py @@ -998,7 +998,7 @@ def add_optouts(ap): def add_safety(ap): ap2 = ap.add_argument_group('safety options') ap2.add_argument("-s", action="count", default=0, help="increase safety: Disable thumbnails / potentially dangerous software (ffmpeg/pillow/vips), hide partial uploads, avoid crawlers.\n └─Alias of\033[32m --dotpart --no-thumb --no-mtag-ff --no-robots --force-js") - ap2.add_argument("-ss", action="store_true", help="further increase safety: Prevent js-injection, accidental move/delete, broken symlinks, webdav, 404 on 403, ban on excessive 404s.\n └─Alias of\033[32m -s --unpost=0 --no-del --no-mv --hardlink --vague-403 --ban-404=50,60,1440 --turbo=-1 -nih") + ap2.add_argument("-ss", action="store_true", help="further increase safety: Prevent js-injection, accidental move/delete, broken symlinks, webdav, 404 on 403, ban on excessive 404s.\n └─Alias of\033[32m -s --unpost=0 --no-del --no-mv --hardlink --vague-403 -nih") ap2.add_argument("-sss", action="store_true", help="further increase safety: Enable logging to disk, scan for dangerous symlinks.\n └─Alias of\033[32m -ss --no-dav --no-logues --no-readme -lo=cpp-%%Y-%%m%%d-%%H%%M%%S.txt.xz --ls=**,*,ln,p,r") ap2.add_argument("--ls", metavar="U[,V[,F]]", type=u, help="do a sanity/safety check of all volumes on startup; arguments \033[33mUSER\033[0m,\033[33mVOL\033[0m,\033[33mFLAGS\033[0m; example [\033[32m**,*,ln,p,r\033[0m]") ap2.add_argument("--xvol", action="store_true", help="never follow symlinks leaving the volume root, unless the link is into another volume where the user has similar access (volflag=xvol)") @@ -1012,10 +1012,10 @@ def add_safety(ap): ap2.add_argument("--no-robots", action="store_true", help="adds http and html headers asking search engines to not index anything (volflag=norobots)") ap2.add_argument("--logout", metavar="H", type=float, default="8086", help="logout clients after H hours of inactivity; [\033[32m0.0028\033[0m]=10sec, [\033[32m0.1\033[0m]=6min, [\033[32m24\033[0m]=day, [\033[32m168\033[0m]=week, [\033[32m720\033[0m]=month, [\033[32m8760\033[0m]=year)") ap2.add_argument("--ban-pw", metavar="N,W,B", type=u, default="9,60,1440", help="more than \033[33mN\033[0m wrong passwords in \033[33mW\033[0m minutes = ban for \033[33mB\033[0m minutes; disable with [\033[32mno\033[0m]") - ap2.add_argument("--ban-404", metavar="N,W,B", type=u, default="no", help="hitting more than \033[33mN\033[0m 404's in \033[33mW\033[0m minutes = ban for \033[33mB\033[0m minutes (disabled by default since turbo-up2k counts as 404s)") + ap2.add_argument("--ban-404", metavar="N,W,B", type=u, default="50,60,1440", help="hitting more than \033[33mN\033[0m 404's in \033[33mW\033[0m minutes = ban for \033[33mB\033[0m minutes; only affects users who cannot see directory listings because their access is either g/G/h") ap2.add_argument("--ban-403", metavar="N,W,B", type=u, default="9,2,1440", help="hitting more than \033[33mN\033[0m 403's in \033[33mW\033[0m minutes = ban for \033[33mB\033[0m minutes; [\033[32m1440\033[0m]=day, [\033[32m10080\033[0m]=week, [\033[32m43200\033[0m]=month") ap2.add_argument("--ban-422", metavar="N,W,B", type=u, default="9,2,1440", help="hitting more than \033[33mN\033[0m 422's in \033[33mW\033[0m minutes = ban for \033[33mB\033[0m minutes (422 is server fuzzing, invalid POSTs and so)") - ap2.add_argument("--ban-url", metavar="N,W,B", type=u, default="9,2,1440", help="hitting more than \033[33mN\033[0m sus URL's in \033[33mW\033[0m minutes = ban for \033[33mB\033[0m minutes (decent replacement for --ban-404 if that can't be used)") + ap2.add_argument("--ban-url", metavar="N,W,B", type=u, default="9,2,1440", help="hitting more than \033[33mN\033[0m sus URL's in \033[33mW\033[0m minutes = ban for \033[33mB\033[0m minutes; applies only to access g/G/h (decent replacement for --ban-404 if that can't be used)") ap2.add_argument("--sus-urls", metavar="R", type=u, default=r"\.php$|(^|/)wp-(admin|content|includes)/", help="URLs which are considered sus / eligible for banning; disable with blank or [\033[32mno\033[0m]") ap2.add_argument("--nonsus-urls", metavar="R", type=u, default=r"^(favicon\.ico|robots\.txt)$|^apple-touch-icon|^\.well-known", help="harmless URLs ignored from 404-bans; disable with blank or [\033[32mno\033[0m]") ap2.add_argument("--aclose", metavar="MIN", type=int, default=10, help="if a client maxes out the server connection limit, downgrade it from connection:keep-alive to connection:close for MIN minutes (and also kill its active connections) -- disable with 0") diff --git a/copyparty/httpcli.py b/copyparty/httpcli.py index 846b751c..455cb476 100644 --- a/copyparty/httpcli.py +++ b/copyparty/httpcli.py @@ -655,6 +655,7 @@ class HttpCli(object): and not body.startswith(b"
source file busy")
                 )
             )
+            and (status != 404 or (self.can_get and not self.can_read))
         ):
             if status == 404:
                 g = self.conn.hsrv.g404
diff --git a/copyparty/svchub.py b/copyparty/svchub.py
index 77f52041..11c4100c 100644
--- a/copyparty/svchub.py
+++ b/copyparty/svchub.py
@@ -119,8 +119,6 @@ class SvcHub(object):
             args.no_mv = True
             args.hardlink = True
             args.vague_403 = True
-            args.ban_404 = "50,60,1440"
-            args.turbo = -1
             args.nih = True
 
         if args.s:
diff --git a/copyparty/web/browser.js b/copyparty/web/browser.js
index 89a6af7c..d7f31cf7 100644
--- a/copyparty/web/browser.js
+++ b/copyparty/web/browser.js
@@ -451,6 +451,8 @@ var Ls = {
 		"u_expl": "explain",
 		"u_tu": '

WARNING: turbo enabled,  client may not detect and resume incomplete uploads; see turbo-button tooltip

', "u_ts": '

WARNING: turbo enabled,  search results can be incorrect; see turbo-button tooltip

', + "u_turbo_c": "turbo is disabled in server config", + "u_turbo_g": "disabling turbo because you don't have\ndirectory listing privileges within this volume", "u_life_cfg": 'autodelete after min (or hours)', "u_life_est": 'upload will be deleted ---', "u_life_max": 'this folder enforces a\nmax lifetime of {0}', @@ -923,6 +925,8 @@ var Ls = { "u_expl": "forklar", "u_tu": '

ADVARSEL: turbo er på,  avbrutte opplastninger vil muligens ikke oppdages og gjenopptas; hold musepekeren over turbo-knappen for mer info

', "u_ts": '

ADVARSEL: turbo er på,  søkeresultater kan være feil; hold musepekeren over turbo-knappen for mer info

', + "u_turbo_c": "turbo er deaktivert i serverkonfigurasjonen", + "u_turbo_g": 'turbo ble deaktivert fordi du ikke har\ntilgang til å se mappeinnhold i dette volumet', "u_life_cfg": 'slett opplastning etter min (eller timer)', "u_life_est": 'opplastningen slettes ---', "u_life_max": 'denne mappen tillater ikke å \noppbevare filer i mer enn {0}', diff --git a/copyparty/web/up2k.js b/copyparty/web/up2k.js index 11d90226..6f3076de 100644 --- a/copyparty/web/up2k.js +++ b/copyparty/web/up2k.js @@ -1340,6 +1340,7 @@ function up2k_init(subtle) { function up_them(good_files) { start_actx(); + draw_turbo(); var evpath = get_evpath(), draw_each = good_files.length < 50; @@ -2711,7 +2712,12 @@ function up2k_init(subtle) { function draw_turbo() { if (turbolvl < 0 && uc.turbo) { bcfg_set('u2turbo', uc.turbo = false); - toast.err(10, "turbo is disabled in server config"); + toast.err(10, L.u_turbo_c); + } + + if (uc.turbo && !has(perms, 'read')) { + bcfg_set('u2turbo', uc.turbo = false); + toast.warn(30, L.u_turbo_g); } var msg = (turbolvl || !uc.turbo) ? null : uc.fsearch ? L.u_ts : L.u_tu,