From 9d0e57e89b5cb92bae5de040a3d96125ac415237 Mon Sep 17 00:00:00 2001 From: emeric Date: Tue, 25 Jul 2023 21:02:42 +0200 Subject: [PATCH 1/4] Made enter key pressed unlock password forms. fixes #89 --- src/fileshelter/ui/ShareCreatePassword.cpp | 31 +++++++++++--------- src/fileshelter/ui/ShareDownloadPassword.cpp | 29 ++++++++++-------- 2 files changed, 33 insertions(+), 27 deletions(-) diff --git a/src/fileshelter/ui/ShareCreatePassword.cpp b/src/fileshelter/ui/ShareCreatePassword.cpp index a215431..3a8a457 100644 --- a/src/fileshelter/ui/ShareCreatePassword.cpp +++ b/src/fileshelter/ui/ShareCreatePassword.cpp @@ -69,20 +69,9 @@ namespace UserInterface ShareCreatePassword::ShareCreatePassword() { - auto model = std::make_shared(); + auto model {std::make_shared()}; - setTemplateText(tr("template-share-create-password")); - addFunction("id", &WTemplate::Functions::id); - addFunction("block", &WTemplate::Functions::block); - - // Password - auto password = std::make_unique(); - password->setEchoMode(Wt::EchoMode::Password); - setFormWidget(ShareCreatePasswordFormModel::PasswordField, std::move(password)); - - // Buttons - Wt::WPushButton* unlockBtn {bindNew("unlock-btn", tr("msg-unlock"))}; - unlockBtn->clicked().connect([=] + auto validateForm {[this, model] { updateModel(model.get()); @@ -100,7 +89,21 @@ namespace UserInterface std::this_thread::sleep_for(std::chrono::seconds {1}); updateView(model.get()); - }); + }}; + + setTemplateText(tr("template-share-create-password")); + addFunction("id", &WTemplate::Functions::id); + addFunction("block", &WTemplate::Functions::block); + + // Password + auto password = std::make_unique(); + password->setEchoMode(Wt::EchoMode::Password); + password->enterPressed().connect([=]{ validateForm(); }); + setFormWidget(ShareCreatePasswordFormModel::PasswordField, std::move(password)); + + // Buttons + Wt::WPushButton* unlockBtn {bindNew("unlock-btn", tr("msg-unlock"))}; + unlockBtn->clicked().connect([=] { validateForm(); }); updateView(model.get()); } diff --git a/src/fileshelter/ui/ShareDownloadPassword.cpp b/src/fileshelter/ui/ShareDownloadPassword.cpp index 93aa3b7..a340737 100644 --- a/src/fileshelter/ui/ShareDownloadPassword.cpp +++ b/src/fileshelter/ui/ShareDownloadPassword.cpp @@ -91,18 +91,7 @@ namespace UserInterface { auto model {std::make_shared(shareUUID)}; - setTemplateText(tr("template-share-download-password")); - addFunction("id", &WTemplate::Functions::id); - addFunction("block", &WTemplate::Functions::block); - - // Password - auto password = std::make_unique(); - password->setEchoMode(Wt::EchoMode::Password); - setFormWidget(ShareDownloadPasswordFormModel::PasswordField, std::move(password)); - - // Buttons - Wt::WPushButton *unlockBtn = bindNew("unlock-btn", tr("msg-unlock")); - unlockBtn->clicked().connect([=] + auto validateForm {[this, model] { updateModel(model.get()); @@ -117,7 +106,21 @@ namespace UserInterface FS_LOG(UI, DEBUG) << "Download password validation failed"; updateView(model.get()); - }); + }}; + + setTemplateText(tr("template-share-download-password")); + addFunction("id", &WTemplate::Functions::id); + addFunction("block", &WTemplate::Functions::block); + + // Password + auto password = std::make_unique(); + password->setEchoMode(Wt::EchoMode::Password); + password->enterPressed().connect([=]{ validateForm(); }); + setFormWidget(ShareDownloadPasswordFormModel::PasswordField, std::move(password)); + + // Buttons + Wt::WPushButton *unlockBtn = bindNew("unlock-btn", tr("msg-unlock")); + unlockBtn->clicked().connect([=] { validateForm(); }); updateView(model.get()); } From ee562be04bafbfc47f6e3417befc98e23e22adc3 Mon Sep 17 00:00:00 2001 From: emeric Date: Tue, 25 Jul 2023 22:30:41 +0200 Subject: [PATCH 2/4] Fixed fallback config file ports to be the same as in the docs --- src/fileshelter/main/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/fileshelter/main/main.cpp b/src/fileshelter/main/main.cpp index 2fb5e50..b4dead2 100644 --- a/src/fileshelter/main/main.cpp +++ b/src/fileshelter/main/main.cpp @@ -57,7 +57,7 @@ std::vector generateWtConfig(std::string execPath) if (Service::get()->getBool("tls-enable", false)) { - args.push_back("--https-port=" + std::to_string( Service::get()->getULong("listen-port", 5081))); + args.push_back("--https-port=" + std::to_string( Service::get()->getULong("listen-port", 5091))); args.push_back("--https-address=" + std::string {Service::get()->getString("listen-addr", "0.0.0.0")}); args.push_back("--ssl-certificate=" + std::string {Service::get()->getString("tls-cert")}); args.push_back("--ssl-private-key=" + std::string {Service::get()->getString("tls-key")}); @@ -65,7 +65,7 @@ std::vector generateWtConfig(std::string execPath) } else { - args.push_back("--http-port=" + std::to_string( Service::get()->getULong("listen-port", 5081))); + args.push_back("--http-port=" + std::to_string( Service::get()->getULong("listen-port", 5091))); args.push_back("--http-address=" + std::string {Service::get()->getString("listen-addr", "0.0.0.0")}); } From ba4b2ea9a73aafd6452154f4085b1720aaa10c67 Mon Sep 17 00:00:00 2001 From: emeric Date: Tue, 25 Jul 2023 22:52:31 +0200 Subject: [PATCH 3/4] Updated install. fixes #88 --- INSTALL.md | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index a47882a..531dea4 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -23,17 +23,17 @@ To install or upgrade _fileshelter_: apt update apt install fileshelter ``` -The _fileshelter_ service is started just after the package installation, run by a dedicated _fileshelter_ system user.
+The _fileshelter_ service is started just after the package installation, run by a dedicated `fileshelter` system user.
Please refer to [Deployment](#deployment) for further configuration options. ## From source __Note__: this installation process and the default values of the configuration files have been written for _Debian Bookworm_. Therefore, you may have to adapt commands and/or paths in order to fit to your distribution. ### Debian/Ubuntu dependencies __Note__: a C++17 compiler is needed to compile _fileshelter_ ```sh -apt-get install build-essential cmake libboost-dev libconfig++-dev +apt-get install build-essential cmake libboost-dev libconfig++-dev libarchive-dev ``` -You also need _Wt4_, that is not packaged yet on _Debian_. See [installation instructions](https://www.webtoolkit.eu/wt/doc/reference/html/InstallationUnix.html). +You also need _Wt4_, that is not packaged on _Debian_. See [installation instructions](https://www.webtoolkit.eu/wt/doc/reference/html/InstallationUnix.html). ### Build ```sh @@ -71,7 +71,7 @@ cp /usr/share/fileshelter/fileshelter.conf /etc/fileshelter.conf cp /usr/share/fileshelter/fileshelter.service /lib/systemd/system/fileshelter.service ``` -Create the working directory and give it access to the _fileshelter_ user: +Create the working directory and give it access to the `fileshelter` user: ```sh mkdir /var/fileshelter chown -R fileshelter:fileshelter /var/fileshelter @@ -103,13 +103,15 @@ systemctl restart fileshelter ## Configuration _Fileshelter_ uses a configuration file, installed by default in `/etc/fileshelter.conf`. It is recommended to edit this file and change relevant settings (listen address, listen port, working directory, ...). -A basic _Terms of Services_ is provided. The configuration file contains the definition of the fields needed by the default tos. -You may also specify an alternate tos file to fit your needs. +A basic _Terms of Services_ is provided. The configuration file contains the definition of the fields needed by the default ToS. +You may also specify an alternate ToS file to fit your needs. If a setting is not present in the configuration file, a hardcoded default value is used (the same as in the [default.conf](conf/fileshelter.conf) file) ## Reverse proxy settings -_Fileshelter_ is shipped with an embedded web server, but it is recommended to deploy behind a reverse proxy. You have to set the _behind-reverse-proxy_ option to _true_ in the `fileshelter.conf` configuration file. +_Fileshelter_ is shipped with an embedded web server, but it is recommended to deploy behind a reverse proxy. +You have to set the `behind-reverse-proxy` option to `true` in the `fileshelter.conf` configuration file and to adjust the trusted proxy list in `trusted-proxies`. +__Note__: when running in a docker environment, you have to trust the docker gateway IP (which is `172.17.0.1` by default) Here is an example to make _Fileshelter_ properly work on _myserver.org_ using _nginx_: ``` @@ -143,7 +145,7 @@ server { systemctl start fileshelter ``` -Log traces can be accessed using journactl: +Logs can be accessed using `journalctl`: ```sh journalctl -u fileshelter.service ``` From a5a88ab7d8a952aa84f17ce12872659be2443f9d Mon Sep 17 00:00:00 2001 From: emeric Date: Tue, 25 Jul 2023 22:57:40 +0200 Subject: [PATCH 4/4] Fixed some typos --- INSTALL.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index 531dea4..a30a738 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -18,17 +18,17 @@ As root, trust the following debian package provider and add it in your list of wget https://debian.poupon.dev/apt/debian/epoupon.gpg -P /usr/share/keyrings echo "deb [signed-by=/usr/share/keyrings/epoupon.gpg] https://debian.poupon.dev/apt/debian bookworm main" > /etc/apt/sources.list.d/epoupon.list ``` -To install or upgrade _fileshelter_: +To install or upgrade _Fileshelter_: ```sh apt update apt install fileshelter ``` -The _fileshelter_ service is started just after the package installation, run by a dedicated `fileshelter` system user.
+The `fileshelter` service is started just after the package installation, run by a dedicated `fileshelter` system user.
Please refer to [Deployment](#deployment) for further configuration options. ## From source __Note__: this installation process and the default values of the configuration files have been written for _Debian Bookworm_. Therefore, you may have to adapt commands and/or paths in order to fit to your distribution. ### Debian/Ubuntu dependencies -__Note__: a C++17 compiler is needed to compile _fileshelter_ +__Note__: a C++17 compiler is needed to compile _Fileshelter_ ```sh apt-get install build-essential cmake libboost-dev libconfig++-dev libarchive-dev ``` @@ -103,7 +103,7 @@ systemctl restart fileshelter ## Configuration _Fileshelter_ uses a configuration file, installed by default in `/etc/fileshelter.conf`. It is recommended to edit this file and change relevant settings (listen address, listen port, working directory, ...). -A basic _Terms of Services_ is provided. The configuration file contains the definition of the fields needed by the default ToS. +A basic _Terms of Service_ is provided. The configuration file contains the definition of the fields needed by the default ToS. You may also specify an alternate ToS file to fit your needs. If a setting is not present in the configuration file, a hardcoded default value is used (the same as in the [default.conf](conf/fileshelter.conf) file) @@ -111,6 +111,7 @@ If a setting is not present in the configuration file, a hardcoded default value ## Reverse proxy settings _Fileshelter_ is shipped with an embedded web server, but it is recommended to deploy behind a reverse proxy. You have to set the `behind-reverse-proxy` option to `true` in the `fileshelter.conf` configuration file and to adjust the trusted proxy list in `trusted-proxies`. + __Note__: when running in a docker environment, you have to trust the docker gateway IP (which is `172.17.0.1` by default) Here is an example to make _Fileshelter_ properly work on _myserver.org_ using _nginx_: