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):
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):

View file

@ -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():

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>
<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>
<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>
</button>
</a>
<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">
<p>{{ _("Step 2") }} <br> {{ _("Create offline account") }} </p>
</button>

View file

@ -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")

View file

@ -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 <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\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
@ -350,9 +371,7 @@ 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

View file

@ -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 <EMAIL@ADDRESS>\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
@ -352,9 +373,7 @@ 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 ""