Browse Source

Check connectivity against updateservers instead of google dns

Michael Schwarz 8 years ago
parent
commit
7c2f011906

+ 13 - 0
ffho/ffho-autoupdater-wifi-fallback/files/usr/lib/lua/autoupdater-wifi-fallback/util.lua

@@ -20,6 +20,19 @@ function get_available_wifi_networks()
   return false
 end
 
+function get_update_hosts()
+  local hosts = {}
+  local branch = uci:get('autoupdater', 'settings', 'branch')
+  local mirrors = uci:get_list('autoupdater', branch, 'mirror')
+
+  while #mirrors > 0 do
+    local m = table.remove(mirrors)
+    mirror = m:match("://%[?([a-zA-Z0-9\:\.]+)%]?/")
+    table.insert(hosts, 1, mirror)
+  end
+  return hosts
+end
+
 function get_site_macs()
   local macs = {}
   local interfaces = util.split(util.trim(util.exec(string.format("iw dev mesh0 scan | grep -B10 %s | grep BSS | cut -f2 -d' ' | cut -f1 -d'('", site.wifi24.ap.ssid))))

+ 9 - 3
ffho/ffho-autoupdater-wifi-fallback/files/usr/sbin/autoupdater-wifi-fallback

@@ -62,11 +62,17 @@ local function check_connectivity()
       end
     end
   end
+
   
-  -- ipv6 connectivity check against google dns
-  if os.execute("ping6 -w2 -c1 2001:4860:4860::8888 > /dev/null 2>&1") == 0 then
-    return true
+  -- connectivity check against updateserver
+  local updateHosts = get_update_hosts()
+  while #updateHosts > 0 do
+    host = table.remove(updateHosts)
+    if os.execute("ping -w2 -c1 " .. host .. " > /dev/null 2>&1") == 0 then
+      return true
+    end
   end
+
   return false
 end