From 93d94b84310c8fc91c9b6a5d6daf60cca847453e Mon Sep 17 00:00:00 2001
From: blek
Date: Sat, 21 Oct 2023 13:52:03 +1000
Subject: [PATCH] add ui banner wall when file uploads are disabled
---
filed/config/filed.toml.example | 4 ++++
filed/src/config/types.rs | 6 ++++++
filed/templates/index.html | 15 +++++++++++++--
3 files changed, 23 insertions(+), 2 deletions(-)
diff --git a/filed/config/filed.toml.example b/filed/config/filed.toml.example
index b7658fc..71a7682 100644
--- a/filed/config/filed.toml.example
+++ b/filed/config/filed.toml.example
@@ -17,6 +17,10 @@ allow_custom_names=true
# Allow password protection
allow_pass_protection=true
+# Reson why the uploads are disabled
+# This is shown only if allow_uploads = false
+# upload_disable_reason="File uploads were disabled because of an ongoing attack."
+
# How much files can one
# user have uploaded to the server.
# Note that it does not include expired files
diff --git a/filed/src/config/types.rs b/filed/src/config/types.rs
index 6f60a1a..9f4965a 100644
--- a/filed/src/config/types.rs
+++ b/filed/src/config/types.rs
@@ -17,6 +17,11 @@ pub struct FilesPolicy {
#[serde(default)]
pub allow_pass_protection: bool,
+ /// Reson why the uploads are disabled
+ /// This is shown only if allow_uploads = false
+ #[serde(default)]
+ pub upload_disable_reason: Option,
+
/// Max uploads for IP (doesn't include deleted uploads)
#[serde(default)]
pub max_per_ip: usize,
@@ -40,6 +45,7 @@ impl Default for FilesPolicy {
allow_uploads: true,
allow_custom_names: true,
allow_pass_protection: true,
+ upload_disable_reason: None,
max_per_ip: 8,
file_del_timeout: 1800,
type_whitelist: None,
diff --git a/filed/templates/index.html b/filed/templates/index.html
index 04f7fcc..7c35005 100644
--- a/filed/templates/index.html
+++ b/filed/templates/index.html
@@ -85,12 +85,23 @@
{%- if ! conf.files.allow_uploads -%}
-
+
Error
- Uploads are temporarily disabled by the administrator.
+ Uploads are temporarily disabled by the administrator
+ {%- if let Some(disable_reason) = conf.files.upload_disable_reason -%}
+ {{- " " -}} because of the following reason:
+
+ {{- disable_reason -}}
+
+ {%- else -%}
+ .
+ {%- endif -%}
+
+ Check again in a few minutes.
+
{%- else -%}