diff --git a/conf/ynh-hotspot b/conf/ynh-hotspot index aaf0b96..d375730 100644 --- a/conf/ynh-hotspot +++ b/conf/ynh-hotspot @@ -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; }') diff --git a/config_panel.toml b/config_panel.toml index 71a9384..ff286d0 100644 --- a/config_panel.toml +++ b/config_panel.toml @@ -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" diff --git a/scripts/config b/scripts/config index 8655dfd..c683ae8 100644 --- a/scripts/config +++ b/scripts/config @@ -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 #================================================= diff --git a/scripts/install b/scripts/install index 090700b..4fa79f4 100644 --- a/scripts/install +++ b/scripts/install @@ -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