From 585458986f16275ba1ec75575d9822b87513f6a6 Mon Sep 17 00:00:00 2001 From: Ana Custura Date: Tue, 31 Mar 2026 11:07:30 +0100 Subject: [PATCH 1/2] Ensure wifi password field accepts 8 characters --- app/forms.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/forms.py b/app/forms.py index ebb878e..1de53bb 100644 --- a/app/forms.py +++ b/app/forms.py @@ -15,7 +15,7 @@ def hostname_check(form, field): def wifi_length_check(form, field): if len(field.data) > 63: raise ValidationError(_l('Wifi password cannot be longer than 63 characters.')) - if len(field.data) in range(1,9): + if len(field.data) in range(1,8): raise ValidationError(_l('Wifi password cannot be shorter than 8 characters.')) class LoginForm(FlaskForm): From eeb387d6946258131cebddac144523c539dccbce Mon Sep 17 00:00:00 2001 From: Ana Custura Date: Tue, 31 Mar 2026 12:46:38 +0100 Subject: [PATCH 2/2] Add deltachat credentials page with QR code, update translation strings --- app/routes.py | 22 ++++--- app/templates/deltachat_creds.html | 24 +++++++ app/templates/messaging.html | 4 +- install_madmail.py | 6 +- messages.pot | 67 +++++++++++++------- translations/ru/LC_MESSAGES/messages.po | 83 ++++++++++++++++++------- 6 files changed, 147 insertions(+), 59 deletions(-) create mode 100644 app/templates/deltachat_creds.html diff --git a/app/routes.py b/app/routes.py index 097d603..f7cdf9f 100644 --- a/app/routes.py +++ b/app/routes.py @@ -1,3 +1,6 @@ +import io +import re + from app import app from flask import render_template, flash, redirect, url_for, send_file from app.forms import LoginForm, SettingsForm, Step1Form, Step2Form, Step3Form, Step4Form @@ -25,7 +28,10 @@ RASPAP_INSTALLED = os.path.exists("/var/www/html/raspap") def gen_username() -> str: words = top_n_list("en", 5000) prefix = random.randint(1000, 9999) - return f"{random.choice(words)}{random.choice(words)}{prefix}" + word1 = re.sub(r'[^a-zA-Z ]', '', random.choice(words)) + word2 = re.sub(r'[^a-zA-Z ]', '', random.choice(words)) + print(word1, word2) + return f"{word1}{word2}{prefix}" def gen_password() -> str: characters = string.ascii_letters + string.digits @@ -346,15 +352,17 @@ def messaging(): return render_template('messaging.html', get_setting=get_setting) @app.route("/deltachat_credentials", methods=["POST"]) -def generate_random_deltachat_credentials(): +def deltachat_credentials(): ip = app.config['BUTTERBOX_DEFAULT_IP'] username = gen_username() password = gen_password() - - flash(f"Username: {username}") - flash(f"Password: {password}") - flash(f"IP: {ip}") - return redirect(url_for("messaging")) + hostname = f"{get_setting('butterbox_hostname')}.local" + dclink = f"dclogin:{username}@{hostname}/?p={password}&v=1&ih={ip}&ip=143&sh={ip}&sp=25&is=plain&ss=plain&sc=3" + img = qrcode.make(dclink) + file_object = io.BytesIO() + img.save(file_object, 'PNG') + base64img = "data:image/png;base64," + base64.b64encode(file_object.getvalue()).decode('ascii') + return render_template('deltachat_creds.html',dclink=dclink, base64img=base64img, get_setting=get_setting) @app.route('/share') def share(): diff --git a/app/templates/deltachat_creds.html b/app/templates/deltachat_creds.html new file mode 100644 index 0000000..afa9f25 --- /dev/null +++ b/app/templates/deltachat_creds.html @@ -0,0 +1,24 @@ +{% extends "base.html" %} + +{% block content %} +

{{ _('Secure Messenger Account') }}

+ + +
+
+

{{ _('Scan the following QR code with a device where DeltaChat is installed:') }}

+
+ +
+
+

{{ _('If your device does not have a camera, select "Create new profile" in DeltaChat, choose "Use Other Server" and find "Paste from clipboard", to paste the following link') }}:

+
{{ dclink}}
+
+ +
+
+ +
+{% endblock %} \ No newline at end of file diff --git a/app/templates/messaging.html b/app/templates/messaging.html index 9ce1233..c5f5e9f 100644 --- a/app/templates/messaging.html +++ b/app/templates/messaging.html @@ -4,14 +4,14 @@

{{ _('Secure Messenger') }}

-

{{ _("To use secure messaging, install Delta Chat and then return to this page to create your local offline account.")}}

+

{{ _("To use secure messaging, install Delta Chat and then create your local offline account.")}}

-
+ diff --git a/install_madmail.py b/install_madmail.py index d5c8e14..cf4dd0b 100644 --- a/install_madmail.py +++ b/install_madmail.py @@ -1,5 +1,7 @@ import pexpect import json +from app import app + def run_madmail_installer(): with open("./settings.txt", "r") as f: settings = json.load(f) @@ -15,7 +17,7 @@ def run_madmail_installer(): child.expect("MX record") child.sendline(f"{butterbox_hostname}.locaL") child.expect("Public IP address") - child.sendline("127.0.0.1") + child.sendline(app.config['BUTTERBOX_DEFAULT_IP']) child.expect("Additional domains") child.sendline("") child.expect("State directory") @@ -55,7 +57,7 @@ def run_madmail_installer(): child.expect("Require PGP encryption for outgoing messages") child.sendline("y") child.expect("Allow secure join requests without encryption") - child.sendline("n") + child.sendline("y") child.expect("Passthrough senders") child.sendline("") child.expect("Passthrough recipients") diff --git a/messages.pot b/messages.pot index 8d9cf7b..2ed9f78 100644 --- a/messages.pot +++ b/messages.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PROJECT VERSION\n" "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" -"POT-Creation-Date: 2026-03-29 17:11+0100\n" +"POT-Creation-Date: 2026-03-31 12:45+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -22,7 +22,7 @@ msgid "Please log in to access this page." msgstr "" #: app/forms.py:13 -msgid "Only dashes, underscores, letters and numbers allowed" +msgid "Only dashes, underscores, letters and numbers allowed." msgstr "" #: app/forms.py:17 @@ -141,49 +141,45 @@ msgstr "" msgid "Submit" msgstr "" -#: app/routes.py:95 -msgid "Share WiFi" -msgstr "" - -#: app/routes.py:97 app/templates/messaging.html:4 +#: app/routes.py:104 app/templates/messaging.html:4 msgid "Secure Messenger" msgstr "" -#: app/routes.py:99 +#: app/routes.py:106 msgid "Local Chat" msgstr "" -#: app/routes.py:101 +#: app/routes.py:108 msgid "Apps" msgstr "" -#: app/routes.py:103 +#: app/routes.py:110 msgid "Maps" msgstr "" -#: app/routes.py:105 +#: app/routes.py:112 msgid "Files" msgstr "" -#: app/routes.py:107 +#: app/routes.py:114 msgid "Insert USB to browse files" msgstr "" -#: app/routes.py:144 +#: app/routes.py:151 msgid "Invalid username or password" msgstr "" -#: app/routes.py:330 +#: app/routes.py:336 msgid "" "⚠️ Some settings may not fully take effect until the Butter Box restarts." " Click 'Apply Changes' to restart." msgstr "" -#: app/routes.py:334 +#: app/routes.py:340 msgid "Settings successfully changed." msgstr "" -#: app/routes.py:340 +#: app/routes.py:346 msgid "" "⚠️ Changes applied! If needed, the system will restart. This may take up " "to two minutes." @@ -263,7 +259,7 @@ msgstr "" msgid "Language" msgstr "" -#: app/translation_refs.py:19 +#: app/templates/base.html:40 app/translation_refs.py:19 msgid "Share Access" msgstr "" @@ -271,11 +267,17 @@ msgstr "" msgid "512 x 512 px. Recommended size." msgstr "" +#: app/translation_refs.py:21 +msgid "" +"Continue to your box portal. The portal is the view others will see when " +"they connect to the box hotspot." +msgstr "" + #: app/templates/admin.html:8 msgid "Application Settings" msgstr "" -#: app/templates/admin_setup.html:6 app/templates/base.html:34 +#: app/templates/admin_setup.html:6 app/templates/base.html:36 msgid "Admin Settings" msgstr "" @@ -295,6 +297,25 @@ msgstr "" msgid "Secure Admin Settings" msgstr "" +#: app/templates/deltachat_creds.html:4 +msgid "Secure Messenger Account" +msgstr "" + +#: app/templates/deltachat_creds.html:9 +msgid "Scan the following QR code with a device where DeltaChat is installed:" +msgstr "" + +#: app/templates/deltachat_creds.html:14 +msgid "" +"If your device does not have a camera, select \"Create new profile\" in " +"DeltaChat, choose \"Use Other Server\" and find \"Paste from clipboard\"," +" to paste the following link" +msgstr "" + +#: app/templates/deltachat_creds.html:21 +msgid "Generate new credentials" +msgstr "" + #: app/templates/first_setup_main_page.html:6 msgid "Set up your box" msgstr "" @@ -325,8 +346,8 @@ msgstr "" #: app/templates/messaging.html:7 msgid "" -"To use secure messaging, install Delta Chat and then return to this page " -"to create your local offline account." +"To use secure messaging, install Delta Chat and then create your local " +"offline account." msgstr "" #: app/templates/messaging.html:10 @@ -346,13 +367,11 @@ msgid "Create offline account" msgstr "" #: app/templates/setup_complete.html:4 -msgid "Changes have been applied " +msgid "Changes have been applied" msgstr "" #: app/templates/setup_complete.html:7 -msgid "" -"Continue to your box portal. The portal is the view others will see when " -"they connect to the box hotspot." +msgid "The box will now reboot to apply settings. This can take up to one minute." msgstr "" #: app/templates/setup_complete.html:8 diff --git a/translations/ru/LC_MESSAGES/messages.po b/translations/ru/LC_MESSAGES/messages.po index d560de7..65e6916 100644 --- a/translations/ru/LC_MESSAGES/messages.po +++ b/translations/ru/LC_MESSAGES/messages.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: PROJECT VERSION\n" "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" -"POT-Creation-Date: 2026-03-29 17:11+0100\n" +"POT-Creation-Date: 2026-03-31 12:45+0100\n" "PO-Revision-Date: 2026-03-29 17:13+0100\n" "Last-Translator: FULL NAME \n" "Language: ru\n" @@ -24,7 +24,7 @@ msgid "Please log in to access this page." msgstr "" #: app/forms.py:13 -msgid "Only dashes, underscores, letters and numbers allowed" +msgid "Only dashes, underscores, letters and numbers allowed." msgstr "" #: app/forms.py:17 @@ -143,49 +143,45 @@ msgstr "" msgid "Submit" msgstr "" -#: app/routes.py:95 -msgid "Share WiFi" -msgstr "" - -#: app/routes.py:97 app/templates/messaging.html:4 +#: app/routes.py:104 app/templates/messaging.html:4 msgid "Secure Messenger" msgstr "" -#: app/routes.py:99 +#: app/routes.py:106 msgid "Local Chat" msgstr "" -#: app/routes.py:101 +#: app/routes.py:108 msgid "Apps" msgstr "" -#: app/routes.py:103 +#: app/routes.py:110 msgid "Maps" msgstr "" -#: app/routes.py:105 +#: app/routes.py:112 msgid "Files" msgstr "" -#: app/routes.py:107 +#: app/routes.py:114 msgid "Insert USB to browse files" msgstr "" -#: app/routes.py:144 +#: app/routes.py:151 msgid "Invalid username or password" msgstr "" -#: app/routes.py:330 +#: app/routes.py:336 msgid "" "⚠️ Some settings may not fully take effect until the Butter Box restarts." " Click 'Apply Changes' to restart." msgstr "" -#: app/routes.py:334 +#: app/routes.py:340 msgid "Settings successfully changed." msgstr "" -#: app/routes.py:340 +#: app/routes.py:346 msgid "" "⚠️ Changes applied! If needed, the system will restart. This may take up " "to two minutes." @@ -265,7 +261,7 @@ msgstr "" msgid "Language" msgstr "" -#: app/translation_refs.py:19 +#: app/templates/base.html:40 app/translation_refs.py:19 msgid "Share Access" msgstr "" @@ -273,11 +269,17 @@ msgstr "" msgid "512 x 512 px. Recommended size." msgstr "" +#: app/translation_refs.py:21 +msgid "" +"Continue to your box portal. The portal is the view others will see when " +"they connect to the box hotspot." +msgstr "" + #: app/templates/admin.html:8 msgid "Application Settings" msgstr "" -#: app/templates/admin_setup.html:6 app/templates/base.html:34 +#: app/templates/admin_setup.html:6 app/templates/base.html:36 msgid "Admin Settings" msgstr "" @@ -297,6 +299,25 @@ msgstr "" msgid "Secure Admin Settings" msgstr "" +#: app/templates/deltachat_creds.html:4 +msgid "Secure Messenger Account" +msgstr "" + +#: app/templates/deltachat_creds.html:9 +msgid "Scan the following QR code with a device where DeltaChat is installed:" +msgstr "" + +#: app/templates/deltachat_creds.html:14 +msgid "" +"If your device does not have a camera, select \"Create new profile\" in " +"DeltaChat, choose \"Use Other Server\" and find \"Paste from clipboard\"," +" to paste the following link" +msgstr "" + +#: app/templates/deltachat_creds.html:21 +msgid "Generate new credentials" +msgstr "" + #: app/templates/first_setup_main_page.html:6 msgid "Set up your box" msgstr "" @@ -327,8 +348,8 @@ msgstr "" #: app/templates/messaging.html:7 msgid "" -"To use secure messaging, install Delta Chat and then return to this page " -"to create your local offline account." +"To use secure messaging, install Delta Chat and then create your local " +"offline account." msgstr "" #: app/templates/messaging.html:10 @@ -348,13 +369,11 @@ msgid "Create offline account" msgstr "" #: app/templates/setup_complete.html:4 -msgid "Changes have been applied " +msgid "Changes have been applied" msgstr "" #: app/templates/setup_complete.html:7 -msgid "" -"Continue to your box portal. The portal is the view others will see when " -"they connect to the box hotspot." +msgid "The box will now reboot to apply settings. This can take up to one minute." msgstr "" #: app/templates/setup_complete.html:8 @@ -498,3 +517,19 @@ msgstr "" msgid "Directory is empty" msgstr "" +#~ msgid "Only dashes, underscores, letters and numbers allowed" +#~ msgstr "" + +#~ msgid "Share WiFi" +#~ msgstr "" + +#~ msgid "" +#~ "To use secure messaging, install Delta" +#~ " Chat and then return to this " +#~ "page to create your local offline " +#~ "account." +#~ msgstr "" + +#~ msgid "Changes have been applied " +#~ msgstr "" +