Parcourir la source

fix dns config

HgO il y a 1 an
Parent
commit
c05667cdbb
4 fichiers modifiés avec 23 ajouts et 14 suppressions
  1. 2 13
      conf/ynh-hotspot
  2. 1 0
      config_panel.toml
  3. 18 0
      scripts/config
  4. 2 1
      scripts/install

+ 2 - 13
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; }')

+ 1 - 0
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"

+ 18 - 0
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 
 #=================================================

+ 2 - 1
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