mirror of
https://github.com/YunoHost-Apps/synapse_ynh.git
synced 2024-09-03 20:26:38 +02:00
User official helper in coturn_config_rotate
This commit is contained in:
parent
e1065d80a8
commit
7ba0e3baaf
1 changed files with 3 additions and 27 deletions
|
@ -2,31 +2,7 @@
|
||||||
|
|
||||||
app_instance=__APP__
|
app_instance=__APP__
|
||||||
|
|
||||||
# Validate an IP address syntax
|
source /usr/share/yunohost/helpers
|
||||||
#
|
|
||||||
# usage: ynh_validate_ip ip_address_family ip_address
|
|
||||||
# | arg: ip_address_family - either 4 (for IPv4) or 6 (for IPv6)
|
|
||||||
# | arg: ip_address - IP address to validate
|
|
||||||
ynh_validate_ip()
|
|
||||||
{
|
|
||||||
# http://stackoverflow.com/questions/319279/how-to-validate-ip-address-in-python#319298
|
|
||||||
|
|
||||||
local ip_address_family=$1
|
|
||||||
local ip_address=$2
|
|
||||||
|
|
||||||
[ "$ip_address_family" == "4" ] || [ "$ip_address_family" == "6" ] || return 1
|
|
||||||
|
|
||||||
python /dev/stdin << EOF
|
|
||||||
import socket
|
|
||||||
import sys
|
|
||||||
family = { "4" : socket.AF_INET, "6" : socket.AF_INET6 }
|
|
||||||
try:
|
|
||||||
socket.inet_pton(family["$ip_address_family"], "$ip_address")
|
|
||||||
except socket.error:
|
|
||||||
sys.exit(1)
|
|
||||||
sys.exit(0)
|
|
||||||
EOF
|
|
||||||
}
|
|
||||||
|
|
||||||
external_IP_line="external-ip=__IPV4__,__IPV6__"
|
external_IP_line="external-ip=__IPV4__,__IPV6__"
|
||||||
|
|
||||||
|
@ -47,6 +23,6 @@ else
|
||||||
external_IP_line="${external_IP_line/',__IPV6__'/}"
|
external_IP_line="${external_IP_line/',__IPV6__'/}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
sed --in-place "s@^external-ip=.*\$@$external_IP_line@g" "/etc/matrix-$app_instance/coturn.conf"
|
ynh_replace_string "^external-ip=.*\$" "$external_IP_line" "/etc/matrix-$app_instance/coturn.conf"
|
||||||
|
|
||||||
exit 0
|
exit 0
|
Loading…
Add table
Reference in a new issue