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 json = require 'jsonc'
|
||||||
local uci = require('simple-uci').cursor()
|
local uci = require('simple-uci').cursor()
|
||||||
local site = require 'gluon.site'
|
local site = require 'gluon.site'
|
||||||
|
local vpn_util = require('gluon.mesh-vpn')
|
||||||
|
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
@ -47,17 +48,15 @@ function M.getDefaultHood(jhood)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- bool if direct VPN. The detection is realised by searching the fastd network interface inside the originator table
|
-- bool if direct VPN. The detection is realised by searching the fastd network interface inside the originator table
|
||||||
function M.directVPN(vpnIfaceList)
|
function M.directVPN()
|
||||||
for _,vpnIface in ipairs(vpnIfaceList) do
|
|
||||||
local file = io.open("/sys/kernel/debug/batman_adv/bat0/originators", 'r')
|
local file = io.open("/sys/kernel/debug/batman_adv/bat0/originators", 'r')
|
||||||
if file ~= nil then
|
if file ~= nil then
|
||||||
for outgoingIF in file:lines() do
|
for outgoingIF in file:lines() do
|
||||||
-- escape special chars "[]-"
|
-- escape special chars "[]-"
|
||||||
if outgoingIF:match(string.gsub("%[ " .. vpnIface .. "%]","%-", "%%-")) then
|
if outgoingIF:match(string.gsub("%[ " .. vpn_util.get_mesh_vpn_interface() .. "%]","%-", "%%-")) then
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
local bit = require('bit')
|
local bit = require('bit')
|
||||||
local unistd = require('posix.unistd')
|
local unistd = require('posix.unistd')
|
||||||
local fcntl = require('posix.fcntl')
|
local fcntl = require('posix.fcntl')
|
||||||
local vpn_util = require('gluon.vpn-util')
|
|
||||||
local hoodutil = require('hoodselector.util')
|
local hoodutil = require('hoodselector.util')
|
||||||
|
|
||||||
-- PID file to ensure the hoodselector isn't running parallel
|
-- 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
|
-- If no hood for the location has been defined, we will select
|
||||||
-- the default hood.
|
-- the default hood.
|
||||||
-- If we can't determine the node's location, we will continue to the next mode.
|
-- 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')
|
io.stdout:write('VPN connection found.\n')
|
||||||
local geo = hoodutil.getGeolocation()
|
local geo = hoodutil.getGeolocation()
|
||||||
if geo.lat ~= nil and geo.lon ~= nil then
|
if geo.lat ~= nil and geo.lon ~= nil then
|
||||||
|
Loading…
Reference in New Issue
Block a user