From ac78f19224d5cadc81561f92ca867d3fdee752b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josu=C3=A9=20Tille?= Date: Wed, 20 May 2020 23:41:04 +0200 Subject: [PATCH] Fix and improve coturn config --- conf/turnserver.conf | 6 +++--- scripts/install | 8 ++------ scripts/restore | 8 ++------ scripts/upgrade | 8 ++------ sources/Coturn_config_rotate.sh | 12 ++++-------- 5 files changed, 13 insertions(+), 29 deletions(-) diff --git a/conf/turnserver.conf b/conf/turnserver.conf index bd9fbe9..c3149da 100644 --- a/conf/turnserver.conf +++ b/conf/turnserver.conf @@ -16,13 +16,13 @@ dh-file=/etc/ssl/private/dh2048.pem no-sslv2 no-sslv3 no-tlsv1 +no-tlsv1_1 no-loopback-peers no-multicast-peers +no-cli + log-file=/var/log/matrix-__APP__/turnserver.log pidfile=/var/run/coturn-__APP__/turnserver.pid simple-log - -external-ip=__IPV4__,__IPV6__ - diff --git a/scripts/install b/scripts/install index eb98c2c..09edb6d 100644 --- a/scripts/install +++ b/scripts/install @@ -363,16 +363,12 @@ public_ip6="$(curl ipv6.yunohost.org)" || true if [ -n "$public_ip4" ] && ynh_validate_ip4 --ip_address="$public_ip4" then - ynh_replace_string --match_string='__IPV4__' --replace_string="$public_ip4" --target_file="$coturn_config_path" -else - ynh_replace_string --match_string='__IPV4__,' --replace_string="" --target_file="$coturn_config_path" + echo "external-ip=$public_ip4" >> "$coturn_config_path" fi if [ -n "$public_ip6" ] && ynh_validate_ip6 --ip_address="$public_ip6" then - ynh_replace_string --match_string='__IPV6__' --replace_string="$public_ip6" --target_file="$coturn_config_path" -else - ynh_replace_string --match_string=',__IPV6__' --replace_string="" --target_file="$coturn_config_path" + echo "external-ip=$public_ip6" >> "$coturn_config_path" fi ynh_store_file_checksum --file="$coturn_config_path" diff --git a/scripts/restore b/scripts/restore index d3d3cfb..cf0cb62 100644 --- a/scripts/restore +++ b/scripts/restore @@ -185,16 +185,12 @@ public_ip6="$(curl ipv6.yunohost.org)" || true if [ -n "$public_ip4" ] && ynh_validate_ip4 --ip_address="$public_ip4" then - ynh_replace_string --match_string='__IPV4__' --replace_string="$public_ip4" --target_file="$coturn_config_path" -else - ynh_replace_string --match_string='__IPV4__,' --replace_string="" --target_file="$coturn_config_path" + echo "external-ip=$public_ip4" >> "$coturn_config_path" fi if [ -n "$public_ip6" ] && ynh_validate_ip6 --ip_address="$public_ip6" then - ynh_replace_string --match_string='__IPV6__' --replace_string="$public_ip6" --target_file="$coturn_config_path" -else - ynh_replace_string --match_string=',__IPV6__' --replace_string="" --target_file="$coturn_config_path" + echo "external-ip=$public_ip6" >> "$coturn_config_path" fi ynh_store_file_checksum --file="$coturn_config_path" diff --git a/scripts/upgrade b/scripts/upgrade index 8239b74..f441395 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -406,16 +406,12 @@ public_ip6="$(curl ipv6.yunohost.org)" || true if [ -n "$public_ip4" ] && ynh_validate_ip4 --ip_address="$public_ip4" then - ynh_replace_string --match_string='__IPV4__' --replace_string="$public_ip4" --target_file="$coturn_config_path" -else - ynh_replace_string --match_string='__IPV4__,' --replace_string="" --target_file="$coturn_config_path" + echo "external-ip=$public_ip4" >> "$coturn_config_path" fi if [ -n "$public_ip6" ] && ynh_validate_ip6 --ip_address="$public_ip6" then - ynh_replace_string --match_string='__IPV6__' --replace_string="$public_ip6" --target_file="$coturn_config_path" -else - ynh_replace_string --match_string=',__IPV6__' --replace_string="" --target_file="$coturn_config_path" + echo "external-ip=$public_ip6" >> "$coturn_config_path" fi ynh_store_file_checksum --file="$coturn_config_path" diff --git a/sources/Coturn_config_rotate.sh b/sources/Coturn_config_rotate.sh index e1a99ac..7c2d704 100644 --- a/sources/Coturn_config_rotate.sh +++ b/sources/Coturn_config_rotate.sh @@ -9,18 +9,14 @@ external_IP_line="external-ip=__IPV4__,__IPV6__" public_ip4="$(curl ip.yunohost.org)" || true public_ip6="$(curl ipv6.yunohost.org)" || true -if [[ -n "$public_ip4" ]] && ynh_validate_ip 4 "$public_ip4" +if [ -n "$public_ip4" ] && ynh_validate_ip4 --ip_address="$public_ip4" then - external_IP_line="${external_IP_line/'__IPV4__'/$public_ip4}" -else - external_IP_line="${external_IP_line/'__IPV4__,'/}" + echo "external-ip=$public_ip4" >> "$coturn_config_path" fi -if [[ -n "$public_ip6" ]] && ynh_validate_ip 6 "$public_ip6" +if [ -n "$public_ip6" ] && ynh_validate_ip6 --ip_address="$public_ip6" then - external_IP_line="${external_IP_line/'__IPV6__'/$public_ip6}" -else - external_IP_line="${external_IP_line/',__IPV6__'/}" + echo "external-ip=$public_ip6" >> "$coturn_config_path" fi old_config_line=$(egrep "^external-ip=.*\$" "/etc/matrix-$app_instance/coturn.conf")