1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/hotspot_ynh.git synced 2024-09-03 19:25:53 +02:00

fix dns config

This commit is contained in:
HgO 2023-08-20 16:20:20 +02:00
parent 1a4030a094
commit c05667cdbb
4 changed files with 23 additions and 14 deletions

View file

@ -223,21 +223,10 @@ if [ "$1" != restart ]; then
wifi_secure=$(ynh_app_setting_get hotspot wifi_secure)
wifi_passphrase=$(ynh_app_setting_get hotspot wifi_passphrase)
ip6_firewall=$(ynh_app_setting_get hotspot ip6_firewall)
ip6_dns=$(ynh_app_setting_get hotspot ip6_dns)
ip6_net=$(ynh_app_setting_get hotspot ip6_net)
dns=$(ynh_app_setting_get hotspot dns)
ip4_dns=$(ynh_app_setting_get hotspot ip4_dns)
ip4_nat_prefix=$(ynh_app_setting_get hotspot ip4_nat_prefix)
ip6_dns=""
ip4_dns=""
for ip in $(echo "${dns}" | tr ',' ' '); do
if [[ "$ip" == *":"* ]]; then
ip6_dns+="[$ip],"
else
ip4_dns+="$ip,"
fi
done
# Remove trailing ,
ip6_dns="${ip6_dns%%,}"
ip4_dns="${ip4_dns%%,}"
old_gateway_interface=$(ynh_app_setting_get hotspot gateway_interface)
new_gateway_interface=$(ip route get 1.2.3.4 | awk '{ print $5; }')

View file

@ -103,6 +103,7 @@ name = "Configuration"
[main.hotspot.dns]
ask = "DNS resolvers"
type = "tags"
bind = "null"
visible = "advanced"
pattern.regexp = '^([0-9.]{7,15}|[0-9a-fA-F:]+)$'
pattern.error = "Not an ip"

View file

@ -132,6 +132,24 @@ validate__dns() {
# SPECIFIC SETTERS FOR TOML SHORT KEYS
#=================================================
set__dns() {
ip6_dns=""
ip4_dns=""
for ip in $(echo "${dns}" | tr ',' ' '); do
if [[ "$ip" == *":"* ]]; then
ip6_dns+="[$ip],"
else
ip4_dns+="$ip,"
fi
done
# Remove trailing ,
ip6_dns="${ip6_dns%%,}"
ip4_dns="${ip4_dns%%,}"
ynh_app_setting_set $app ip6_dns "${ip6_dns}"
ynh_app_setting_set $app ip4_dns "${ip4_dns}"
}
#=================================================
# OVERWRITING VALIDATE STEP
#=================================================

View file

@ -139,8 +139,9 @@ ynh_app_setting_set --app=$app --key=wifi_passphrase --value="${wifi_passphrase}
ynh_app_setting_set --app=$app --key=wifi_device --value="${wifi_device}"
ynh_app_setting_set --app=$app --key=wifi_channel --value=6
ynh_app_setting_set --app=$app --key=ip6_firewall --value=1
ynh_app_setting_set --app=$app --key=ip6_dns --value=""
ynh_app_setting_set --app=$app --key=ip6_net --value="${ip6_net}"
ynh_app_setting_set --app=$app --key=dns --value="10.0.242.1"
ynh_app_setting_set --app=$app --key=ip4_dns --value="10.0.242.1"
ynh_app_setting_set --app=$app --key=ip4_nat_prefix --value=10.0.242
if [[ -z $wifi_device ]]; then