Browse Source

Moar bugfixes

Alexandre Aubin 3 years ago
parent
commit
ae29b14852
3 changed files with 6 additions and 5 deletions
  1. 3 3
      conf/hook_post-iptable-rules
  2. 2 1
      conf/ynh-vpnclient
  3. 1 1
      scripts/config

+ 3 - 3
conf/hook_post-iptable-rules

@@ -1,14 +1,14 @@
 #!/bin/bash
 
 server_names=$(grep -o -P '^\s*remote\s+\K([^\s]+)' /etc/openvpn/client.conf | sort | uniq)
-host6=$(dig AAAA +short $server_names @127.0.0.1 | grep -v '\.$')
-host4=$(dig A +short $server_names @127.0.0.1 | grep -v '\.$')
+host6=$(dig AAAA +short $server_names @127.0.0.1 | grep -v '\.$' | grep -v "timed out")
+host4=$(dig A +short $server_names @127.0.0.1 | grep -v '\.$' | grep -v "timed out")
 
 # In case an ip has been provided in ovpn conf
 for i in ${server_names}; do
   if [[ "${i}" =~ : ]]; then
       host6+=" ${i}"
-  elif [[ "${i}" =~ ^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$ ]]; then
+  elif [[ "${i}" =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
       host4+=" ${i}"
   fi
 done

+ 2 - 1
conf/ynh-vpnclient

@@ -353,7 +353,8 @@ if [ "$1" != restart ]; then
   new_ip6_gw=$(ip -6 route | awk '/default via/ { print $3 }')
   new_wired_device=$(ip route | awk '/default via/ { print $5; }')
   ynh_server_names=$(grep -o -P '^\s*remote\s+\K([^\s]+)' /etc/openvpn/client.conf | sort | uniq)
-  new_server_ip6=$(dig AAAA +short $ynh_server_names | grep -v '\.$' | sort | uniq)
+  new_server_ip6=$(dig AAAA +short $ynh_server_names @127.0.0.1 | grep -v '\.$' | grep -v "timed out" | sort | uniq)
+
   for i in $ynh_server_names; do
     if [[ "${i}" =~ : ]] && [[ ! "$new_server_ip6" == *"${i}"* ]] ; then
         new_server_ip6+=" ${i}"

+ 1 - 1
scripts/config

@@ -211,7 +211,7 @@ ynh_app_config_validate() {
 
     # We don't have the extension, so we use this ugly hack to check that this is a json-like
     # (i.e. it starts with { ..)
-    elif [ -f "${config_file}" ] && [ "$(cat ${config_file} | tr -d ' ' | grep -v "^$" | head -c1)" == "{" ]]
+    elif [ -f "${config_file}" ] && [[ "$(cat ${config_file} | tr -d ' ' | grep -v "^$" | head -c1)" == "{" ]]
     then
         ynh_print_info --message="Transforming .cube into OVPN file"
         server_name="$(read_cube $config_file server_name)"