gluon-hoodselector: hoodselector, use taps instead of spaces.

Signed-off-by: Jan-Tarek Butt <tarek@ring0.de>
This commit is contained in:
Jan-Tarek Butt 2019-02-09 04:51:29 +01:00
parent 4554e23b37
commit 1a8e41150b

View File

@ -10,23 +10,23 @@ local lockfile = '/var/lock/hoodselector.lock'
local lockfd, err = fcntl.open(lockfile, bit.bor(fcntl.O_WRONLY, fcntl.O_CREAT), 384) -- mode 0600
if not lockfd then
hoodutil.log(err, '\n')
os.exit(1)
hoodutil.log(err, '\n')
os.exit(1)
end
local ok, _ = fcntl.fcntl(lockfd, fcntl.F_SETLK, {
l_start = 0,
l_len = 0,
l_type = fcntl.F_WRLCK,
l_whence = unistd.SEEK_SET,
l_start = 0,
l_len = 0,
l_type = fcntl.F_WRLCK,
l_whence = unistd.SEEK_SET,
})
if not ok then
io.stderr:write(string.format(
"Unable to lock file %s. Make sure there is no other instance of the hoodselector running.\n",
lockfile
))
os.exit(1)
io.stderr:write(string.format(
"Unable to lock file %s. Make sure there is no other instance of the hoodselector running.\n",
lockfile
))
os.exit(1)
end
-- VPN MODE
@ -36,31 +36,31 @@ end
-- the default hood.
-- If we can't determine the node's location, we will continue to the next mode.
if hoodutil.direct_vpn() then
io.stdout:write('VPN connection found.\n')
local geo = hoodutil.get_geolocation()
if geo.lat ~= nil and geo.lon ~= nil then
io.stdout:write('Position found.\n')
local jhood = hoodutil.get_domains()
local geo_hood = hoodutil.get_hood_by_geo(jhood, geo)
if geo_hood ~= nil then
if hoodutil.set_hoodconfig(geo_hood) then
hoodutil.restart_services()
hoodutil.log('Domain set by VPN mode.\n')
end
return
end
io.stdout:write('No domain has been defined for the current position.\n')
if hoodutil.set_hoodconfig(hoodutil.get_default_hood(jhood)) then
hoodutil.restart_services()
hoodutil.log('Domain set by VPN mode.\n')
end
return
else
-- The hoodselector should continue with the next states because there can be other
-- VPN nodes in the local mesh network which provide a position and therefore
-- have set a geo base hood.
io.stdout:write('No position found\n')
end
io.stdout:write('VPN connection found.\n')
local geo = hoodutil.get_geolocation()
if geo.lat ~= nil and geo.lon ~= nil then
io.stdout:write('Position found.\n')
local jhood = hoodutil.get_domains()
local geo_hood = hoodutil.get_hood_by_geo(jhood, geo)
if geo_hood ~= nil then
if hoodutil.set_hoodconfig(geo_hood) then
hoodutil.restart_services()
hoodutil.log('Domain set by VPN mode.\n')
end
return
end
io.stdout:write('No domain has been defined for the current position.\n')
if hoodutil.set_hoodconfig(hoodutil.get_default_hood(jhood)) then
hoodutil.restart_services()
hoodutil.log('Domain set by VPN mode.\n')
end
return
else
-- The hoodselector should continue with the next states because there can be other
-- VPN nodes in the local mesh network which provide a position and therefore
-- have set a geo base hood.
io.stdout:write('No position found\n')
end
else
io.stdout:write('No VPN connection found\n')
io.stdout:write('No VPN connection found\n')
end