diff --git a/app/forms.py b/app/forms.py index 1de53bb..ebb878e 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,8): + if len(field.data) in range(1,9): raise ValidationError(_l('Wifi password cannot be shorter than 8 characters.')) class LoginForm(FlaskForm): diff --git a/app/routes.py b/app/routes.py index f7cdf9f..097d603 100644 --- a/app/routes.py +++ b/app/routes.py @@ -1,6 +1,3 @@ -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 @@ -28,10 +25,7 @@ RASPAP_INSTALLED = os.path.exists("/var/www/html/raspap") def gen_username() -> str: words = top_n_list("en", 5000) prefix = random.randint(1000, 9999) - 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}" + return f"{random.choice(words)}{random.choice(words)}{prefix}" def gen_password() -> str: characters = string.ascii_letters + string.digits @@ -352,17 +346,15 @@ def messaging(): return render_template('messaging.html', get_setting=get_setting) @app.route("/deltachat_credentials", methods=["POST"]) -def deltachat_credentials(): +def generate_random_deltachat_credentials(): ip = app.config['BUTTERBOX_DEFAULT_IP'] username = gen_username() password = gen_password() - 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) + + flash(f"Username: {username}") + flash(f"Password: {password}") + flash(f"IP: {ip}") + return redirect(url_for("messaging")) @app.route('/share') def share(): diff --git a/app/templates/deltachat_creds.html b/app/templates/deltachat_creds.html deleted file mode 100644 index afa9f25..0000000 --- a/app/templates/deltachat_creds.html +++ /dev/null @@ -1,24 +0,0 @@ -{% 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 c5f5e9f..9ce1233 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 create your local offline account.")}}

+

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

-
+ diff --git a/install_madmail.py b/install_madmail.py index cf4dd0b..d5c8e14 100644 --- a/install_madmail.py +++ b/install_madmail.py @@ -1,7 +1,5 @@ import pexpect import json -from app import app - def run_madmail_installer(): with open("./settings.txt", "r") as f: settings = json.load(f) @@ -17,7 +15,7 @@ def run_madmail_installer(): child.expect("MX record") child.sendline(f"{butterbox_hostname}.locaL") child.expect("Public IP address") - child.sendline(app.config['BUTTERBOX_DEFAULT_IP']) + child.sendline("127.0.0.1") child.expect("Additional domains") child.sendline("") child.expect("State directory") @@ -57,7 +55,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("y") + child.sendline("n") child.expect("Passthrough senders") child.sendline("") child.expect("Passthrough recipients") diff --git a/messages.pot b/messages.pot index 2ed9f78..8d9cf7b 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-31 12:45+0100\n" +"POT-Creation-Date: 2026-03-29 17:11+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,45 +141,49 @@ msgstr "" msgid "Submit" msgstr "" -#: app/routes.py:104 app/templates/messaging.html:4 +#: app/routes.py:95 +msgid "Share WiFi" +msgstr "" + +#: app/routes.py:97 app/templates/messaging.html:4 msgid "Secure Messenger" msgstr "" -#: app/routes.py:106 +#: app/routes.py:99 msgid "Local Chat" msgstr "" -#: app/routes.py:108 +#: app/routes.py:101 msgid "Apps" msgstr "" -#: app/routes.py:110 +#: app/routes.py:103 msgid "Maps" msgstr "" -#: app/routes.py:112 +#: app/routes.py:105 msgid "Files" msgstr "" -#: app/routes.py:114 +#: app/routes.py:107 msgid "Insert USB to browse files" msgstr "" -#: app/routes.py:151 +#: app/routes.py:144 msgid "Invalid username or password" msgstr "" -#: app/routes.py:336 +#: app/routes.py:330 msgid "" "⚠️ Some settings may not fully take effect until the Butter Box restarts." " Click 'Apply Changes' to restart." msgstr "" -#: app/routes.py:340 +#: app/routes.py:334 msgid "Settings successfully changed." msgstr "" -#: app/routes.py:346 +#: app/routes.py:340 msgid "" "⚠️ Changes applied! If needed, the system will restart. This may take up " "to two minutes." @@ -259,7 +263,7 @@ msgstr "" msgid "Language" msgstr "" -#: app/templates/base.html:40 app/translation_refs.py:19 +#: app/translation_refs.py:19 msgid "Share Access" msgstr "" @@ -267,17 +271,11 @@ 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:36 +#: app/templates/admin_setup.html:6 app/templates/base.html:34 msgid "Admin Settings" msgstr "" @@ -297,25 +295,6 @@ 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 "" @@ -346,8 +325,8 @@ msgstr "" #: app/templates/messaging.html:7 msgid "" -"To use secure messaging, install Delta Chat and then create your local " -"offline account." +"To use secure messaging, install Delta Chat and then return to this page " +"to create your local offline account." msgstr "" #: app/templates/messaging.html:10 @@ -367,11 +346,13 @@ 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 "The box will now reboot to apply settings. This can take up to one minute." +msgid "" +"Continue to your box portal. The portal is the view others will see when " +"they connect to the box hotspot." msgstr "" #: app/templates/setup_complete.html:8 diff --git a/translations/ru/LC_MESSAGES/messages.po b/translations/ru/LC_MESSAGES/messages.po index 65e6916..d560de7 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-31 12:45+0100\n" +"POT-Creation-Date: 2026-03-29 17:11+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,45 +143,49 @@ msgstr "" msgid "Submit" msgstr "" -#: app/routes.py:104 app/templates/messaging.html:4 +#: app/routes.py:95 +msgid "Share WiFi" +msgstr "" + +#: app/routes.py:97 app/templates/messaging.html:4 msgid "Secure Messenger" msgstr "" -#: app/routes.py:106 +#: app/routes.py:99 msgid "Local Chat" msgstr "" -#: app/routes.py:108 +#: app/routes.py:101 msgid "Apps" msgstr "" -#: app/routes.py:110 +#: app/routes.py:103 msgid "Maps" msgstr "" -#: app/routes.py:112 +#: app/routes.py:105 msgid "Files" msgstr "" -#: app/routes.py:114 +#: app/routes.py:107 msgid "Insert USB to browse files" msgstr "" -#: app/routes.py:151 +#: app/routes.py:144 msgid "Invalid username or password" msgstr "" -#: app/routes.py:336 +#: app/routes.py:330 msgid "" "⚠️ Some settings may not fully take effect until the Butter Box restarts." " Click 'Apply Changes' to restart." msgstr "" -#: app/routes.py:340 +#: app/routes.py:334 msgid "Settings successfully changed." msgstr "" -#: app/routes.py:346 +#: app/routes.py:340 msgid "" "⚠️ Changes applied! If needed, the system will restart. This may take up " "to two minutes." @@ -261,7 +265,7 @@ msgstr "" msgid "Language" msgstr "" -#: app/templates/base.html:40 app/translation_refs.py:19 +#: app/translation_refs.py:19 msgid "Share Access" msgstr "" @@ -269,17 +273,11 @@ 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:36 +#: app/templates/admin_setup.html:6 app/templates/base.html:34 msgid "Admin Settings" msgstr "" @@ -299,25 +297,6 @@ 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 "" @@ -348,8 +327,8 @@ msgstr "" #: app/templates/messaging.html:7 msgid "" -"To use secure messaging, install Delta Chat and then create your local " -"offline account." +"To use secure messaging, install Delta Chat and then return to this page " +"to create your local offline account." msgstr "" #: app/templates/messaging.html:10 @@ -369,11 +348,13 @@ 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 "The box will now reboot to apply settings. This can take up to one minute." +msgid "" +"Continue to your box portal. The portal is the view others will see when " +"they connect to the box hotspot." msgstr "" #: app/templates/setup_complete.html:8 @@ -517,19 +498,3 @@ 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 "" -