gluon/package/gluon-hoodselector/check_site.lua
Jan-Tarek Butt 95566316cb gluon-hoodselector: add VPN-state and checksite
Signed-off-by: Jan-Tarek Butt <tarek@ring0.de>
2018-04-23 12:28:09 +02:00

38 lines
1.4 KiB
Lua

need_string_match(in_domain({'domain_seed'}), '^' .. ('%x'):rep(64) .. '$')
function need_nil(path)
need(path, function(val)
if val == nil then
return true
end
return false
end, true, "default hood should not contain shapes")
return nil
end
--Need to check if not default hood and does the default not contain shapes
if this_domain() ~= need_string(in_site({'default_domain'})) then
local no_shapes = true
for _,shape in ipairs(need_table(in_domain({'hoodselector', 'shapes'}))) do
no_shapes = false
if #shape >= 2 then
for _, pos in ipairs(shape) do
if pos.lat == nil or not ( pos.lat < 90.0 and pos.lat > -90.0 ) then
need(in_domain({'hoodselector', 'shapes'}), function(err) return false end, true, "lat muss match a rage +/-90.0")
end
if pos.lon == nil or not ( pos.lon < 180.0 and pos.lon > -180.0 ) then
need(in_domain({'hoodselector', 'shapes'}), function(err) return false end, true, "lon muss match a rage +/-180.0")
end
end
end
if #shape < 2 then
need(in_domain({'hoodselector', 'shapes'}), function(err) return false end, true, "needs to have at lease 2 coordiantes for rectangular shapes.")
end
end
if no_shapes then
need(in_domain({'hoodselector', 'shapes'}), function(err) return false end, true, "no shapes are defined in hoods")
end
else -- ente by default hood
need_nil(in_domain({'hoodselector', 'shapes'}))
end