gluon-hoodselector: apply changes of mesh vpn lib
This commit is contained in:
parent
12f6387ad0
commit
898ceff9a8
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user