diff --git a/package/gluon-hoodselector/luasrc/usr/lib/lua/hoodselector/util.lua b/package/gluon-hoodselector/luasrc/usr/lib/lua/hoodselector/util.lua index cce97788..3da92a65 100644 --- a/package/gluon-hoodselector/luasrc/usr/lib/lua/hoodselector/util.lua +++ b/package/gluon-hoodselector/luasrc/usr/lib/lua/hoodselector/util.lua @@ -2,6 +2,7 @@ local util = require 'gluon.util' local json = require 'jsonc' local uci = require('simple-uci').cursor() local site = require 'gluon.site' +local vpn_util = require('gluon.mesh-vpn') local M = {} @@ -47,17 +48,15 @@ function M.getDefaultHood(jhood) end -- bool if direct VPN. The detection is realised by searching the fastd network interface inside the originator table -function M.directVPN(vpnIfaceList) - for _,vpnIface in ipairs(vpnIfaceList) do +function M.directVPN() local file = io.open("/sys/kernel/debug/batman_adv/bat0/originators", 'r') if file ~= nil then for outgoingIF in file:lines() do -- escape special chars "[]-" - if outgoingIF:match(string.gsub("%[ " .. vpnIface .. "%]","%-", "%%-")) then + if outgoingIF:match(string.gsub("%[ " .. vpn_util.get_mesh_vpn_interface() .. "%]","%-", "%%-")) then return true end end - end end return false end diff --git a/package/gluon-hoodselector/luasrc/usr/sbin/hoodselector b/package/gluon-hoodselector/luasrc/usr/sbin/hoodselector index 20ea9b32..0cfe8a29 100755 --- a/package/gluon-hoodselector/luasrc/usr/sbin/hoodselector +++ b/package/gluon-hoodselector/luasrc/usr/sbin/hoodselector @@ -3,7 +3,6 @@ local bit = require('bit') local unistd = require('posix.unistd') local fcntl = require('posix.fcntl') -local vpn_util = require('gluon.vpn-util') local hoodutil = require('hoodselector.util') -- PID file to ensure the hoodselector isn't running parallel @@ -36,7 +35,7 @@ end -- If no hood for the location has been defined, we will select -- the default hood. -- If we can't determine the node's location, we will continue to the next mode. -if hoodutil.directVPN(vpn_util.get_mesh_vpn_interface()) then +if hoodutil.directVPN() then io.stdout:write('VPN connection found.\n') local geo = hoodutil.getGeolocation() if geo.lat ~= nil and geo.lon ~= nil then