Compare commits

..

2 commits

7 changed files with 148 additions and 60 deletions

View file

@ -15,7 +15,7 @@ def hostname_check(form, field):
def wifi_length_check(form, field): def wifi_length_check(form, field):
if len(field.data) > 63: if len(field.data) > 63:
raise ValidationError(_l('Wifi password cannot be longer than 63 characters.')) 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.')) raise ValidationError(_l('Wifi password cannot be shorter than 8 characters.'))
class LoginForm(FlaskForm): class LoginForm(FlaskForm):

View file

@ -1,3 +1,6 @@
import io
import re
from app import app from app import app
from flask import render_template, flash, redirect, url_for, send_file from flask import render_template, flash, redirect, url_for, send_file
from app.forms import LoginForm, SettingsForm, Step1Form, Step2Form, Step3Form, Step4Form 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: def gen_username() -> str:
words = top_n_list("en", 5000) words = top_n_list("en", 5000)
prefix = random.randint(1000, 9999) 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: def gen_password() -> str:
characters = string.ascii_letters + string.digits characters = string.ascii_letters + string.digits
@ -346,15 +352,17 @@ def messaging():
return render_template('messaging.html', get_setting=get_setting) return render_template('messaging.html', get_setting=get_setting)
@app.route("/deltachat_credentials", methods=["POST"]) @app.route("/deltachat_credentials", methods=["POST"])
def generate_random_deltachat_credentials(): def deltachat_credentials():
ip = app.config['BUTTERBOX_DEFAULT_IP'] ip = app.config['BUTTERBOX_DEFAULT_IP']
username = gen_username() username = gen_username()
password = gen_password() password = gen_password()
hostname = f"{get_setting('butterbox_hostname')}.local"
flash(f"Username: {username}") dclink = f"dclogin:{username}@{hostname}/?p={password}&v=1&ih={ip}&ip=143&sh={ip}&sp=25&is=plain&ss=plain&sc=3"
flash(f"Password: {password}") img = qrcode.make(dclink)
flash(f"IP: {ip}") file_object = io.BytesIO()
return redirect(url_for("messaging")) 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') @app.route('/share')
def share(): def share():

View file

@ -0,0 +1,24 @@
{% extends "base.html" %}
{% block content %}
<h1 class="title is-large butter-title">{{ _('Secure Messenger Account') }}</h1>
<div class="block">
<div class="block">
<p>{{ _('Scan the following QR code with a device where DeltaChat is installed:') }}</p>
</div>
<img src="{{ base64img }}"/>
</div>
<div class="block">
<div class="block"><p class="">{{ _('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') }}:</p></div>
<pre>{{ dclink}}</pre>
</div>
<div class="block"></div>
<form action="{{ url_for('deltachat_credentials') }}" method="post">
<button type="submit" class="button is-link is-fullwidth block">
<p>{{ _("Generate new credentials") }} </p>
</button>
</form>
{% endblock %}

View file

@ -4,14 +4,14 @@
<h1 class="title is-large butter-title">{{ _('Secure Messenger') }}</h1> <h1 class="title is-large butter-title">{{ _('Secure Messenger') }}</h1>
<div class="block"> <div class="block">
<p> {{ _("To use secure messaging, install Delta Chat and then return to this page to create your local offline account.")}}</p> <p> {{ _("To use secure messaging, install Delta Chat and then create your local offline account.")}}</p>
</div> </div>
<a href="{{ url_for('static', filename='DeltaChat_2.35.0_APKPure.apk') }}"><button class="button is-link is-fullwidth block"> <a href="{{ url_for('static', filename='DeltaChat_2.35.0_APKPure.apk') }}"><button class="button is-link is-fullwidth block">
<p>{{ _("Step 1") }}<br> {{ _("Download and install") }}</p> <p>{{ _("Step 1") }}<br> {{ _("Download and install") }}</p>
</button> </button>
</a> </a>
<div class="block"></div> <div class="block"></div>
<form action="{{ url_for('generate_random_deltachat_credentials') }}" method="post"> <form action="{{ url_for('deltachat_credentials') }}" method="post">
<button type="submit" class="button is-link is-fullwidth block"> <button type="submit" class="button is-link is-fullwidth block">
<p>{{ _("Step 2") }} <br> {{ _("Create offline account") }} </p> <p>{{ _("Step 2") }} <br> {{ _("Create offline account") }} </p>
</button> </button>

View file

@ -1,5 +1,7 @@
import pexpect import pexpect
import json import json
from app import app
def run_madmail_installer(): def run_madmail_installer():
with open("./settings.txt", "r") as f: with open("./settings.txt", "r") as f:
settings = json.load(f) settings = json.load(f)
@ -15,7 +17,7 @@ def run_madmail_installer():
child.expect("MX record") child.expect("MX record")
child.sendline(f"{butterbox_hostname}.locaL") child.sendline(f"{butterbox_hostname}.locaL")
child.expect("Public IP address") child.expect("Public IP address")
child.sendline("127.0.0.1") child.sendline(app.config['BUTTERBOX_DEFAULT_IP'])
child.expect("Additional domains") child.expect("Additional domains")
child.sendline("") child.sendline("")
child.expect("State directory") child.expect("State directory")
@ -55,7 +57,7 @@ def run_madmail_installer():
child.expect("Require PGP encryption for outgoing messages") child.expect("Require PGP encryption for outgoing messages")
child.sendline("y") child.sendline("y")
child.expect("Allow secure join requests without encryption") child.expect("Allow secure join requests without encryption")
child.sendline("n") child.sendline("y")
child.expect("Passthrough senders") child.expect("Passthrough senders")
child.sendline("") child.sendline("")
child.expect("Passthrough recipients") child.expect("Passthrough recipients")

View file

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PROJECT VERSION\n" "Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\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" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -22,7 +22,7 @@ msgid "Please log in to access this page."
msgstr "" msgstr ""
#: app/forms.py:13 #: app/forms.py:13
msgid "Only dashes, underscores, letters and numbers allowed" msgid "Only dashes, underscores, letters and numbers allowed."
msgstr "" msgstr ""
#: app/forms.py:17 #: app/forms.py:17
@ -141,49 +141,45 @@ msgstr ""
msgid "Submit" msgid "Submit"
msgstr "" msgstr ""
#: app/routes.py:95 #: app/routes.py:104 app/templates/messaging.html:4
msgid "Share WiFi"
msgstr ""
#: app/routes.py:97 app/templates/messaging.html:4
msgid "Secure Messenger" msgid "Secure Messenger"
msgstr "" msgstr ""
#: app/routes.py:99 #: app/routes.py:106
msgid "Local Chat" msgid "Local Chat"
msgstr "" msgstr ""
#: app/routes.py:101 #: app/routes.py:108
msgid "Apps" msgid "Apps"
msgstr "" msgstr ""
#: app/routes.py:103 #: app/routes.py:110
msgid "Maps" msgid "Maps"
msgstr "" msgstr ""
#: app/routes.py:105 #: app/routes.py:112
msgid "Files" msgid "Files"
msgstr "" msgstr ""
#: app/routes.py:107 #: app/routes.py:114
msgid "Insert USB to browse files" msgid "Insert USB to browse files"
msgstr "" msgstr ""
#: app/routes.py:144 #: app/routes.py:151
msgid "Invalid username or password" msgid "Invalid username or password"
msgstr "" msgstr ""
#: app/routes.py:330 #: app/routes.py:336
msgid "" msgid ""
"⚠️ Some settings may not fully take effect until the Butter Box restarts." "⚠️ Some settings may not fully take effect until the Butter Box restarts."
" Click 'Apply Changes' to restart." " Click 'Apply Changes' to restart."
msgstr "" msgstr ""
#: app/routes.py:334 #: app/routes.py:340
msgid "Settings successfully changed." msgid "Settings successfully changed."
msgstr "" msgstr ""
#: app/routes.py:340 #: app/routes.py:346
msgid "" msgid ""
"⚠️ Changes applied! If needed, the system will restart. This may take up " "⚠️ Changes applied! If needed, the system will restart. This may take up "
"to two minutes." "to two minutes."
@ -263,7 +259,7 @@ msgstr ""
msgid "Language" msgid "Language"
msgstr "" msgstr ""
#: app/translation_refs.py:19 #: app/templates/base.html:40 app/translation_refs.py:19
msgid "Share Access" msgid "Share Access"
msgstr "" msgstr ""
@ -271,11 +267,17 @@ msgstr ""
msgid "512 x 512 px. Recommended size." msgid "512 x 512 px. Recommended size."
msgstr "" 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 #: app/templates/admin.html:8
msgid "Application Settings" msgid "Application Settings"
msgstr "" 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" msgid "Admin Settings"
msgstr "" msgstr ""
@ -295,6 +297,25 @@ msgstr ""
msgid "Secure Admin Settings" msgid "Secure Admin Settings"
msgstr "" 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 #: app/templates/first_setup_main_page.html:6
msgid "Set up your box" msgid "Set up your box"
msgstr "" msgstr ""
@ -325,8 +346,8 @@ msgstr ""
#: app/templates/messaging.html:7 #: app/templates/messaging.html:7
msgid "" msgid ""
"To use secure messaging, install Delta Chat and then return to this page " "To use secure messaging, install Delta Chat and then create your local "
"to create your local offline account." "offline account."
msgstr "" msgstr ""
#: app/templates/messaging.html:10 #: app/templates/messaging.html:10
@ -350,9 +371,7 @@ msgid "Changes have been applied "
msgstr "" msgstr ""
#: app/templates/setup_complete.html:7 #: app/templates/setup_complete.html:7
msgid "" msgid "The box will now reboot to apply settings. This can take up to one minute."
"Continue to your box portal. The portal is the view others will see when "
"they connect to the box hotspot."
msgstr "" msgstr ""
#: app/templates/setup_complete.html:8 #: app/templates/setup_complete.html:8

View file

@ -7,7 +7,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PROJECT VERSION\n" "Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\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" "PO-Revision-Date: 2026-03-29 17:13+0100\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language: ru\n" "Language: ru\n"
@ -24,7 +24,7 @@ msgid "Please log in to access this page."
msgstr "" msgstr ""
#: app/forms.py:13 #: app/forms.py:13
msgid "Only dashes, underscores, letters and numbers allowed" msgid "Only dashes, underscores, letters and numbers allowed."
msgstr "" msgstr ""
#: app/forms.py:17 #: app/forms.py:17
@ -143,49 +143,45 @@ msgstr ""
msgid "Submit" msgid "Submit"
msgstr "" msgstr ""
#: app/routes.py:95 #: app/routes.py:104 app/templates/messaging.html:4
msgid "Share WiFi"
msgstr ""
#: app/routes.py:97 app/templates/messaging.html:4
msgid "Secure Messenger" msgid "Secure Messenger"
msgstr "" msgstr ""
#: app/routes.py:99 #: app/routes.py:106
msgid "Local Chat" msgid "Local Chat"
msgstr "" msgstr ""
#: app/routes.py:101 #: app/routes.py:108
msgid "Apps" msgid "Apps"
msgstr "" msgstr ""
#: app/routes.py:103 #: app/routes.py:110
msgid "Maps" msgid "Maps"
msgstr "" msgstr ""
#: app/routes.py:105 #: app/routes.py:112
msgid "Files" msgid "Files"
msgstr "" msgstr ""
#: app/routes.py:107 #: app/routes.py:114
msgid "Insert USB to browse files" msgid "Insert USB to browse files"
msgstr "" msgstr ""
#: app/routes.py:144 #: app/routes.py:151
msgid "Invalid username or password" msgid "Invalid username or password"
msgstr "" msgstr ""
#: app/routes.py:330 #: app/routes.py:336
msgid "" msgid ""
"⚠️ Some settings may not fully take effect until the Butter Box restarts." "⚠️ Some settings may not fully take effect until the Butter Box restarts."
" Click 'Apply Changes' to restart." " Click 'Apply Changes' to restart."
msgstr "" msgstr ""
#: app/routes.py:334 #: app/routes.py:340
msgid "Settings successfully changed." msgid "Settings successfully changed."
msgstr "" msgstr ""
#: app/routes.py:340 #: app/routes.py:346
msgid "" msgid ""
"⚠️ Changes applied! If needed, the system will restart. This may take up " "⚠️ Changes applied! If needed, the system will restart. This may take up "
"to two minutes." "to two minutes."
@ -265,7 +261,7 @@ msgstr ""
msgid "Language" msgid "Language"
msgstr "" msgstr ""
#: app/translation_refs.py:19 #: app/templates/base.html:40 app/translation_refs.py:19
msgid "Share Access" msgid "Share Access"
msgstr "" msgstr ""
@ -273,11 +269,17 @@ msgstr ""
msgid "512 x 512 px. Recommended size." msgid "512 x 512 px. Recommended size."
msgstr "" 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 #: app/templates/admin.html:8
msgid "Application Settings" msgid "Application Settings"
msgstr "" 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" msgid "Admin Settings"
msgstr "" msgstr ""
@ -297,6 +299,25 @@ msgstr ""
msgid "Secure Admin Settings" msgid "Secure Admin Settings"
msgstr "" 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 #: app/templates/first_setup_main_page.html:6
msgid "Set up your box" msgid "Set up your box"
msgstr "" msgstr ""
@ -327,8 +348,8 @@ msgstr ""
#: app/templates/messaging.html:7 #: app/templates/messaging.html:7
msgid "" msgid ""
"To use secure messaging, install Delta Chat and then return to this page " "To use secure messaging, install Delta Chat and then create your local "
"to create your local offline account." "offline account."
msgstr "" msgstr ""
#: app/templates/messaging.html:10 #: app/templates/messaging.html:10
@ -352,9 +373,7 @@ msgid "Changes have been applied "
msgstr "" msgstr ""
#: app/templates/setup_complete.html:7 #: app/templates/setup_complete.html:7
msgid "" msgid "The box will now reboot to apply settings. This can take up to one minute."
"Continue to your box portal. The portal is the view others will see when "
"they connect to the box hotspot."
msgstr "" msgstr ""
#: app/templates/setup_complete.html:8 #: app/templates/setup_complete.html:8
@ -498,3 +517,19 @@ msgstr ""
msgid "Directory is empty" msgid "Directory is empty"
msgstr "" 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 ""