From 3b5ce11787ffe36df22cededc52d7c993882133e Mon Sep 17 00:00:00 2001 From: Dante Date: Tue, 12 Apr 2022 17:25:33 +0100 Subject: [PATCH 1/5] Configure end-to-bridge encryption --- conf/config.yaml | 4 ++-- scripts/_common.sh | 1 + scripts/install | 16 ++++++++++++++++ scripts/upgrade | 15 +++++++++++++++ 4 files changed, 34 insertions(+), 2 deletions(-) diff --git a/conf/config.yaml b/conf/config.yaml index aec934f..4edaa44 100644 --- a/conf/config.yaml +++ b/conf/config.yaml @@ -233,10 +233,10 @@ bridge: # application service. encryption: # Allow encryption, work in group chat rooms with e2ee enabled - allow: false + allow: __IS_ENCRYPTION_ENABLED__ # Default to encryption, force-enable encryption in all portals the bridge creates # This will cause the bridge bot to be in private chats for the encryption to work properly. - default: false + default: __IS_ENCRYPTION_ENABLED__ # Database for the encryption data. Currently only supports Postgres and an in-memory # store that's persisted as a pickle. # If set to `default`, will use the appservice postgres database diff --git a/scripts/_common.sh b/scripts/_common.sh index 7a9038d..8d785a2 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -7,6 +7,7 @@ # dependencies used by the app # HACK zlib1g-dev libjpeg-dev (libwebp-dev optional but necessary for stickers) are necessary to compile / install pillow pkg_dependencies="postgresql python3 zlib1g-dev libjpeg-dev libwebp-dev python3-venv libpq-dev" +pkg_dependencies_e2be="libolm-dev" #================================================= # PERSONAL HELPERS diff --git a/scripts/install b/scripts/install index 7bcefe1..081a00d 100755 --- a/scripts/install +++ b/scripts/install @@ -108,6 +108,11 @@ ynh_app_setting_set --app=$app --key=final_path --value=$final_path #================================================= ynh_script_progression --message="Installing dependencies..." --weight=97 +if [ $encryption -eq 1 ]; then + # Install libolm-dev from backports to avoid break on Debian Buster + ynh_install_extra_app_dependencies --repo="http://ftp.debian.org/debian/ buster-backports main" --package="$pkg_dependencies_e2be" --key="https://ftp-master.debian.org/keys/archive-key-10.asc" --name="$app" +fi + ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies #================================================= @@ -178,6 +183,12 @@ ynh_script_progression --message="Configuring Mautrix-Bridge..." --weight=2 mautrix_config_path="$final_path/config.yaml" as_token="\"This value is generated when generating the registration\"" hs_token="\"This value is generated when generating the registration\"" +is_encryption_enabled=$encryption + +if [ $encryption -eq 1 ]; then + is_encryption_enabled=true +fi + write_bridge_config #================================================= @@ -190,6 +201,11 @@ python3 -m venv $final_path export HOME=$final_path # HACK see https://github.com/mautrix/telegram/issues/661 $final_path/bin/pip3 install --upgrade setuptools wheel # HACK fixes "error: invalid command 'bdist_wheel'" $final_path/bin/pip3 install --upgrade $final_path/src/mautrix-telegram.tar.gz[postgres,speedups,qr_login] # metrics,hq_thumbnails,e2be + +if [ $encryption -eq 1 ]; then + $final_path/bin/pip3 install --upgrade $final_path/src/mautrix-telegram.tar.gz[e2be] +fi + # -r optional-requirements.txt $final_path/bin/python3 -m mautrix_telegram -g -c "$mautrix_config_path" -r "$app_service_registration_path/$app.yaml" # initialize the database diff --git a/scripts/upgrade b/scripts/upgrade index efe9cac..fc40a5d 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -99,6 +99,11 @@ fi #================================================= ynh_script_progression --message="Upgrading dependencies..." --weight=1 +if [ $encryption -eq 1 ]; then + # Install libolm-dev from backports to avoid break on Debian Buster + ynh_install_extra_app_dependencies --repo="http://ftp.debian.org/debian/ buster-backports main" --package="$pkg_dependencies_e2be" --key="https://ftp-master.debian.org/keys/archive-key-10.asc" --name="$app" +fi + ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies #================================================= @@ -120,6 +125,10 @@ if [ "$upgrade_type" == "UPGRADE_APP" ]; then export HOME=$final_path # HACK see https://github.com/mautrix/telegram/issues/661 $final_path/bin/pip3 install --upgrade setuptools wheel # HACK fixes "error: invalid command 'bdist_wheel'" $final_path/bin/pip3 install --upgrade $final_path/src/mautrix-telegram.tar.gz[postgres,speedups,qr_login] #,hq_thumbnails + + if [ $encryption -eq 1 ]; then + $final_path/bin/pip3 install --upgrade $final_path/src/mautrix-telegram.tar.gz[e2be] + fi fi #================================================= @@ -142,6 +151,12 @@ as_token=$(grep "as_token:" "$mautrix_config_path" | sed -r "s/ *as_token: *//") hs_token=$(grep "hs_token:" "$mautrix_config_path" | sed -r "s/ *hs_token: *//") # ynh_replace_string --match_string=__AS_TOKEN__ --replace_string="$as_token" --target_file="$mautrix_config_path" # ynh_replace_string --match_string=__HS_TOKEN__ --replace_string="$hs_token" --target_file="$mautrix_config_path" +is_encryption_enabled=$encryption + +if [ $encryption -eq 1 ]; then + is_encryption_enabled=true +fi + write_bridge_config # upgrade the app-service-registration From a66045a369947124468ac595f8bb44e99682e3d6 Mon Sep 17 00:00:00 2001 From: Dante Date: Mon, 8 Aug 2022 12:57:05 +0100 Subject: [PATCH 2/5] Bump yuno version --- README.md | 4 ++-- README_fr.md | 4 ++-- manifest.json | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 764d25c..d034727 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ See also [upstream wiki Authentication page](https://docs.mau.fi/bridges/python/ * see https://docs.mau.fi/bridges/python/telegram/relay-bot.html -**Shipped version:** 0.10.2~ynh3 +**Shipped version:** 0.10.2~ynh4 @@ -123,4 +123,4 @@ or sudo yunohost app upgrade mautrix_telegram -u https://github.com/YunoHost-Apps/mautrix_telegram_ynh/tree/testing --debug ``` -**More info regarding app packaging:** https://yunohost.org/packaging_apps \ No newline at end of file +**More info regarding app packaging:** https://yunohost.org/packaging_apps diff --git a/README_fr.md b/README_fr.md index 5612b12..e23337a 100644 --- a/README_fr.md +++ b/README_fr.md @@ -46,7 +46,7 @@ See also [upstream wiki Authentication page](https://docs.mau.fi/bridges/python/ * see https://docs.mau.fi/bridges/python/telegram/relay-bot.html -**Version incluse :** 0.10.2~ynh3 +**Version incluse :** 0.10.2~ynh4 @@ -119,4 +119,4 @@ ou sudo yunohost app upgrade mautrix_telegram -u https://github.com/YunoHost-Apps/mautrix_telegram_ynh/tree/testing --debug ``` -**Plus d'infos sur le packaging d'applications :** https://yunohost.org/packaging_apps \ No newline at end of file +**Plus d'infos sur le packaging d'applications :** https://yunohost.org/packaging_apps diff --git a/manifest.json b/manifest.json index 2df5204..73eb8dd 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "Telegram puppeting bridge for Matrix/Synapse", "fr": "Passerelle Telegram pour Matrix/Synapse" }, - "version": "0.10.2~ynh3", + "version": "0.10.2~ynh4", "url": "https://docs.mau.fi/bridges/python/telegram/index.html", "upstream": { "license": "free", From bb02df5dcc589564a5fb3c05f395fcbf6286b1a6 Mon Sep 17 00:00:00 2001 From: Dante Date: Mon, 8 Aug 2022 13:11:30 +0100 Subject: [PATCH 3/5] Bump yuno version ynh5 --- README.md | 5 +---- README_fr.md | 5 +---- manifest.json | 2 +- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 26fbafa..03010f8 100644 --- a/README.md +++ b/README.md @@ -50,10 +50,7 @@ See also [upstream wiki Authentication page](https://docs.mau.fi/bridges/python/ * see https://docs.mau.fi/bridges/python/telegram/relay-bot.html -**Shipped version:** 0.10.2~ynh4 - - - +**Shipped version:** 0.10.2~ynh5 ## Disclaimers / important information ### Configuration of the bridge diff --git a/README_fr.md b/README_fr.md index 2f5c1e2..e33558b 100644 --- a/README_fr.md +++ b/README_fr.md @@ -50,10 +50,7 @@ See also [upstream wiki Authentication page](https://docs.mau.fi/bridges/python/ * see https://docs.mau.fi/bridges/python/telegram/relay-bot.html -**Version incluse :** 0.10.2~ynh4 - - - +**Version incluse :** 0.10.2~ynh5 ## Avertissements / informations importantes ### Configuration of the bridge diff --git a/manifest.json b/manifest.json index ce097d5..165c0a5 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "Telegram puppeting bridge for Matrix/Synapse", "fr": "Passerelle Telegram pour Matrix/Synapse" }, - "version": "0.10.2~ynh4", + "version": "0.10.2~ynh5", "url": "https://docs.mau.fi/bridges/python/telegram/index.html", "upstream": { "license": "AGPL-3.0-or-later", From b042fa3db3e70914a2a29724781468904273e9da Mon Sep 17 00:00:00 2001 From: Dante Date: Fri, 12 Aug 2022 18:26:48 +0100 Subject: [PATCH 4/5] Remove specific steps for Buster and add more info on E2BE --- manifest.json | 4 ++-- scripts/install | 4 ++-- scripts/upgrade | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/manifest.json b/manifest.json index c5d31c3..2045037 100644 --- a/manifest.json +++ b/manifest.json @@ -64,8 +64,8 @@ "fr": "Activer le chiffrement entre Synapse et le bridge ?" }, "help": { - "en": "Only activate if you know the prerequisites and constraints related to e2b.", - "fr": "N'activer que si vous connaissez les prérequis et constraintes liées à e2b." + "en": "Only activate if you know the prerequisites and constraints related to e2b. Voir aussi : https://docs.mau.fi/bridges/general/end-to-bridge-encryption.html", + "fr": "N'activer que si vous connaissez les prérequis et constraintes liées à e2b. See more: https://docs.mau.fi/bridges/general/end-to-bridge-encryption.html" }, "default": false }, diff --git a/scripts/install b/scripts/install index fae393a..0362dc4 100755 --- a/scripts/install +++ b/scripts/install @@ -108,8 +108,8 @@ ynh_app_setting_set --app=$app --key=port --value=$port ynh_script_progression --message="Installing dependencies..." --weight=97 if [ $encryption -eq 1 ]; then - # Install libolm-dev from backports to avoid break on Debian Buster - ynh_install_extra_app_dependencies --repo="http://ftp.debian.org/debian/ buster-backports main" --package="$pkg_dependencies_e2be" --key="https://ftp-master.debian.org/keys/archive-key-10.asc" --name="$app" + # Install libolm-dev to be able to use encryption + ynh_install_extra_app_dependencies $pkg_dependencies_e2be fi ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies diff --git a/scripts/upgrade b/scripts/upgrade index 28f8836..170d407 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -98,8 +98,8 @@ fi ynh_script_progression --message="Upgrading dependencies..." --weight=1 if [ $encryption -eq 1 ]; then - # Install libolm-dev from backports to avoid break on Debian Buster - ynh_install_extra_app_dependencies --repo="http://ftp.debian.org/debian/ buster-backports main" --package="$pkg_dependencies_e2be" --key="https://ftp-master.debian.org/keys/archive-key-10.asc" --name="$app" + # Install libolm-dev to be able to use encryption + ynh_install_extra_app_dependencies $pkg_dependencies_e2be fi ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies From 1ac6f955fac0429eab9798e2051352686504010a Mon Sep 17 00:00:00 2001 From: Dante Date: Tue, 16 Aug 2022 14:42:16 +0100 Subject: [PATCH 5/5] Fix translation manifest --- manifest.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/manifest.json b/manifest.json index 2045037..b70bde8 100644 --- a/manifest.json +++ b/manifest.json @@ -64,8 +64,8 @@ "fr": "Activer le chiffrement entre Synapse et le bridge ?" }, "help": { - "en": "Only activate if you know the prerequisites and constraints related to e2b. Voir aussi : https://docs.mau.fi/bridges/general/end-to-bridge-encryption.html", - "fr": "N'activer que si vous connaissez les prérequis et constraintes liées à e2b. See more: https://docs.mau.fi/bridges/general/end-to-bridge-encryption.html" + "en": "Only activate if you know the prerequisites and constraints related to e2b. See more: https://docs.mau.fi/bridges/general/end-to-bridge-encryption.html", + "fr": "N'activer que si vous connaissez les prérequis et constraintes liées à e2b. Voir aussi : https://docs.mau.fi/bridges/general/end-to-bridge-encryption.html" }, "default": false },