diff --git a/copyparty/httpcli.py b/copyparty/httpcli.py index 7ded17ee..79355774 100644 --- a/copyparty/httpcli.py +++ b/copyparty/httpcli.py @@ -545,6 +545,10 @@ class HttpCli(object): static_path = os.path.join(E.mod, "web/", self.vpath[5:]) return self.tx_file(static_path) + if "cf_challenge" in self.uparam: + self.reply(self.j2s("cf").encode("utf-8", "replace")) + return True + if not self.can_read and not self.can_write and not self.can_get: if self.vpath: self.log("inaccessible: [{}]".format(self.vpath)) @@ -911,6 +915,9 @@ class HttpCli(object): except: raise Pebkac(422, "you POSTed invalid json") + # self.reply(b" DDoS Protection ", 503) + # return True + if "srch" in self.uparam or "srch" in body: return self.handle_search(body) diff --git a/copyparty/httpsrv.py b/copyparty/httpsrv.py index fd449b5f..3f40b5e9 100644 --- a/copyparty/httpsrv.py +++ b/copyparty/httpsrv.py @@ -81,7 +81,7 @@ class HttpSrv(object): env.loader = jinja2.FileSystemLoader(os.path.join(E.mod, "web")) self.j2 = { x: env.get_template(x + ".html") - for x in ["splash", "browser", "browser2", "msg", "md", "mde"] + for x in ["splash", "browser", "browser2", "msg", "md", "mde", "cf"] } self.prism = os.path.exists(os.path.join(E.mod, "web", "deps", "prism.js.gz")) diff --git a/copyparty/util.py b/copyparty/util.py index 844f4add..d7c4a782 100644 --- a/copyparty/util.py +++ b/copyparty/util.py @@ -127,6 +127,7 @@ HTTPCODE = { 429: "Too Many Requests", 500: "Internal Server Error", 501: "Not Implemented", + 503: "Service Unavailable", } diff --git a/copyparty/web/browser.js b/copyparty/web/browser.js index a4513516..9767ed98 100644 --- a/copyparty/web/browser.js +++ b/copyparty/web/browser.js @@ -248,6 +248,7 @@ var Ls = { "md_eshow": "cannot show ", "xhr403": "403: Access denied\n\ntry pressing F5, maybe you got logged out", + "cf_ok": "sorry about that -- DDoS protection kicked in\n\nthings should resume in about 30 sec\n\nif nothing happens, hit F5 to reload the page", "tl_xe1": "could not list subfolders:\n\nerror ", "tl_xe2": "404: Folder not found", "fl_xe1": "could not list files in folder:\n\nerror ", @@ -572,6 +573,7 @@ var Ls = { "md_eshow": "kan ikke vise ", "xhr403": "403: Tilgang nektet\n\nkanskje du ble logget ut? prøv å trykk F5", + "cf_ok": "beklager -- liten tilfeldig kontroll, alt OK\n\nting skal fortsette om ca. 30 sekunder\n\nhvis ikkeno skjer, trykk F5 for å laste siden på nytt", "tl_xe1": "kunne ikke hente undermapper:\n\nfeil ", "tl_xe2": "404: Mappen finnes ikke", "fl_xe1": "kunne ikke hente filer i mappen:\n\nfeil ", diff --git a/copyparty/web/cf.html b/copyparty/web/cf.html new file mode 100644 index 00000000..05c5a7e9 --- /dev/null +++ b/copyparty/web/cf.html @@ -0,0 +1,27 @@ + + + +
+ +sorry for the inconvenience
+