Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • ffnw-firmware/siteconf
  • pic/siteconf
  • PowerPan/siteconf
  • netmon-sc/siteconf
  • floh1111/siteconf
  • lrnzo/siteconf
  • florian.lottes/siteconf
7 results
Show changes
From 886bd0ad1b4d401452e207966e88630c55e2ebd6 Mon Sep 17 00:00:00 2001
From: Jan-Tarek Butt <tarek@ring0.de>
Date: Fri, 28 Jul 2017 02:41:30 +0200
Subject: [PATCH 3/5] add pkg gluon-geolocator
From 28944a798cdd929f3b87f18112fcf7b3c2c4c442 Mon Sep 17 00:00:00 2001
From: runner01 <runner01@ffnw.de>
Date: Fri, 8 Feb 2019 04:43:50 +0100
Subject: [PATCH 1/4] add gluon-geolocator
* add check_site.lua
* add config geolocator
* add geolocator.sh
* add cron file
* add upgrade script for intervall
* mv to 540-geolocator-settings
* add 540-geolocator-settings
* add luaminifyer
* change check_site.lua
* rm ffnw spec stuff and add site array to geolocator.sh
* change lua require
* change lua require 'gluon.site_config' to 'gluon.site'
* clean up cron file
- rm unneded semicolon
- remove the sh
* use taps and chang val type in check_site.lua
- set geolocator.autolocation as need_boolean
- replace spaces with taps
* geolocator.sh replace spaces with taps
* geolocator.sh rm unneeded ;
* geolocator.sh use if/fi instead of {}
* upgrade script prepare for new site file
* rm geolocator.sh
* porting from shell to lua code
* rm .sh file ending
* fix line endings and write mode
* set uci getbool fix scan for surrounded wifis
* rm TODO commend after discussion wiht Neoraider
* refactoring and spellcheck
- rm irrelevant else states
- fix print message for time stamp file
* fix intervall in 540-geolocator-settings
- change intervall value from seconds to minutes
* ensure MAC addreses are filert by uppercase matching
---
package/gluon-geolocator/Makefile | 36 ++++++
package/gluon-geolocator/check_site.lua | 5 +
.../gluon-geolocator/files/etc/config/geolocator | 2 +
.../files/usr/lib/micron.d/geolocator | 1 +
.../luasrc/lib/gluon/geolocator/geolocator | 135 +++++++++++++++++++++
.../lib/gluon/upgrade/540-geolocator-settings | 38 ++++++
6 files changed, 217 insertions(+)
package/gluon-geolocator/Makefile | 14 ++
package/gluon-geolocator/check_site.lua | 2 +
.../files/etc/config/geolocator | 2 +
.../files/usr/lib/micron.d/geolocator | 1 +
.../luasrc/lib/gluon/geolocator/geolocator | 130 ++++++++++++++++++
.../lib/gluon/upgrade/540-geolocator-settings | 26 ++++
6 files changed, 175 insertions(+)
create mode 100644 package/gluon-geolocator/Makefile
create mode 100644 package/gluon-geolocator/check_site.lua
create mode 100644 package/gluon-geolocator/files/etc/config/geolocator
......@@ -54,67 +20,40 @@ Subject: [PATCH 3/5] add pkg gluon-geolocator
diff --git a/package/gluon-geolocator/Makefile b/package/gluon-geolocator/Makefile
new file mode 100644
index 00000000..3896ae70
index 00000000..54dd3002
--- /dev/null
+++ b/package/gluon-geolocator/Makefile
@@ -0,0 +1,36 @@
@@ -0,0 +1,14 @@
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=gluon-geolocator
+PKG_VERSION:=1
+PKG_RELEASE:=1
+
+PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
+
+include ../gluon.mk
+
+define Package/gluon-geolocator
+ SECTION:=gluon
+ CATEGORY:=Gluon
+ TITLE:=Provide the geolocator to receive positions over wifi
+ DEPENDS:=+gluon-node-info +micrond
+endef
+
+define Build/Prepare
+ mkdir -p $(PKG_BUILD_DIR)
+ DEPENDS:=+gluon-node-info +micrond +lua-bit32
+endef
+
+define Build/Compile
+ $(call GluonSrcDiet,./luasrc,$(PKG_BUILD_DIR)/luadest/)
+endef
+
+define Package/gluon-geolocator/install
+ $(CP) ./files/* $(1)/
+ $(CP) $(PKG_BUILD_DIR)/luadest/* $(1)/
+endef
+
+define Package/gluon-geolocator/postinst
+#!/bin/sh
+$(call GluonCheckSite,check_site.lua)
+endef
+
+$(eval $(call BuildPackage,gluon-geolocator))
+$(eval $(call BuildPackageGluon,gluon-geolocator))
diff --git a/package/gluon-geolocator/check_site.lua b/package/gluon-geolocator/check_site.lua
new file mode 100644
index 00000000..3fb49cd8
index 00000000..2771d938
--- /dev/null
+++ b/package/gluon-geolocator/check_site.lua
@@ -0,0 +1,5 @@
+if need_table('geolocator', nil, false) then
+ need_boolean('geolocator.autolocation', false)
+ need_number('geolocator.interval', false)
+ need_string_array_match('geolocator.blacklist', '^%w+:%w+:%w+:%w+:%w+:%w+$', false)
+end
@@ -0,0 +1,2 @@
+need_boolean(in_site({'geolocator', 'autolocation'}), false)
+need_number(in_site({'geolocator', 'interval'}), false)
diff --git a/package/gluon-geolocator/files/etc/config/geolocator b/package/gluon-geolocator/files/etc/config/geolocator
new file mode 100644
index 00000000..aed88cce
--- /dev/null
+++ b/package/gluon-geolocator/files/etc/config/geolocator
@@ -0,0 +1,4 @@
@@ -0,0 +1,2 @@
+config geolocator 'settings'
+ option static_location '0'
+ option auto_location '1'
+ option refresh_interval '1000'
diff --git a/package/gluon-geolocator/files/usr/lib/micron.d/geolocator b/package/gluon-geolocator/files/usr/lib/micron.d/geolocator
new file mode 100644
index 00000000..7379b730
......@@ -124,130 +63,125 @@ index 00000000..7379b730
+*/5 * * * * /lib/gluon/geolocator/geolocator
diff --git a/package/gluon-geolocator/luasrc/lib/gluon/geolocator/geolocator b/package/gluon-geolocator/luasrc/lib/gluon/geolocator/geolocator
new file mode 100755
index 00000000..1a08ccf2
index 00000000..3ec5771c
--- /dev/null
+++ b/package/gluon-geolocator/luasrc/lib/gluon/geolocator/geolocator
@@ -0,0 +1,135 @@
@@ -0,0 +1,130 @@
+#!/usr/bin/lua
+
+local bit = require('bit32')
+local unistd = require('posix.unistd')
+local fcntl = require('posix.fcntl')
+local uci = require('simple-uci').cursor()
+local json = require ("luci.jsonc")
+require("iwinfo")
+local json = require ("jsonc")
+local ubus = require 'ubus'
+local iwinfo = require("iwinfo")
+
+local LOC="gluon-node-info"
+local GLC="geolocator"
+local TIME_STAMP="/tmp/geolocator_timestamp"
+
+if not uci:get_bool(GLC, "settings", "auto_location") then
+ os.exit(0)
+end
+
+-- PID file to ensure the geolocator isn't running parallel
+local PID_PART="/var/run/geolocator.pid"
+local TIME_STAMP="/tmp/geolocator_timestamp"
+
+local function file_exsist(file)
+ return io.open(file, "r") ~= nil
+end
+local lockfile = '/var/lock/geolocator.lock'
+local lockfd, err = fcntl.open(lockfile, bit.bor(fcntl.O_WRONLY, fcntl.O_CREAT), 384) -- mode 0600
+
+if file_exsist(PID_PART) then
+ io.stdout:write("The geolocator is still running.\n")
+ os.exit(0)
+end
+if io.open(PID_PART, "w") == nil then
+ io.stdout:write("Can`t create pid file on " .. PID_PART .. "\n")
+if not lockfd then
+ io.stderr:write(err, '\n')
+ os.exit(1)
+end
+
+-- Program terminating function including removing of PID file
+local function exit(exc)
+ if file_exsist(PID_PART) then
+ os.remove(PID_PART)
+ end
+ os.exit(exc)
+local ok, _ = fcntl.fcntl(lockfd, fcntl.F_SETLK, {
+ 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 geolocator running.\n",
+ lockfile
+ ))
+ os.exit(1)
+end
+
+local function table_contains(tbl, prefix)
+ for _, entry in ipairs(tbl) do
+ if entry:match(prefix) then
+ return true
+-- Iterates over all active WLAN interfaces
+-- Returning true from the callback function will skip all remaining
+-- interfaces of the same radio
+local function foreach_radio(f)
+ local uconn = assert(ubus.connect(), 'failed to connect to ubus')
+ local status = uconn:call('network.wireless', 'status', {})
+ ubus.close(uconn)
+
+ for _, radio in pairs(status) do
+ for _, iface in ipairs(radio.interfaces) do
+ if f(iface.ifname) then
+ break
+ end
+ end
+ end
+ return false
+end
+
+local function getWifiifnames()
+ local ifnames = {}
+ uci:foreach('wireless', 'wifi-iface',
+ function(s)
+ local ifname = uci:get('wireless', s['.name'], 'ifname')
+ if (ifname ~= nil) then
+ table.insert(ifnames, ifname)
+ end
+ end
+ )
+ return ifnames
+local function receive_json(request)
+ local f = assert(io.popen(string.format("exec wget -T 15 -q -O- '%s'", request)), 'failed to run wget')
+ local data = f:read('*a')
+ f:close()
+
+ return json.parse(data)
+end
+
+-- Get position
+local function Get_geolocation_info()
+
+ -- Get list of BSSID there should ignored
+ local blacklist_bssid = { }
+ for _, bl_bssid in ipairs(uci:get(GLC, "settings", "blacklist")) do
+ -- Ensure rm colons and uppercase
+ table.insert(blacklist_bssid,(string.upper(bl_bssid):gsub(":", "")))
+ end
+local function locate()
+ local done_bssids = {}
+ local found_bssids = {}
+ foreach_radio(function(ifname)
+ local iw = iwinfo[iwinfo.type(ifname)]
+ if not iw then
+ -- Skip other ifaces of this radio, as they
+ -- will have the same type
+ return true
+ end
+
+ local scaned_bssid = ""
+ local uniq = { }
+ for _, ifname in ipairs(getWifiifnames()) do
+ local api = iwinfo.type(ifname)
+ if api then
+ local iw = iwinfo[api]
+ local scanlist = iw.scanlist(ifname)
+ if not scanlist then
+ return false
+ end
+
+ -- Get list of BSSID without blacklisted and redundancy entrys.
+ for _, net in ipairs(iw.scanlist(ifname) or { }) do
+ -- Ensure rm colons and uppercase
+ net.bssid = string.upper(net.bssid:gsub(":", ""))
+ if not uniq[net.bssid] and not table_contains(blacklist_bssid, net.bssid) then
+ scaned_bssid = scaned_bssid .. "," .. net.bssid
+ uniq[net.bssid] = true
+ for _, entry in ipairs(scanlist) do
+ if entry.mode:match("Master") then
+ local bssid = string.upper(entry.bssid:gsub(":", ""))
+ if not done_bssids[bssid] then
+ table.insert(found_bssids, bssid)
+ done_bssids[bssid] = true
+ end
+ end
+ if #scaned_bssid < 12 then
+ io.stdout:write("No surrounded BSSIDs found.\n")
+ return { }
+ end
+ scaned_bssid = scaned_bssid:gsub("^,(.-),*", "%1")
+ end
+ end
+ -- Request position
+ local req = io.popen("wget -T 15 -q -O - http://openwifi.su/api/v1/bssids/" .. scaned_bssid)
+ if not req then
+ io.stdout:write("connection failed.\n")
+ return { }
+ end
+
+ local jreq, _, err = json.parse(req:read("*a"), 1, nil)
+ req:close()
+ if err or jreq == nil or jreq.lon == nil or jreq.lat == nil then
+ io.stdout:write("openwifi.su doesn't gif a location.\n")
+ return { }
+ end
+ return true
+ end)
+
+ assert(#found_bssids > 0, 'insufficient BSSIDs found')
+
+ local data = receive_json('http://openwifi.su/api/v1/bssids/' .. table.concat(found_bssids, ','))
+ assert(type(data) == 'table' and data.lon and data.lat, 'location not available')
+
+ return jreq
+end -- end Get_geolocation_info()
+ return data
+end
+
+-- Check if interval over or not exist
+if file_exsist(TIME_STAMP) then
+if io.open(TIME_STAMP) ~= nil then
+ if os.time() - tonumber(io.open(TIME_STAMP):read("*a")) < uci:get(GLC, "settings", "refresh_interval") * 60 then
+ exit(0)
+ os.exit(0)
+ end
+end
+
+local pos = Get_geolocation_info()
+local pos = locate()
+if not next(pos) then
+ exit(1)
+ os.exit(1)
+end
+if not uci:get_bool(GLC, "settings", "static_location") then
+ uci:set(LOC, uci:get_first(LOC, 'location'), 'latitude', pos.lat)
......@@ -259,19 +193,19 @@ index 00000000..1a08ccf2
+if timestap ~= nil then
+ timestap:write(os.time())
+ timestap:close()
+ exit(0)
+ os.exit(0)
+end
+io.stdout:write("Can`t create file on " .. TIME_STAMP .. "\n")
+exit(1)
+os.exit(1)
diff --git a/package/gluon-geolocator/luasrc/lib/gluon/upgrade/540-geolocator-settings b/package/gluon-geolocator/luasrc/lib/gluon/upgrade/540-geolocator-settings
new file mode 100755
index 00000000..6f17e8c3
index 00000000..84c9f99c
--- /dev/null
+++ b/package/gluon-geolocator/luasrc/lib/gluon/upgrade/540-geolocator-settings
@@ -0,0 +1,38 @@
@@ -0,0 +1,26 @@
+#!/usr/bin/lua
+
+local site = require 'gluon.site_config'
+local site = require 'gluon.site'
+local uci = require('simple-uci').cursor()
+
+local config = 'geolocator'
......@@ -280,23 +214,12 @@ index 00000000..6f17e8c3
+
+local auto_location = uci:get(config, 'settings', 'auto_location')
+if not auto_location then
+ auto_location = 0
+ if site.geolocator.autolocation then
+ auto_location = tonumber(site.geolocator.autolocation)
+ end
+ auto_location = site.geolocator.autolocation(false)
+end
+
+local refresh_interval = uci:get(config, 'settings', 'refresh_interval')
+if not refresh_interval then
+ refresh_interval = 720 -- default: 12h
+ if site.config_mode.location.interval then
+ refresh_interval = site.geolocator.interval
+ end
+end
+
+local blacklist = {}
+if site.geolocator.blacklist then
+ blacklist = site.geolocator.blacklist
+ refresh_interval = site.geolocator.interval(720) -- default: 12h
+end
+
+uci:delete(config, 'settings')
......@@ -304,9 +227,8 @@ index 00000000..6f17e8c3
+ static_location = static_location,
+ refresh_interval = refresh_interval,
+ auto_location = auto_location,
+ blacklist = blacklist,
+})
+uci:save(config)
--
2.16.1
2.20.1
From 2993f96b2b3eddd0f401a45982ce65b128e71223 Mon Sep 17 00:00:00 2001
From 71bcf5add0180cda356f6c9ce69e2a676e4daba6 Mon Sep 17 00:00:00 2001
From: Jan-Tarek Butt <tarek@ring0.de>
Date: Sun, 25 Feb 2018 08:42:42 +0100
Subject: [PATCH 6/6] ffnw config migration from gluon-node-info to geolocator
Subject: [PATCH 2/4] ffnw config migration from gluon-node-info to geolocator
Signed-off-by: Jan-Tarek Butt <tarek@ring0.de>
---
.../luasrc/lib/gluon/upgrade/900-geloc-conf-migration | 17 +++++++++++++++++
.../lib/gluon/upgrade/900-geloc-conf-migration | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
create mode 100755 package/gluon-geolocator/luasrc/lib/gluon/upgrade/900-geloc-conf-migration
......@@ -33,5 +33,5 @@ index 00000000..6bfb1059
+ uci:save('geolocator')
+end
--
2.16.2
2.20.1
From a273489a54d14454e6e53af94ab479b7c72f74d2 Mon Sep 17 00:00:00 2001
From: runner01 <runner01@ffnw.de>
Date: Mon, 18 Mar 2019 21:29:26 +0100
Subject: [PATCH 3/4] hoodselector to domain migration
Domain migration: restart services after migration
Signed-off-by: runner01 <runner01@ffnw.de>
---
.../lib/gluon/upgrade/010-domain-migrate | 38 +++++++++++++++++++
1 file changed, 38 insertions(+)
create mode 100755 package/gluon-hoodselector/luasrc/lib/gluon/upgrade/010-domain-migrate
diff --git a/package/gluon-hoodselector/luasrc/lib/gluon/upgrade/010-domain-migrate b/package/gluon-hoodselector/luasrc/lib/gluon/upgrade/010-domain-migrate
new file mode 100755
index 00000000..9146970b
--- /dev/null
+++ b/package/gluon-hoodselector/luasrc/lib/gluon/upgrade/010-domain-migrate
@@ -0,0 +1,38 @@
+#!/usr/bin/lua
+
+local uci = require('simple-uci').cursor()
+local hoodutil = require('hoodselector.util')
+
+local last_hood = uci:get('hoodselector', 'hoodselector', 'hood')
+
+-- Return domain based on a given MESH-ID. nil if no matching domain could be found
+function get_domain_by_meshid(jdomains, meshid)
+ for _, jdomain in pairs(jdomains) do
+ if jdomain.domain.wifi24 ~= nil then
+ if jdomain.domain.wifi24.mesh ~= nil then
+ if meshid:lower() == jdomain.domain.wifi24.mesh.id:lower() then
+ return jdomain
+ end
+ end
+ end
+ if jdomain.domain.wifi5 ~= nil then
+ if jdomain.domain.wifi5.mesh ~= nil then
+ if meshid:lower() == jdomain.domain.wifi5.mesh.id:lower() then
+ return jdomain
+ end
+ end
+ end
+ end
+ return nil
+end
+
+if last_hood ~= nil then
+ print(last_hood)
+ local new_domain = get_domain_by_meshid(hoodutil.get_domains(),"ffnw-mesh_"..last_hood)
+ if new_domain ~= nil then
+ print(new_domain.domain_code)
+ hoodutil.set_domain_config(new_domain)
+ os.execute("rm /etc/config/hoodselector")
+ hoodutil.restart_services()
+ end
+end
--
2.20.1
From bfb90653c70a1f9c9573b4d0b4efc48702320f62 Mon Sep 17 00:00:00 2001
From: Jan-Tarek Butt <tarek@ring0.de>
Date: Mon, 18 Sep 2017 18:20:28 +0200
Subject: [PATCH 5/5] add pkg gluon-hoodselector
* add pkg Makefile
* add respondd c file
* add respondd Makefile
* add etc config
* add micron.d file
* add upgrade script 540-hoodselector
* add hoodselector lua script
* rm gluon-hoods and gluon-mesh-vpn-fastd from DEPENDS
* config rm static option
* backport tested comunity version:
- Hoodselector: is now able to handle Polygon hoods. !60
- Hoodselector: does not use `scan dump` anymore which
saved airtime
- Hoodselector: L2TP tunneldigger support #47
- Hoodselector: the upgrade script got a refactoring.
Dead code is removed. desing failuer is
fixed, the script use the hood BSSID
instead the possible redundant hood name
for hood identification. #107
- Hoodselector: New state, a router from hood A which is
connected to an another router from hood B
is now able to switch back in its own hood
if a router from hood A viseble. #108
- Hoodselector: in state "radio less" is now ensured that
mesh on LAN / WAN is enabled befor entering
mode. #109
- Hoodselector: A bug in the function get_mesh_if() is
fixed now. This function returns now a list
of all mesh interfaces exzept the VPN
interface #116
- Hoodselector: Old VPN configurations will be deleted now.
If a hood without VPN peers got configured
the old peers from the old hood was still
presend. #117
- Hoodselector: many functions of the hoodselector are now
placed in a lua libary. #118
---
package/gluon-hoodselector/Makefile | 43 +
.../files/etc/config/hoodselector | 3 +
.../files/usr/lib/micron.d/hoodselector | 1 +
.../luasrc/lib/gluon/upgrade/540-hoodselector | 88 ++
.../luasrc/usr/lib/lua/hoodselector/util.lua | 898 +++++++++++++++++++++
.../luasrc/usr/sbin/hoodselector | 622 ++++++++++++++
package/gluon-hoodselector/src/Makefile | 6 +
package/gluon-hoodselector/src/respondd.c | 139 ++++
8 files changed, 1800 insertions(+)
create mode 100644 package/gluon-hoodselector/Makefile
create mode 100644 package/gluon-hoodselector/files/etc/config/hoodselector
create mode 100644 package/gluon-hoodselector/files/usr/lib/micron.d/hoodselector
create mode 100755 package/gluon-hoodselector/luasrc/lib/gluon/upgrade/540-hoodselector
create mode 100644 package/gluon-hoodselector/luasrc/usr/lib/lua/hoodselector/util.lua
create mode 100755 package/gluon-hoodselector/luasrc/usr/sbin/hoodselector
create mode 100644 package/gluon-hoodselector/src/Makefile
create mode 100644 package/gluon-hoodselector/src/respondd.c
diff --git a/package/gluon-hoodselector/Makefile b/package/gluon-hoodselector/Makefile
new file mode 100644
index 00000000..210e5200
--- /dev/null
+++ b/package/gluon-hoodselector/Makefile
@@ -0,0 +1,43 @@
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=gluon-hoodselector
+PKG_VERSION:=1
+PKG_RELEASE:=1
+
+PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
+PKG_BUILD_DEPENDS := respondd
+
+include ../gluon.mk
+
+define Package/gluon-hoodselector
+ SECTION:=network
+ CATEGORY:=Gluon
+ TITLE:=Automatic layer2 networksecmentation depending on geo coordinates
+ DEPENDS:=+luci-lib-jsonc +gluon-mesh-batman-adv-15 +respondd +iwinfo
+endef
+
+define Package/gluon-hoodselector/description
+ Automatic layer2 networksecmentation depending on geo coordinates
+endef
+
+define Build/Prepare
+ mkdir -p $(PKG_BUILD_DIR)
+ $(CP) ./src/* $(PKG_BUILD_DIR)/
+endef
+
+define Build/Configure
+endef
+
+define Build/Compile
+ $(call Build/Compile/Default)
+ $(call GluonSrcDiet,./luasrc,$(PKG_BUILD_DIR)/luadest/)
+endef
+
+define Package/gluon-hoodselector/install
+ $(CP) ./files/* $(1)/
+ $(CP) $(PKG_BUILD_DIR)/luadest/* $(1)/
+ $(INSTALL_DIR) $(1)/lib/gluon/respondd
+ $(CP) $(PKG_BUILD_DIR)/respondd.so $(1)/lib/gluon/respondd/hoodselector.so
+endef
+
+$(eval $(call BuildPackage,gluon-hoodselector))
diff --git a/package/gluon-hoodselector/files/etc/config/hoodselector b/package/gluon-hoodselector/files/etc/config/hoodselector
new file mode 100644
index 00000000..24b2800c
--- /dev/null
+++ b/package/gluon-hoodselector/files/etc/config/hoodselector
@@ -0,0 +1,3 @@
+config settings 'hoodselector'
+ option hoodfile '/lib/gluon/hoods.json'
+ option enabled '1'
diff --git a/package/gluon-hoodselector/files/usr/lib/micron.d/hoodselector b/package/gluon-hoodselector/files/usr/lib/micron.d/hoodselector
new file mode 100644
index 00000000..a4c9916d
--- /dev/null
+++ b/package/gluon-hoodselector/files/usr/lib/micron.d/hoodselector
@@ -0,0 +1 @@
+*/2 * * * * /usr/sbin/hoodselector 2>> /tmp/hoodselector_error
diff --git a/package/gluon-hoodselector/luasrc/lib/gluon/upgrade/540-hoodselector b/package/gluon-hoodselector/luasrc/lib/gluon/upgrade/540-hoodselector
new file mode 100755
index 00000000..a0fe8d65
--- /dev/null
+++ b/package/gluon-hoodselector/luasrc/lib/gluon/upgrade/540-hoodselector
@@ -0,0 +1,88 @@
+#!/usr/bin/lua
+
+local uci = require('simple-uci').cursor()
+local hoodutil = require("hoodselector.util")
+
+-- Retun a table of current peers from /etc/config/fastd
+local function getCurrentPeers()
+ local configPeers = {}
+ local err = uci:foreach('fastd', 'peer',
+ function(s)
+ hoodutil.extrac_fastd_peer(s,configPeers)
+ end
+ )
+ if not err then
+ os.exit(1)
+ end
+ return configPeers
+end
+
+-- START HERE
+local hoodfile = uci:get('hoodselector', 'hoodselector', 'hoodfile')
+local hoodbssid = uci:get('hoodselector', 'hoodselector', 'hood')
+
+if hoodfile == nil then
+ os.exit(1)
+end
+
+local jhood = hoodutil.readHoodfile(hoodfile)
+if jhood == nil then
+ uci:set('hoodselector', 'hoodselector', 'enabled', false)
+ uci:save('hoodselector')
+ os.exit(1)
+end
+
+if hoodbssid == nil then
+ local defaulthood = hoodutil.getDefaultHood(jhood)
+ if defaulthood == nil then
+ os.exit(1)
+ end
+ if defaulthood.bssid == nil then
+ os.exit(1)
+ end
+ hoodbssid = defaulthood.bssid
+end
+
+local hood = hoodutil.gethoodByBssid(jhood,hoodbssid)
+if hood == nil then
+ os.exit(1)
+end
+
+uci:section('hoodselector', 'settings', 'hoodselector', {
+ hood = hoodbssid,
+ hoodfile = hoodfile,
+ enabled = true
+})
+uci:save('hoodselector')
+
+local radios = hoodutil.getWifiDevices()
+-- pre check if fastd conf exsist
+if uci:get('fastd', 'mesh_vpn_backbone', 'net') ~= nil then
+ hoodutil.fastd_reconfigure(hood["servers"],getCurrentPeers())
+end
+-- per check if tunneldigger conf exsist
+if uci:get('tunneldigger', 'mesh_vpn', 'interface') ~= nil then
+ hoodutil.tunneldigger_reconfigure(hood["servers"])
+end
+
+if next(radios) then
+ local ibss_exists = false
+ local mesh_exists = false
+ for _,radio in ipairs(radios) do
+ local ifname = uci:get('wireless', 'ibss_' .. radio, 'ifname')
+ if (ifname ~= nil) then
+ ibss_exists = true
+ end
+ ifname = uci:get('wireless', 'mesh_' .. radio, 'ifname')
+ if (ifname ~= nil) then
+ mesh_exists = true
+ end
+ end
+ if ibss_exists then
+ hoodutil.ibss_reconfigure(radios, hood["bssid"])
+ end
+ if mesh_exists then
+ local mesh_prefix = hoodutil.get_mesh_prefix(radios)
+ hoodutil.mesh_reconfigure(radios, mesh_prefix..hood["bssid"]:lower())
+ end
+end
diff --git a/package/gluon-hoodselector/luasrc/usr/lib/lua/hoodselector/util.lua b/package/gluon-hoodselector/luasrc/usr/lib/lua/hoodselector/util.lua
new file mode 100644
index 00000000..05678809
--- /dev/null
+++ b/package/gluon-hoodselector/luasrc/usr/lib/lua/hoodselector/util.lua
@@ -0,0 +1,898 @@
+local json = require ("luci.jsonc")
+local uci = require('simple-uci').cursor()
+
+local M = {}
+
+function M.split(s, delimiter)
+ local result = {};
+ for match in (s..delimiter):gmatch("(.-)"..delimiter) do
+ table.insert(result, match);
+ end
+ return result;
+end
+
+local PID = M.split(io.open("/proc/self/stat", 'r'):read('*a'), " ")[1]
+
+function M.log(msg)
+ if msg then
+ io.stdout:write(msg.."\n")
+ os.execute("logger hoodselector["..PID.."]: "..msg)
+ end
+end
+
+-- Read the full hoodfile. Return nil for wrong format or no such file
+function M.readHoodfile(file)
+ local jhood = io.open(file, 'r')
+ if not jhood then return nil end
+ local obj, _, err = json.parse (jhood:read('*a'), 1, nil)
+ if err then
+ return nil
+ else
+ return obj
+ end
+end
+
+function M.mesh_on_wan_disable()
+ os.execute('ifdown mesh_wan')
+ io.stdout:write('Interface mesh_wan disabled.\n')
+end
+
+function M.mesh_on_wan_enable()
+ os.execute('ifup mesh_wan')
+ io.stdout:write('Interface mesh_wan enabled.\n')
+end
+
+function M.mesh_on_lan_disable()
+ os.execute('ifdown mesh_lan')
+ io.stdout:write('Interface mesh_lan disabled.\n')
+end
+
+function M.mesh_on_lan_enable()
+ os.execute('ifup mesh_lan')
+ io.stdout:write('Interface mesh_lan enabled.\n')
+end
+
+function M.fastd_installed()
+ if io.open("/usr/bin/fastd", 'r') ~= nil then
+ return true
+ end
+ return false
+end
+
+function M.tunneldigger_installed()
+ if io.open("/usr/bin/tunneldigger", 'r') ~= nil then
+ return true
+ end
+ return false
+end
+
+function M.filt_if(filt,str)
+ for _, c in ipairs(filt) do
+ -- check if - is contains because it is a magic character thus it musst be replace)
+ if c:gsub("%-", "0"):match(str:gsub("%-", "0")) then
+ return true
+ end
+ end
+ return false
+end
+
+function M.filter_redundancy(list)
+ local flag = {}
+ local ret = {}
+ for _,element in ipairs(list) do
+ if not flag[element] then
+ ret[#ret+1] = element
+ flag[element] = true
+ end
+ end
+ return ret
+end
+
+function M.trim(s)
+ -- from PiL2 19.4
+ return (s:gsub("^%s*(.-)%s*$", "%1"))
+end
+
+function M.sleep(n)
+ os.execute("sleep " .. tonumber(n))
+end
+
+function M.brclient_restart()
+ os.execute('ifconfig br-client down')
+ os.execute('ifconfig br-client up')
+ io.stdout:write('Interface br-client restarted.\n')
+end
+
+function M.vpn_stop()
+ -- check if fastd installed
+ if M.fastd_installed() then
+ if uci:get_bool('fastd','mesh_vpn','enabled') then
+ os.execute('/etc/init.d/fastd stop')
+ io.stdout:write('Fastd stoped.\n')
+ end
+ end
+ -- check if tunneldigger installed
+ if M.tunneldigger_installed() then
+ if uci:get_bool('tunneldigger','mesh_vpn','enabled') then
+ os.execute('/etc/init.d/tunneldigger stop')
+ io.stdout:write('Tunneldigger stoped.\n')
+ end
+ end
+end
+
+function M.vpn_start()
+ if M.fastd_installed() then
+ if uci:get_bool('fastd','mesh_vpn','enabled') then
+ os.execute('/etc/init.d/fastd start')
+ io.stdout:write('Fastd started.\n')
+ end
+ end
+ if M.tunneldigger_installed() then
+ if uci:get_bool('tunneldigger','mesh_vpn','enabled') then
+ os.execute('/etc/init.d/tunneldigger start')
+ io.stdout:write('Tunneldigger started.\n')
+ end
+ end
+ M.brclient_restart()
+end
+
+function M.vpn_disable()
+ if M.fastd_installed() then
+ if uci:get_bool('fastd','mesh_vpn','enabled') then
+ os.execute('/etc/init.d/fastd disable')
+ io.stdout:write('Fastd disabled.\n')
+ end
+ end
+ if M.tunneldigger_installed() then
+ if uci:get_bool('tunneldigger','mesh_vpn','enabled') then
+ os.execute('/etc/init.d/tunneldigger disable')
+ io.stdout:write('Tunneldigger disabled.\n')
+ end
+ end
+end
+
+function M.vpn_enable()
+ if M.fastd_installed() then
+ if not uci:get_bool('fastd','mesh_vpn','enabled') then
+ os.execute('/etc/init.d/fastd enable')
+ io.stdout:write('Fastd enabled.\n')
+ end
+ end
+ if M.tunneldigger_installed() then
+ if not uci:get_bool('tunneldigger','mesh_vpn','enabled') then
+ os.execute('/etc/init.d/tunneldigger enable')
+ io.stdout:write('Tunneldigger enabled.\n')
+ end
+ end
+end
+
+function M.wireless_restart()
+ os.execute('wifi')
+ io.stdout:write('Wireless restarted.\n')
+end
+
+-- Get a list of wifi devices return an emty table for no divices
+function M.getWifiDevices()
+ local radios = {}
+ uci:foreach('wireless', 'wifi-device',
+ function(s)
+ table.insert(radios, s['.name'])
+ end
+ )
+ return radios
+end
+
+-- get signal strength
+function M.scan_filter_quality(scan_str, redirect)
+ local tmp_quality = redirect
+ if scan_str:match("signal:") then
+ tmp_quality = M.split(scan_str, " ")
+ tmp_quality = M.split(tmp_quality[2], "%.")
+ if tmp_quality[1]:match("-") then
+ tmp_quality = M.split(tmp_quality[1], "-")
+ end
+ tmp_quality = tonumber(tmp_quality[2]:match("(%d%d)"))
+ end
+ return tmp_quality
+end
+
+-- get frequency
+function M.scan_filter_frequency(scan_str, redirect)
+ local tmp_frequency = redirect
+ if scan_str:match("freq") then
+ tmp_frequency = M.split(scan_str, ":")
+ tmp_frequency = tmp_frequency[2]
+ if tmp_frequency ~= nil then
+ tmp_frequency = M.trim(tmp_frequency)
+ end
+ end
+ return tmp_frequency
+end
+
+function M.ibss_scan(radio,ifname,ssid,networks)
+ local wireless_scan = string.format( "iw %s scan", ifname)
+ local row = {}
+ row["radio"] = radio
+ -- loop through each line in the output of iw
+ for wifiscan in io.popen(wireless_scan, 'r'):lines() do
+ -- the following line matches a new network in the output of iw
+ if(row["bssid"] ~= nil and row["quality"] ~= nil and row["ssid"] == ssid) then
+ table.insert(networks, row)
+ row = {}
+ row["radio"] = radio
+ end
+
+ -- get ssid
+ if wifiscan:match("SSID:") then
+ row["ssid"] = M.split(wifiscan, ":")
+ row["ssid"] = row["ssid"][2]
+ if(row["ssid"] ~= nil) then
+ row["ssid"] = M.trim(row["ssid"])
+ end
+ end
+ row["frequency"] = M.scan_filter_frequency(wifiscan, row["frequency"])
+
+ -- get bssid
+ if wifiscan:match("(%w+:%w+:%w+:%w+:%w+:%w+)") then
+ row["bssid"] = wifiscan:match("(%w+:%w+:%w+:%w+:%w+:%w+)")
+ end
+ row["quality"] = M.scan_filter_quality(wifiscan, row["quality"])
+ end
+ return networks
+end
+
+function M.mesh_scan(radio,ifname,meshid,networks)
+ local wireless_scan = string.format( "iw %s scan", ifname)
+ local row = {}
+ row["radio"] = radio
+ -- loop through each line in the output of iw
+ for wifiscan in io.popen(wireless_scan, 'r'):lines() do
+ -- the following line matches a new network in the output of iw
+ if(row["bssid"] ~= nil and row["quality"] ~= nil and row["ssid"] == meshid) then
+ table.insert(networks, row)
+ row = {}
+ row["radio"] = radio
+ end
+ row["frequency"] = M.scan_filter_frequency(wifiscan, row["frequency"])
+ row["quality"] = M.scan_filter_quality(wifiscan, row["quality"])
+
+ -- get mesh-ID(ssid) and hoodbssid
+ if wifiscan:match("MESH ID:") then
+ local meshID = M.split(wifiscan, " ")[3]
+ if meshID ~= nil then
+ meshID = M.split(meshID, "_")
+ if meshID[1] ~= nil then
+ row["ssid"] = meshID[1].."_"
+ end
+ if meshID[2] ~= nil then
+ if meshID[2]:match("(%w+:%w+:%w+:%w+:%w+:%w+)") then
+ row["bssid"] = meshID[2]:match("(%w+:%w+:%w+:%w+:%w+:%w+)")
+ end
+ end
+ end
+ end
+ end
+ return networks
+end
+
+-- Scans for wireless networks and returns a two dimensional array containing
+-- wireless mesh neighbour networks and their properties.
+-- The array is sorted descending by signal strength (strongest signal
+-- first, usually the local signal of the wireless chip of the router)
+function M.wlan_list_sorted(radios, mesh_prefix)
+ local networks = {}
+ for _, radio in ipairs(radios) do
+ local ifname = uci:get('wireless', 'ibss_' .. radio, 'ifname')
+ local ssid = uci:get('wireless', 'ibss_' .. radio, 'ssid')
+ if (ifname ~= nil and ssid ~= nil) then
+ --do ibss scan
+ networks = M.ibss_scan(radio,ifname,ssid,networks)
+ end
+ ifname = uci:get('wireless', 'mesh_' .. radio, 'ifname')
+ if (ifname ~= nil and mesh_prefix ~= nil) then
+ --do mesh scan
+ networks = M.mesh_scan(radio,ifname,mesh_prefix,networks)
+ end
+ end
+ table.sort(networks, function(a,b) return a["quality"] < b["quality"] end)
+ return networks
+end
+
+-- this method removes the wireless network of the router itself
+-- from the wlan_list
+function M.filter_my_wlan_network(wlan_list)
+ for i=#wlan_list,1,-1 do
+ local bssid = uci:get('wireless', 'ibss_' .. wlan_list[i].radio, 'bssid')
+ if bssid ~= nil then
+ if string.lower(wlan_list[i].bssid) == string.lower(bssid) then
+ table.remove(wlan_list, i)
+ end
+ else
+ local mesh = uci:get('wireless', 'mesh_' .. wlan_list[i].radio, 'mesh_id')
+ if mesh ~= nil then
+ if string.lower(wlan_list[i].ssid..wlan_list[i].bssid) == string.lower(mesh) then
+ table.remove(wlan_list, i)
+ end
+ end
+ end
+ end
+ return wlan_list
+end
+
+function M.filter_default_hood_wlan_networks(default_hood, wlan_list)
+ for i=#wlan_list,1,-1 do
+ if(string.lower(default_hood.bssid) == string.lower(wlan_list[i].bssid)) then
+ table.remove(wlan_list, i)
+ end
+ end
+ return wlan_list
+end
+
+-- Get Geoposition. Return nil for no position
+function M.getGeolocation()
+ return {["lat"] = tonumber(uci:get('gluon-node-info', uci:get_first('gluon-node-info', 'location'), 'latitude')),
+ ["lon"] = tonumber(uci:get('gluon-node-info', uci:get_first('gluon-node-info', 'location'), 'longitude')) }
+end
+
+-- Source with pseudocode: https://de.wikipedia.org/wiki/Punkt-in-Polygon-Test_nach_Jordan
+-- see also https://en.wikipedia.org/wiki/Point_in_polygon
+-- parameters: points A = (x_A,y_A), B = (x_B,y_B), C = (x_C,y_C)
+-- return value: −1 if the ray from A to the right bisects the edge [BC] (the lower vortex of [BC]
+-- is not seen as part of [BC]);
+-- 0 if A is on [BC];
+-- +1 else
+function M.crossProdTest(x_A,y_A,x_B,y_B,x_C,y_C)
+ if y_A == y_B and y_B == y_C then
+ if (x_B <= x_A and x_A <= x_C) or (x_C <= x_A and x_A <= x_B) then
+ return 0
+ end
+ return 1
+ end
+ if not ((y_A == y_B) and (x_A == x_B)) then
+ if y_B > y_C then
+ -- swap B and C
+ local h = x_B
+ x_B = x_C
+ x_C = h
+ h = y_B
+ y_B = y_C
+ y_C = h
+ end
+ if (y_A <= y_B) or (y_A > y_C) then
+ return 1
+ end
+ local Delta = (x_B-x_A) * (y_C-y_A) - (y_B-y_A) * (x_C-x_A)
+ if Delta > 0 then
+ return 1
+ elseif Delta < 0 then
+ return -1
+ end
+ end
+ return 0
+end
+
+-- Source with pseudocode: https://de.wikipedia.org/wiki/Punkt-in-Polygon-Test_nach_Jordan
+-- see also: https://en.wikipedia.org/wiki/Point_in_polygon
+-- let P be a 2D Polygon and Q a 2D Point
+-- return value: +1 if Q within P;
+-- −1 if Q outside of P;
+-- 0 if Q on an edge of P
+function M.pointInPolygon(poly, point)
+ local t = -1
+ for i=1,#poly-1 do
+ t = t * M.crossProdTest(point.lon,point.lat,poly[i][2],poly[i][1],poly[i+1][2],poly[i+1][1])
+ if t == 0 then break end
+ end
+ return t
+end
+
+-- Return hood from the hood file based on geo position or nil if no real hood could be determined
+-- First check if an area has > 2 points and is hence a polygon. Else assume it is a rectangular
+-- box defined by two points (south-west and north-east)
+function M.getHoodByGeo(jhood,geo)
+ for _, h in pairs(jhood) do
+ for _, area in pairs(h.boxes) do
+ if #area > 2 then
+ if (M.pointInPolygon(area,geo) == 1) then
+ return h
+ end
+ else
+ if ( geo.lat >= area[1][1] and geo.lat < area[2][1] and geo.lon >= area[1][2] and geo.lon < area[2][2] ) then
+ return h
+ end
+ end
+ end
+ end
+ return nil
+end
+
+-- This method checks if the fastd configuration needs to be rewritten from the
+-- hoodfile. Therefore the method performs 3 checks and returns false if all
+-- checks fail. If one of the checks results to true the method returns true:
+-- 1. Check if the local fastd configuration has a server that does not exist
+-- in the hoodfile.
+-- 2. Check if a server that does exist in the local fastd configuration AND
+-- in the hoodfile has a configuration change.
+-- 3. Check if the hoodfile contains a server that does not exist in the
+-- local fastd configuration.
+function M.fastd_reconfiguration_needed(hood_serverlist,local_serverlist)
+
+ local tmp_hood_serverlist = {}
+ for _,hood_server in pairs(hood_serverlist) do
+ if (hood_server["type"] == "fastd") then
+ table.insert(tmp_hood_serverlist,hood_server)
+ end
+ end
+
+ -- Checks 1. and 2.
+ for local_server_config_name, local_server in pairs(local_serverlist) do
+ local local_server_exists_in_hoodfile = false
+ for _,hood_server in pairs(tmp_hood_serverlist) do
+ if (local_server_config_name == 'mesh_vpn_backbone_peer_'..
+ M.split(hood_server["host"], '.')[1]:gsub("%-", "%_") .. "_" .. hood_server['port']) then
+ local_server_exists_in_hoodfile = true
+ if ( local_server.key ~= hood_server['publickey'] ) then return true end
+ if ( local_server.remote.host ~= '\"'..hood_server["host"]..'\"' ) then return true end
+ if ( local_server.remote.port ~= hood_server['port'] ) then return true end
+ end
+ end
+ if not local_server_exists_in_hoodfile then return true end
+ end
+
+ -- Check 3.
+ for _,hood_server in pairs(tmp_hood_serverlist) do
+ local hood_server_exists_locally = false
+ for local_server_config_name, _ in pairs(local_serverlist) do
+ if (local_server_config_name == 'mesh_vpn_backbone_peer_'..
+ M.split(hood_server["host"], '.')[1]:gsub("%-", "%_") .. "_" .. hood_server['port']) then
+ hood_server_exists_locally = true
+ end
+ end
+ if not hood_server_exists_locally then return true end
+ end
+ return false
+end
+
+function M.tunneldigger_reconfiguration_needed(hood_serverlist,local_serverlist)
+
+ local tmp_hood_serverlist = {}
+ for _,hood_server in pairs(hood_serverlist) do
+ if (hood_server["type"] == "l2tp") then
+ table.insert(tmp_hood_serverlist,hood_server)
+ end
+ end
+
+ -- Checks 1. and 2.
+ for _,local_peer in pairs(local_serverlist) do
+ local local_server_exists_in_hoodfile = false
+ for _,hood_server in pairs(tmp_hood_serverlist) do
+ if (local_peer == hood_server["host"] .. ":" .. hood_server["port"]) then
+ local_server_exists_in_hoodfile = true
+ end
+ end
+ if not local_server_exists_in_hoodfile then return true end
+ end
+
+ -- Check 3.
+ for _,hood_server in pairs(tmp_hood_serverlist) do
+ local hood_server_exists_locally = false
+ for _,local_peer in pairs(local_serverlist) do
+ if (local_peer == hood_server["host"] .. ":" .. hood_server["port"]) then
+ hood_server_exists_locally = true
+ end
+ end
+ if not(hood_server_exists_locally) then return true end
+ end
+ return false
+end
+
+-- Reconfigure fastd
+function M.fastd_reconfigure(hood_serverlist,local_serverlist)
+ -- remove all servers
+ for config_index, _ in pairs(local_serverlist) do
+ uci:delete('fastd',config_index)
+ end
+
+ -- add servers from hoodfile
+ local group = 'mesh_vpn_backbone'
+ for _,hood_server in pairs(hood_serverlist) do
+ if (hood_server["type"] == "fastd") then
+ uci:section('fastd', 'peer', group .. '_peer_' ..
+ M.split(hood_server.host, '.')[1]:gsub("%-", "%_") .. "_" .. hood_server.port,
+ {
+ enabled = 1,
+ net = 'mesh_vpn',
+ group = group,
+ key = hood_server.publickey,
+ remote = {'\"'..hood_server.host..'\"'..' port '..hood_server.port}
+ }
+ )
+ end
+ end
+
+ uci:save('fastd')
+ uci:commit('fastd')
+ io.stdout:write('Fastd needed reconfiguration. Stopped and applied new settings.\n')
+end
+
+function M.tunneldigger_reconfigure(hood_serverlist)
+ -- remove all servers
+ uci:delete('tunneldigger', 'mesh_vpn', 'address')
+
+ -- add servers from hoodfile
+ local addresslist = {}
+ for _,hood_server in pairs(hood_serverlist) do
+ if (hood_server["type"] == "l2tp") then
+ local tmpAdrr =hood_server["host"] .. ":" .. hood_server["port"]
+ table.insert(addresslist, tmpAdrr)
+ end
+ end
+ if next(addresslist) then
+ uci:set('tunneldigger', 'mesh_vpn', 'address', addresslist)
+ end
+ uci:save('tunneldigger')
+ uci:commit('tunneldigger')
+ io.stdout:write('tunneldigger needed reconfiguration. Stopped and applied new settings.\n')
+end
+
+-- Checks if wireless needs a reconfiguration. Returns true if any of the checks
+-- passes. Otherwise the method returns false.
+function M.wireless_reconfiguration_needed(radios, prefix, hood_bssid)
+ local configure_ibss = false
+ local configure_mesh = false
+ for _, radio in ipairs(radios) do
+ if uci:get('wireless', 'ibss_' .. radio, 'ifname') ~= nil then
+ if ( uci:get('wireless', 'ibss_' .. radio, 'bssid') ~= hood_bssid ) then
+ configure_ibss = true
+ end
+ end
+ if uci:get('wireless', 'mesh_' .. radio, 'ifname') ~= nil then
+ if ( uci:get('wireless', 'mesh_' .. radio, 'mesh_id') ~= prefix..hood_bssid:lower() ) then
+ configure_mesh = true
+ end
+ end
+ end
+ if not configure_ibss and not configure_mesh then return 0 end --no changes
+ if configure_ibss and not configure_mesh then return 1 end --ibss changes
+ if not configure_ibss and configure_mesh then return 2 end --mesh changes
+ return 3 --bouth changes
+end
+
+-- Reconfigure wireless
+function M.ibss_reconfigure(radios, hood_bssid)
+ for _, radio in ipairs(radios) do
+ if not ( uci:get('wireless', 'ibss_' .. radio, 'bssid') == hood_bssid ) then
+ uci:section('wireless', 'wifi-iface', 'ibss_' .. radio, {bssid = hood_bssid})
+ end
+ end
+ uci:save('wireless')
+ uci:commit('wireless')
+end
+
+function M.mesh_reconfigure(radios, meshid)
+ for _, radio in ipairs(radios) do
+ if not ( uci:get('wireless', 'mesh_' .. radio, 'mesh_id') == meshid ) then
+ uci:section('wireless', 'wifi-iface', 'mesh_' .. radio, {mesh_id = meshid})
+ end
+ end
+ uci:save('wireless')
+ uci:commit('wireless')
+end
+
+-- Save selected hood to config to make a restore after a sysupgrade possible
+function M.saveHoodToConfig(hoodbssid)
+ uci:set('hoodselector', 'hoodselector', 'hood', hoodbssid)
+ uci:save('hoodselector')
+ uci:commit('hoodselector')
+end
+
+-- Return the default hood in the hood list.
+-- This method can return the following data:
+-- * default hood
+-- * nil if no default hood has been defined
+function M.getDefaultHood(jhood)
+ for _, h in pairs(jhood) do
+ if h.defaulthood then
+ return h
+ end
+ end
+ return nil
+end
+
+-- boolean check if batman-adv has gateways
+function M.batmanHasGateway()
+ local file = io.open("/sys/kernel/debug/batman_adv/bat0/gateways", 'r')
+ if file ~= nil then
+ for gw in file:lines() do
+ if gw:match("Bit") then
+ return true
+ end
+ end
+ end
+ return false
+end
+
+-- Return hood from the hood file based on a given BSSID. nil if no matching hood could be found
+function M.gethoodByBssid(jhood, scan_bssid)
+ for _, h in pairs(jhood) do
+ if scan_bssid:lower():match(h.bssid:lower()) then
+ return h
+ end
+ end
+ return nil
+end
+
+-- Return hood from hood file based on a bssid address. nil if no matching hood could be found
+function M.getCurrentHood(jhood)
+ local hoodbssid = uci:get('hoodselector', 'hoodselector', 'hood')
+ for _, h in pairs(jhood) do
+ if h.bssid == hoodbssid then
+ return h
+ end
+ end
+ return nil
+end
+
+function M.test_batman_mesh_networks(sorted_wlan_list, meshprefix)
+ -- remove the ap network because we cannot change
+ -- the settings of the adhoc network if the ap network is still operating
+ for iface in io.popen(string.format("iw dev"),'r'):lines() do
+ if iface:match("Interface") then
+ iface = M.trim(M.split(iface, "Interface")[2])
+ if not ( iface:match("ibss") or iface:match("mesh")) then
+ os.execute("iw dev "..iface.." del")
+ end
+ end
+ end
+ for _, wireless in pairs(sorted_wlan_list) do
+ local ibss = uci:get('wireless', 'ibss_' .. wireless["radio"], 'ifname')
+ local mesh = uci:get('wireless', 'mesh_' .. wireless["radio"], 'ifname')
+ if wireless["ssid"] == uci:get('wireless', 'ibss_' .. wireless["radio"], 'ssid') then
+ io.stdout:write("Testing IBSS "..wireless["bssid"].."...\n")
+ -- leave the current adhoc network
+ os.execute("iw dev "..ibss.." ibss leave 2> /dev/null")
+ if mesh ~= nil then
+ os.execute("iw dev "..mesh.." mesh leave 2> /dev/null")
+ end
+ -- setup the adhoc network we want to test
+ os.execute("iw dev "..ibss.." ibss join "..wireless["ssid"].." "..wireless["frequency"].." "..wireless["bssid"])
+ end
+ if wireless["ssid"] == meshprefix then
+ io.stdout:write("Testing MESH "..wireless["bssid"].."...\n")
+ -- leave the current mesh network
+ os.execute("iw dev "..mesh.." mesh leave 2> /dev/null")
+ if ibss ~= nil then
+ os.execute("iw dev "..ibss.." ibss leave 2> /dev/null")
+ end
+ -- setup the mesh network we want to test
+ os.execute("iw dev "..mesh.." mesh join "..meshprefix..wireless["bssid"].." freq "..wireless["frequency"])
+ end
+ -- sleep 30 seconds till the connection is fully setup
+ local c = 0;
+ while(not M.batmanHasGateway()) do
+ if(c >= 30) then break end
+ M.sleep(1)
+ c = c +1;
+ end
+ if c < 30 then
+ return wireless["bssid"]
+ end
+ end
+ return nil
+end
+
+function M.get_batman_mesh_network(sorted_wlan_list, defaultHood, meshprefix)
+ io.stdout:write('Testing neighbouring adhoc networks for batman advanced gw connection.\n')
+ io.stdout:write('The following wireless networks have been found:\n')
+ for _, network in pairs(sorted_wlan_list) do
+ print(network["quality"].."\t"..network["frequency"].."\t"..network["bssid"].."\t"..network["ssid"])
+ end
+
+ -- we dont want to test the default hood because if there is no other
+ -- hood present we will connect to the default hood anyway
+ sorted_wlan_list = M.filter_default_hood_wlan_networks(defaultHood, sorted_wlan_list)
+
+ -- we dont want to test duplicated networks
+ sorted_wlan_list = M.filter_redundancy(sorted_wlan_list)
+
+ -- we dont want to get tricked by our signal
+ sorted_wlan_list = M.filter_my_wlan_network(sorted_wlan_list)
+
+ io.stdout:write('After filtering we will test the following wireless networks:\n')
+ for _, network in pairs(sorted_wlan_list) do
+ print(network["quality"].."\t"..network["frequency"].."\t"..network["bssid"].."\t"..network["ssid"])
+ end
+
+ local bssid = nil
+ if(next(sorted_wlan_list)) then
+ io.stdout:write("Prepare configuration for testing wireless networks...\n")
+ -- Notice:
+ -- we will use iw for testing the wireless networks because using iw does
+ -- not need any changes inside the uci config. This approach allows the
+ -- router to automatically reset to previous configuration in case
+ -- someone disconnects the router from power during test.
+
+ -- stop vpn to prevent two hoods from beeing connected in case
+ -- the router gets internet unexpectedly during test.
+ M.vpn_stop()
+ bssid = M.test_batman_mesh_networks(sorted_wlan_list, meshprefix)
+ M.vpn_start()
+ M.wireless_restart()
+ io.stdout:write("Finished testing wireless networks, restored previous configuration\n")
+ end
+
+ return bssid
+end
+
+function M.get_batman_GW_interface()
+ for gw in io.open("/sys/kernel/debug/batman_adv/bat0/gateways", 'r'):lines() do
+ if gw:match("=>") then
+ return M.trim(gw:match("%[.-%]"):gsub("%[", ""):gsub("%]", ""))
+ end
+ end
+ return nil
+end
+
+function M.get_radio_to_bssid(radios,iface,jhood)
+ for _, radio in ipairs(radios) do
+ local ifname = uci:get('wireless', 'ibss_' .. radio, 'ifname')
+ if ifname == iface then
+ return M.gethoodByBssid(jhood, uci:get('wireless', 'ibss_' .. radio, 'bssid'))
+ end
+ ifname = uci:get('wireless', 'mesh_' .. radio, 'ifname')
+ if ifname == iface then
+ local meshid = uci:get('wireless', 'mesh_' .. radio, 'mesh_id')
+ meshid = M.split(meshid, '_')
+ if meshid[2] ~= nil then
+ if meshid[2]:match("(%w+:%w+:%w+:%w+:%w+:%w+)") then
+ return M.gethoodByBssid(jhood, meshid[2]:match("(%w+:%w+:%w+:%w+:%w+:%w+)"))
+ end
+ end
+ end
+ end
+ return nil
+end
+
+function M.mesh_lan_wan(iface)
+ if uci:get('network', 'mesh_wan') then
+ local if_wan = io.popen(string.format("ifstatus mesh_wan"), 'r'):read('*a')
+ if if_wan ~= nil then
+ local wan, _, _ = json.parse(if_wan, 1, nil)
+ if wan["device"] == iface then
+ io.stdout:write("gw source is wan\n")
+ return true
+ end
+ end
+ end
+ if uci:get('network', 'mesh_lan') then
+ local if_lan = io.popen(string.format("ifstatus mesh_lan"), 'r'):read('*a')
+ if if_lan ~= nil then
+ local lan, _, _ = json.parse(if_lan, 1, nil)
+ if lan["device"] == iface then
+ io.stdout:write("gw source is lan\n")
+ return true
+ end
+ end
+ end
+ return false
+end
+
+function M.conditional_increment(table,index)
+ if index["bssid"] ~= nil then
+ if not table[index["bssid"]] then
+ table[index["bssid"]] = 1
+ else
+ table[index["bssid"]] = table[index["bssid"]] + 1
+ end
+ end
+end
+
+-- Get BSSID from neighbour hoods over respondd
+function M.molw_get_bssid(iface)
+ -- differentiate between VPN and mesh only routers
+ local vpn_router_neighbour_bssids = {}
+ local mesh_router_neighbour_bssids = {}
+ local own_mac = uci:get('network', 'client', 'macaddr')
+ for _,respondd_if in ipairs(iface) do
+ local respondd = string.format("gluon-neighbour-info -i " ..
+ respondd_if .. " -p 1001 -d ff02::2 -r hoodselector -t 0.5")
+ print(respondd)
+ for line in io.popen(respondd, 'r'):lines() do
+ local obj, _, err = json.parse (line, 1, nil)
+ if err then
+ io.stdout:write("json parse error!\n")
+ else
+ if obj["mac"] ~= own_mac then
+ if obj["hoodinfo"] ~= nil then
+ if obj["hoodinfo"]["vpnrouter"] ~= nil then
+ if obj["hoodinfo"]["vpnrouter"]:match("true") then
+ if obj["mesh"] ~= nil then
+ M.conditional_increment(vpn_router_neighbour_bssids, obj["mesh"])
+ end
+ else
+ if obj["mesh"] ~= nil then
+ M.conditional_increment(mesh_router_neighbour_bssids, obj["mesh"])
+ end
+ end
+ end
+ end
+ end
+ end
+ end
+ end
+ local neighbour_bssids
+ if next(vpn_router_neighbour_bssids) then
+ -- molwm VPN router founds.
+ print("Found VPN routers over mesh on lan or wan")
+ neighbour_bssids = vpn_router_neighbour_bssids
+ else
+ -- molwm VPN router not founds. Get most presented bssid
+ print("No VPN routers over mesh on lan or wan")
+ neighbour_bssids = mesh_router_neighbour_bssids
+ end
+
+ local bssid = nil
+ local value = 0
+ for b,c in pairs(neighbour_bssids) do
+ io.stdout:write(b.."\t"..c.."\n")
+ if value < c then
+ bssid = b
+ value = c
+ end
+ end
+ local eq_cost_entrys = {}
+ for b,c in pairs(neighbour_bssids) do
+ if b == bssid then
+ table.insert(eq_cost_entrys,b)
+ end
+ if c == value and b ~= bssid then
+ table.insert(eq_cost_entrys,b)
+ end
+ end
+ if #eq_cost_entrys ~= 0 then
+ bssid = eq_cost_entrys[math.random(#eq_cost_entrys)]
+ end
+ return bssid
+end
+
+function M.get_mesh_prefix(radios)
+ local mesh_prefix = nil
+ for _,radio in ipairs(radios) do
+ local mesh_id = uci:get('wireless', 'mesh_' .. radio, 'mesh_id')
+ if mesh_id ~= nil then
+ mesh_id = M.split(mesh_id, '_')
+ if mesh_id[1] ~= "" then
+ mesh_prefix = mesh_id[1].."_"
+ else
+ if mesh_id[2] ~= "" then
+ mesh_prefix = mesh_id[2].."_"
+ end
+ end
+ end
+ end
+ return mesh_prefix
+end
+
+function M.extrac_fastd_peer(s,configPeers)
+ if s['.name'] then
+ for prefix,peer in pairs(s) do
+ local tmpPeer = {}
+ if prefix:match(".name") then
+ if peer:match("mesh_vpn_backbone_peer_") then
+ -- val tmpRemote does not need uci exception check because its already include by "uci:foreach"
+ local tmpRemote = uci:get('fastd', peer, 'remote')
+ tmpRemote = M.split(tmpRemote[1], " ")
+ local remote = {}
+ remote['host'] = tmpRemote[1]
+ remote[tmpRemote[2]] = tmpRemote[3]
+ -- uci:get does not need uci exception check because its already include by "uci:foreach"
+ tmpPeer['key'] = tostring(uci:get('fastd', peer, 'key'))
+ tmpPeer['remote'] = remote
+ configPeers[peer] = tmpPeer
+ end
+ end
+ end
+ end
+end
+
+return M
diff --git a/package/gluon-hoodselector/luasrc/usr/sbin/hoodselector b/package/gluon-hoodselector/luasrc/usr/sbin/hoodselector
new file mode 100755
index 00000000..b74f0362
--- /dev/null
+++ b/package/gluon-hoodselector/luasrc/usr/sbin/hoodselector
@@ -0,0 +1,622 @@
+#!/usr/bin/lua
+
+-- This is the hoodselector. The hoodselector is one of the main components for
+-- splitting a layer 2 mesh network into seperated network segments (hoods).
+-- The job of the hoodselector is to automatically detect in which hood
+-- the router is located based on geo settings or by scanning its environment.
+-- Based on these informations the hoodselector should select a hood from a
+-- list of known hoods (hoodlist) and adjust vpn, wireless and mesh on lan
+-- configuration based on the settings given for the selected hood.
+--
+-- The hoodlist containing all hood settings is located in a seperate hoodfile
+-- in the hoods package.
+--
+-- The hoodselector works with the folowing additional software:
+-- * fastd (vpn configuration) see getCurrentFastdPeers()
+-- * tunneldigger (vpn configuration) see getCurrentTunneldiggerPeers()
+-- * iw (wireless network scanning) see get_batman_mesh_network()
+-- * batman-adv (mesh protocol) see directVPN(), get_batman_GW_interface()
+-- * respondd (mesh on LAN or WAN) see molwm()
+--
+-- To detect the current hood the hoodselector knows 5 modes containing
+-- * 1. VPN mode (VPN Router)
+-- - set hood dependent on geo position.
+-- * 2. Gateway mode
+-- - set hood dependent on gateway source
+-- * 3. Scan mode
+-- - Set wifi conf on scanned BSSID
+-- - Set vpn conf getting by BSSID (if no VPN conf exsist disable vpn)
+-- * 4. Radio less mode
+-- - Set hood via mesh on lan wan managemand
+-- * 5. Default mode
+-- - Set default hood if no other hood matchs
+
+-- When selecting a hood, the hoodselector has the following priorities:
+-- 1. Selecting a hood by geo position depending on direct VPN connection.
+-- 2. force creating one mesh cloud with neighbour mesh routers
+-- 3. if routers had only mesh setting vpn config depends on the BSSID
+--
+-- Resources
+-- * https://wireless.wiki.kernel.org/en/users/documentation/iw
+
+-- MOLWM respondd file
+local molwmFile="/tmp/.hoodselector"
+
+local molwmtable = {}
+molwmtable["md5hash"] = ""
+molwmtable["vpnrouter"] = ""
+molwmtable["hoodname"] = ""
+molwmtable["bssid"] = ""
+
+-- PID file to ensure the hoodselector isn't running parallel
+local pidPath="/var/run/hoodselector.pid"
+
+local json = require ("luci.jsonc")
+local uci = require('simple-uci').cursor()
+local hash = require("hash")
+local hoodutil = require("hoodselector.util")
+
+if not uci:get_bool('hoodselector', 'hoodselector', 'enabled') then
+ io.stdout:write("Hoodselector is disabled by UCI\n")
+ os.exit(0)
+end
+
+if io.open(pidPath, "r") ~=nil then
+ hoodutil.log("The hoodselector is still running.")
+ os.exit(1)
+else
+ if io.open(pidPath, "w") ==nil then
+ hoodutil.log("Can`t create pid file on "..pidPath)
+ os.exit(1)
+ end
+end
+
+-- Program terminating function including removing of PID file
+local function exit(exc)
+ if io.open(pidPath, "r") ~=nil then
+ os.remove(pidPath)
+ end
+ os.exit(tonumber(exc))
+end
+
+local FILE = uci:get('hoodselector', 'hoodselector', 'hoodfile')
+if FILE == nil then
+ hoodutil.log("No hood file in config")
+ exit(1)
+end
+
+-- initialization done
+
+local function get_mesh_vpn_interface()
+ local ret = {}
+ if hoodutil.fastd_installed() then
+ local vpnifac = uci:get('fastd', 'mesh_vpn_backbone', 'net')
+ if vpnifac ~= nil then
+ vpnifac = vpnifac:gsub("%_",'-')
+ table.insert(ret,vpnifac)
+ else
+ hoodutil.log("fastd uci config broken! abort...")
+ exit(1)
+ end
+ end
+ if hoodutil.tunneldigger_installed() then
+ local vpnifac = uci:get('tunneldigger', 'mesh_vpn', 'interface')
+ if vpnifac ~= nil then
+ table.insert(ret,vpnifac)
+ else
+ hoodutil.log("tunneldigger uci config broken! abort...")
+ exit(1)
+ end
+ end
+ return ret
+end
+
+-- Give a list of interfaces where respondd is listening
+local function get_mesh_if(radios)
+ -- get VPN interfaces
+ local filtert_if = get_mesh_vpn_interface()
+
+ -- get Wifi interfaces
+ for _, radio in ipairs(radios) do
+ local ifname = uci:get('wireless', 'ibss_' .. radio, 'ifname')
+ if ifname ~= nil then
+ table.insert(filtert_if,ifname)
+ end
+ ifname = uci:get('wireless', 'mesh_' .. radio, 'ifname')
+ if ifname ~= nil then
+ table.insert(filtert_if,ifname)
+ end
+ end
+
+ local respondd_if = {}
+ for line in io.popen(string.format("ubus call network.interface dump | jsonfilter -e \"@.interface[@.proto='gluon_mesh' && @.up=true].device\" -e \"@.interface[@.interface='$(cat /lib/gluon/respondd/client.dev 2>/dev/null)' && @.up=true].device\""), "r"):lines() do
+ -- filter vpn and wifi interfaces
+ if not hoodutil.filt_if(filtert_if,line) then
+ table.insert(respondd_if,line)
+ end
+ end
+
+ return hoodutil.filter_redundancy(respondd_if)
+end
+
+local function molwm(radios)
+ if uci:get_bool("network", "mesh_lan", "auto") or uci:get_bool("network", "mesh_wan", "auto") then
+ local mesh_en = true
+ for _,respondd_if in ipairs(get_mesh_if(radios)) do
+ local respondd = string.format("gluon-neighbour-info -i " .. respondd_if .. " -p 1001 -d ff02::2 -r hoodselector -t 0.5")
+ for line in io.popen(respondd, 'r'):lines() do
+ local obj, _, err = json.parse (line, 1, nil)
+ if err then
+ io.stdout:write("json parse error!\n")
+ mesh_en = false
+ break
+ else
+ if obj["hoodinfo"] ~= nil then
+ if obj["mesh"] ~= nil then
+ if ( obj["mesh"]["lan"] or obj["mesh"]["wan"] ) then
+ if not ( obj["hoodinfo"]["md5hash"] == molwmtable["md5hash"]:gsub('\"', '') ) then
+ io.stdout:write("hashes are not equal! Souce " .. respondd .. "\n")
+ mesh_en = false
+ break
+ end
+ end
+ end
+ end
+ end
+ end
+ end
+ if uci:get('network', 'mesh_wan') then
+ local ifstatus_wan = io.popen(string.format("ifstatus mesh_wan"), 'r'):read('*a')
+ if ifstatus_wan ~= nil then
+ local wan, _, _ = json.parse (ifstatus_wan, 1, nil)
+ if wan["up"] and not mesh_en then
+ hoodutil.mesh_on_wan_disable()
+ end
+ if not wan["up"] and mesh_en then
+ hoodutil.mesh_on_wan_enable()
+ end
+ end
+ end
+ if uci:get('network', 'mesh_lan') then
+ local ifstatus_lan = io.popen(string.format("ifstatus mesh_lan"), 'r'):read('*a')
+ if ifstatus_lan ~= nil then
+ local lan, _, _ = json.parse (ifstatus_lan, 1, nil)
+ if lan["up"] and not mesh_en then
+ hoodutil.mesh_on_lan_disable()
+ end
+ if not lan["up"] and mesh_en then
+ hoodutil.mesh_on_lan_enable()
+ end
+ end
+ end
+ end
+end
+
+function table.val_to_str ( v )
+ if "string" == type( v ) then
+ v = string.gsub( v, "\n", "\\n" )
+ if string.match( string.gsub(v,"[^'\"]",""), '^"+$' ) then
+ return "'" .. v .. "'"
+ end
+ return '"' .. string.gsub(v,'"', '\\"' ) .. '"'
+ else
+ return "table" == type( v ) and table.tostring( v ) or tostring( v )
+ end
+end
+
+function table.key_to_str ( k )
+ if "string" == type( k ) and string.match( k, "^[_%a][_%a%d]*$" ) then
+ return k
+ else
+ return "[" .. table.val_to_str( k ) .. "]"
+ end
+end
+
+function table.tostring( tbl )
+ local result, done = {}, {}
+ for k, v in ipairs( tbl ) do
+ table.insert( result, table.val_to_str( v ) )
+ done[ k ] = true
+ end
+ for k, v in pairs( tbl ) do
+ if not done[ k ] then
+ table.insert( result, table.key_to_str( k ) .. "=" .. table.val_to_str( v ) )
+ end
+ end
+ return "{" .. table.concat( result, "," ) .. "}"
+end
+
+local function molwm_to_file()
+ local file = io.open(molwmFile, "w")
+ if not file then
+ hoodutil.log(molwmFile ..' not found or not createble!')
+ else
+ file:write("\"md5hash\": " .. molwmtable["md5hash"] .. "\n")
+ file:write("\"vpnrouter\": " .. molwmtable["vpnrouter"] .. "\n")
+ file:write("\"hoodname\": " .. molwmtable["hoodname"] .. "\n")
+ file:write("\"bssid\": " .. molwmtable["bssid"] .. "\n")
+ file:close()
+ end
+end
+
+-- Write MOLWM content into file
+local function write_molwm(hood,radios)
+ if hood ~= nil then
+ molwmtable["md5hash"] = "\"" .. string.format(hash.md5(table.tostring(hood))) .. "\""
+ molwmtable["hoodname"] = "\"" .. hood["name"] .. "\""
+ molwmtable["bssid"] = "\"" .. hood["bssid"] .. "\""
+ end
+ molwm(radios)
+ molwm_to_file()
+end
+
+-- bool if direct VPN. The detection is realaise by searching the fastd network interface inside the originator table
+local function directVPN()
+ local vpnIfaceList = get_mesh_vpn_interface()
+ for _,vpnIface in ipairs(vpnIfaceList) do
+ 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
+ molwmtable["vpnrouter"] = "\"true\""
+ return true
+ end
+ end
+ end
+ end
+ molwmtable["vpnrouter"] = "\"false\""
+ return false
+end
+
+-- Retun a table of current peers from /etc/config/fastd
+local function getFastdCurrentPeers()
+ local configPeers = {}
+ local err = uci:foreach('fastd', 'peer',
+ function(s)
+ hoodutil.extrac_fastd_peer(s,configPeers)
+ end
+ )
+ if not err then
+ hoodutil.log("fastd uci config broken! abort...")
+ exit(1)
+ end
+ return configPeers
+end
+
+-- Retun a table of current peers from /etc/config/tunneldigger
+local function getTunneldiggerCurrentPeers()
+ local configPeers = {}
+ local err = uci:foreach('tunneldigger', 'broker',
+ function(s)
+ if s["address"] then
+ for _, peer in pairs(s["address"]) do
+ table.insert(configPeers, peer)
+ end
+ end
+ end
+ )
+ if not err then
+ hoodutil.log("tunneldigger uci config broken! abort...")
+ exit(1)
+ end
+ return configPeers
+end
+
+-- This method sets a new hoodconfig and takes care that services are only
+-- stopped or restarted if reconfiguration is needed.
+-- Process:
+-- * Check if wireless needs reconfiguration and prepare reconfiguration
+-- * Check if vpn needs reconfiguration and prepare reconfiguration
+-- * If vpn needs reconfiguration, stop vpn and apply new settings but
+-- dont restart it before wireless has been reconfigured
+-- * If wireless needs reconfiguration apply new settings and restart wireless
+-- * If vpn needed reconfiguration start fastd now
+local function set_hoodconfig(hood, prefix, radios)
+ local fastd_serverlist = {}
+ local fastd_reconf_needed = false
+ local tunneldigger_reconf_needed = false
+
+ -- pre check if fastd conf exsist
+ if uci:get('fastd', 'mesh_vpn_backbone', 'net') ~= nil then
+ fastd_serverlist = getFastdCurrentPeers()
+ -- Check if fastd needs reconfiguration because in case of reconfiguration we
+ -- need to stop fastd before we can reconfigure any other connection.
+ fastd_reconf_needed = hoodutil.fastd_reconfiguration_needed(hood["servers"], fastd_serverlist);
+ else
+ -- check if fastd uci conf broken
+ if hoodutil.fastd_installed() then
+ hoodutil.log("fastd uci config broken! abort...")
+ exit(1)
+ end
+ end
+
+ -- per check if tunneldigger conf exsist
+ if uci:get('tunneldigger', 'mesh_vpn', 'interface') ~= nil then
+ local tunneldigger_serverlist = getTunneldiggerCurrentPeers()
+ tunneldigger_reconf_needed = hoodutil.tunneldigger_reconfiguration_needed(hood["servers"], tunneldigger_serverlist)
+ else
+ -- check if tunneldigger uci conf broken
+ if hoodutil.tunneldigger_installed() then
+ hoodutil.log("tunneldigger uci config broken! abort...")
+ exit(1)
+ end
+ end
+
+ if fastd_reconf_needed or tunneldigger_reconf_needed then
+ hoodutil.vpn_stop()
+ end
+
+ -- reconfigure wireless
+ local wifi_reconf = hoodutil.wireless_reconfiguration_needed(radios, prefix, hood["bssid"])
+ if(wifi_reconf == 1 or wifi_reconf == 3) then
+ hoodutil.ibss_reconfigure(radios, hood["bssid"])
+ hoodutil.wireless_restart()
+ io.stdout:write('IBSS needed reconfiguration. Applied new settings and restarted.\n')
+ end
+ if(wifi_reconf == 2 or wifi_reconf == 3) then
+ hoodutil.mesh_reconfigure(radios, prefix..hood["bssid"]:lower())
+ hoodutil.wireless_restart()
+ io.stdout:write('MESH needed reconfiguration. Applied new settings and restarted.\n')
+ end
+
+ -- reconfigure fastd
+ if fastd_reconf_needed then
+ hoodutil.fastd_reconfigure(hood["servers"],fastd_serverlist)
+ io.stdout:write('fastd needed reconfiguration. Applied new settings and restarted.\n')
+ end
+
+ if tunneldigger_reconf_needed then
+ hoodutil.tunneldigger_reconfigure(hood["servers"])
+ io.stdout:write('tunneldigger needed reconfiguration. Applied new settings and restarted.\n')
+ end
+
+ if fastd_reconf_needed or tunneldigger_reconf_needed then
+ -- scan mode can disable VPN so we need to make shure that VPN is enabled
+ -- if the router selects a hood
+ hoodutil.vpn_enable()
+ hoodutil.vpn_start()
+ end
+
+ io.stdout:write("Set hood \""..hood["name"].."\"\n")
+ molwmtable["hoodname"] = "\"" .. hood["name"] .. "\""
+
+ if(uci:get('hoodselector', 'hoodselector' , 'hood') ~= hood["bssid"]) then
+ hoodutil.saveHoodToConfig(hood["bssid"])
+ end
+ return true
+end
+
+-- INITIALIZE AND PREPARE DATA --
+-- read hoodfile, exit if reading the hoodfile fails
+local jhood = hoodutil.readHoodfile(FILE)
+if jhood == nil then
+ hoodutil.log('There seems to have gone something wrong while reading hoodfile from ' .. FILE)
+ exit(1)
+end
+
+-- check if a default hood has been defined and exit if none has been defined
+local defaultHood = hoodutil.getDefaultHood(jhood)
+if defaultHood == nil then
+ hoodutil.log('No defaulthood defined.')
+ exit(1)
+end
+
+-- Get list of wifi devices
+local radios = hoodutil.getWifiDevices()
+
+local mesh_prefix = hoodutil.get_mesh_prefix(radios)
+
+-- VPN MODE
+-- If we have a VPN connection then we will try to get the routers location and
+-- select the hood coresponding to our location.
+-- If no hood for the location has been defined, we will select
+-- the default hood.
+-- If we can not get our routers location, we will fallback to scan mode.
+if directVPN() then
+ io.stdout:write('VPN connection found.\n')
+ local geo = hoodutil.getGeolocation()
+ if geo.lat ~= nil and geo.lon ~= nil then
+ io.stdout:write('Position found.\n')
+ local geoHood = hoodutil.getHoodByGeo(jhood, geo)
+ if geoHood ~= nil then
+ set_hoodconfig(geoHood, mesh_prefix, radios)
+ io.stdout:write('Hood set by VPN mode.\n')
+ write_molwm(geoHood,radios)
+ exit(0)
+ end
+ io.stdout:write('No hood has been defined for current position.\n')
+ else
+ io.stdout:write('No position found\n')
+ end
+ set_hoodconfig(defaultHood, mesh_prefix, radios)
+ io.stdout:write('Set defaulthood.\n')
+ write_molwm(defaultHood,radios)
+ exit(0)
+else
+ io.stdout:write('No VPN connection found\n')
+end
+
+if hoodutil.batmanHasGateway() then
+ io.stdout:write('Batman gateways found\n')
+ local gw_intf = {}
+ table.insert(gw_intf,hoodutil.get_batman_GW_interface())
+
+ if next(gw_intf) then
+ -- wifi interface
+ local bssidHood = hoodutil.get_radio_to_bssid(radios,gw_intf[1], jhood)
+ if bssidHood ~= nil then
+ --check if hood inside geo pos
+ local geo = hoodutil.getGeolocation()
+ if geo.lat ~= nil and geo.lon ~= nil then
+ io.stdout:write('Position found.\n')
+ local geoHood = hoodutil.getHoodByGeo(jhood, geo)
+ if geoHood ~= nil then
+ if string.format(hash.md5(table.tostring(bssidHood))) ~= string.format(hash.md5(table.tostring(geoHood))) then
+ io.stdout:write('Geo hood and bssid hood are not equal, do wifi scan...\n')
+ local sortedWlanList = hoodutil.wlan_list_sorted(radios, mesh_prefix)
+ for i=#sortedWlanList,1,-1 do
+ if(string.lower(geoHood.bssid) ~= string.lower(sortedWlanList[i].bssid)) then
+ table.remove(sortedWlanList, i)
+ end
+ end
+ if next(sortedWlanList) then
+ io.stdout:write('Try to switch back in our real hood!\n')
+ io.stdout:write('After filtering we will test the following wireless networks:\n')
+ for _, network in pairs(sortedWlanList) do
+ print(network["quality"].."\t"..network["frequency"].."\t"..network["bssid"].."\t"..network["ssid"])
+ end
+ io.stdout:write("Prepare configuration for testing wireless networks...\n")
+ local bssid = hoodutil.test_batman_mesh_networks(sortedWlanList, mesh_prefix)
+ hoodutil.wireless_restart()
+ io.stdout:write("Finished testing wireless networks, restored previous configuration\n")
+ if bssid ~= nil then
+ set_hoodconfig(geoHood, mesh_prefix, radios)
+ hoodutil.vpn_enable()
+ hoodutil.vpn_start()
+ io.stdout:write('Set Geo Hood by Gateway mode\n')
+ write_molwm(geoHood, radios)
+ exit(0)
+ else
+ io.stdout:write('No neighboring freifunk batman advanced mesh found.\n')
+ end
+ else
+ io.stdout:write('No networks left after filtering!\n')
+ end --end next(sortedWlanList)
+ else
+ io.stdout:write('Geo hood are equal to bssid hood no wifi scan necessary.\n')
+ end --end bssidHood ~= geoHood
+ else
+ io.stdout:write('No hood has been defined for current position.\n')
+ end --end geoHood ~= nil
+ else
+ io.stdout:write('No position found.\n')
+ end --end geo.lat ~= nil and geo.lon ~= nil
+ set_hoodconfig(bssidHood, mesh_prefix, radios)
+ io.stdout:write('Hood set by batmanHasGateway mode, GW source is wifi\n')
+ write_molwm(bssidHood,radios)
+ exit(0)
+ end --end bssidHood ~= nil
+
+ -- mesh lan or wan interface
+ if hoodutil.mesh_lan_wan(gw_intf[1]) then
+ -- if mesh_lan/wan try to get hood by selected bssid of neightbour vpnRouters
+ local neighbourBssid = hoodutil.molw_get_bssid(gw_intf)
+ if neighbourBssid ~= nil then
+ bssidHood = hoodutil.gethoodByBssid(jhood, neighbourBssid)
+ if bssidHood ~= nil then
+ set_hoodconfig(bssidHood, mesh_prefix, radios)
+ io.stdout:write('Hood set by batmanHasGateway mode, GW source is mesh on lan/wan\n')
+ molwmtable["md5hash"] = "\"" .. string.format(hash.md5(table.tostring(bssidHood))) .. "\""
+ molwmtable["hoodname"] = "\"" .. bssidHood["name"] .. "\""
+ molwmtable["bssid"] = "\"" .. bssidHood["bssid"] .. "\""
+ molwm_to_file()
+ exit(0)
+ end
+ end
+ end
+ end --end next(gw_intf)
+ local currendHood = hoodutil.getCurrentHood(jhood)
+ if currendHood ~= nil then
+ write_molwm(currendHood,radios)
+ end
+end
+
+-- SCAN MODE
+if next(radios) then
+ -- check if there exist a neighbouring freifunk batman advanced mesh
+ -- network with an active connection to a batman advanced gateway
+ local sortedWlanList = hoodutil.wlan_list_sorted(radios, mesh_prefix)
+ local meshBSSID = hoodutil.get_batman_mesh_network(sortedWlanList, defaultHood, mesh_prefix)
+ if meshBSSID ~= nil then
+ io.stdout:write("Neighoring freifunk batman advanced mesh with BSSID "..meshBSSID.." found\n")
+ local bssidHood = hoodutil.gethoodByBssid(jhood, meshBSSID)
+ if bssidHood ~= nil then
+ set_hoodconfig(bssidHood, mesh_prefix, radios)
+ io.stdout:write('Hood set by scan mode\n')
+ write_molwm(bssidHood,radios)
+ exit(0)
+ end
+
+ -- if the bssid does not corespond to any hood, we disable vpn and
+ -- just establish a wireless connection to the mesh without any vpn or
+ hoodutil.vpn_stop()
+ hoodutil.vpn_disable()
+ local ibss_exists = false
+ local mesh_exists = false
+ for _,radio in ipairs(radios) do
+ local ifname = uci:get('wireless', 'ibss_' .. radio, 'ifname')
+ if (ifname ~= nil) then
+ ibss_exists = true
+ end
+ ifname = uci:get('wireless', 'mesh_' .. radio, 'ifname')
+ if (ifname ~= nil) then
+ mesh_exists = true
+ end
+ end
+ if ibss_exists then
+ hoodutil.ibss_reconfigure(radios, meshBSSID)
+ end
+ if mesh_exists then
+ hoodutil.mesh_reconfigure(radios, mesh_prefix..meshBSSID:lower())
+ end
+ hoodutil.wireless_restart()
+ io.stdout:write('Could not select a hood but established a connection via wireless mesh.\n')
+ io.stdout:write('Disabled all connections except connections via wireless mesh.\n')
+ exit(0)
+ end
+ io.stdout:write('No neighbouring freifunk batman advanced mesh found.\n')
+end
+
+--Radio less router have mesh lan/wan neighbours
+local mesh_inf = get_mesh_if(radios);
+if next(mesh_inf) then
+ local wait_for_mesh_lan_wan = false
+ if uci:get('network', 'mesh_wan') then
+ local ifstatus_wan = io.popen(string.format("ifstatus mesh_wan"), 'r'):read('*a')
+ if ifstatus_wan ~= nil then
+ local wan, _, _ = json.parse (ifstatus_wan, 1, nil)
+ if not wan["up"] and uci:get_bool("network", "mesh_wan", "auto") then
+ hoodutil.mesh_on_wan_enable()
+ wait_for_mesh_lan_wan = true
+ end
+ end
+ end
+ if uci:get('network', 'mesh_lan') then
+ local ifstatus_lan = io.popen(string.format("ifstatus mesh_lan"), 'r'):read('*a')
+ if ifstatus_lan ~= nil then
+ local lan, _, _ = json.parse (ifstatus_lan, 1, nil)
+ if not lan["up"] and uci:get_bool("network", "mesh_lan", "auto") then
+ hoodutil.mesh_on_lan_enable()
+ wait_for_mesh_lan_wan = true
+ end
+ end
+ end
+ -- wait for network delay
+ if wait_for_mesh_lan_wan then
+ hoodutil.sleep(5)
+ end
+ local neighbourBssid = hoodutil.molw_get_bssid(mesh_inf)
+ if neighbourBssid ~= nil then
+ local bssidHood = hoodutil.gethoodByBssid(jhood, neighbourBssid)
+ if bssidHood ~= nil then
+ set_hoodconfig(bssidHood, mesh_prefix, radios)
+ io.stdout:write('Hood set by "Radio less router have mesh lan/wan neighbours"\n')
+ molwmtable["md5hash"] = "\"" .. string.format(hash.md5(table.tostring(bssidHood) )) .. "\""
+ molwmtable["hoodname"] = "\"" .. bssidHood["name"] .. "\""
+ molwmtable["bssid"] = "\"" .. bssidHood["bssid"] .. "\""
+ molwm_to_file()
+ exit(0)
+ end
+ end
+ io.stdout:write('No molwm neighbours found\n')
+end
+
+-- DEFAULT-HOOD MODE
+-- If we do NOT have a VPN connection AND found no freifunk mesh network while
+-- scanning then we set the default hood if no current hood set.
+io.stdout:write("ENV does not give enough information set default hood\n")
+set_hoodconfig(defaultHood, mesh_prefix, radios)
+io.stdout:write('Set defaulthood.\n')
+write_molwm(defaultHood,radios)
+exit(0)
diff --git a/package/gluon-hoodselector/src/Makefile b/package/gluon-hoodselector/src/Makefile
new file mode 100644
index 00000000..3ddc8a58
--- /dev/null
+++ b/package/gluon-hoodselector/src/Makefile
@@ -0,0 +1,6 @@
+all: respondd.so
+
+CFLAGS += -Wall
+
+respondd.so: respondd.c
+ $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -shared -fPIC -D_GNU_SOURCE -o $@ $^ $(LDLIBS) -lgluonutil -luci
diff --git a/package/gluon-hoodselector/src/respondd.c b/package/gluon-hoodselector/src/respondd.c
new file mode 100644
index 00000000..cc864a1c
--- /dev/null
+++ b/package/gluon-hoodselector/src/respondd.c
@@ -0,0 +1,139 @@
+#include <respondd.h>
+#include <json-c/json.h>
+#include <libgluonutil.h>
+#include <uci.h>
+#include <string.h>
+#include <net/if.h>
+
+#define _STRINGIFY(s) #s
+#define STRINGIFY(s) _STRINGIFY(s)
+
+bool strstw(const char *pre, const char *str) {
+ size_t lenpre = strlen(pre);
+ return strlen(str) < lenpre ? false : strncmp(pre, str, lenpre) == 0;
+}
+
+bool strrmbs(char *line, int begin, int end) { // <- ist es hier sinvoller pointer auf die ints zu setzen??
+ size_t len = strlen(line);
+ if (len < begin)
+ return false;
+
+ memmove(line, line+begin, len - begin + 1);
+ if (len < end)
+ return false;
+
+ line[len-end] = 0; //remove val of end characters on the end
+ return true;
+}
+
+// extract hood informations
+static struct json_object * get_hoodselector(void) {
+ FILE *f = fopen("/tmp/.hoodselector", "r");
+ if (!f)
+ return NULL;
+
+ struct json_object *ret = json_object_new_object();
+ char *line = NULL;
+ size_t len = 0;
+ while (getline(&line, &len, f) >= 0) {
+ //1. Get md5 hash from current selected hood.
+ if (strstw("\"md5hash\": ",line)) {
+ if (!strrmbs(line, 12, 14))
+ continue;
+
+ json_object_object_add(ret, "md5hash", gluonutil_wrap_string(line));
+ }
+ //2. Get true or false string for VPN Router.
+ if (strstw("\"vpnrouter\": ",line)) {
+ if (!strrmbs(line, 14, 16))
+ continue;
+
+ json_object_object_add(ret, "vpnrouter", gluonutil_wrap_string(line));
+ }
+ //3. Get hoodname
+ if (strstw("\"hoodname\": ",line)) {
+ if (!strrmbs(line, 13, 15))
+ continue;
+
+ json_object_object_add(ret, "hoodname", gluonutil_wrap_string(line));
+ }
+ }
+ free(line);
+ fclose(f);
+ return ret;
+}
+
+//Get uci mesh on lan wan
+static struct json_object * get_mesh_on_lan_wan(void){
+ struct uci_context *ctx = uci_alloc_context();
+ ctx->flags &= ~UCI_FLAG_STRICT;
+ struct uci_package *p;
+
+ if (!uci_load(ctx, "wireless", &p)) {
+ struct uci_element *e;
+ uci_foreach_element(&p->sections, e) {
+ struct uci_section *s = uci_to_section(e);
+ if (strcmp(s->type, "wifi-iface"))
+ continue;
+
+ if (strncmp(e->name, "ibss_", 5))
+ continue;
+
+ const char *bssid = uci_lookup_option_string(ctx, s, "bssid");
+ if (!bssid)
+ continue;
+
+ struct json_object *ret = json_object_new_object();
+ json_object_object_add(ret, "bssid", gluonutil_wrap_string(bssid));
+ free((char*)bssid);
+ if(ret) {
+ uci_free_context(ctx);
+ return ret;
+ }
+ }
+ }
+ uci_free_context(ctx);
+ FILE *f = fopen("/tmp/.hoodselector", "r");
+ if (!f)
+ return NULL;
+
+ struct json_object *ret = json_object_new_object();
+ char *line = NULL;
+ size_t len = 0;
+ while (getline(&line, &len, f) >= 0) {
+ //Get bssid from current selected hood.
+ if (strstw("\"bssid\": ",line)) {
+ if (!strrmbs(line, 10, 12))
+ continue;
+ json_object_object_add(ret, "bssid", gluonutil_wrap_string(line));
+ free(line);
+ fclose(f);
+ return ret;
+ }
+ }
+ free(line);
+ fclose(f);
+ return NULL;
+}
+
+// create final obj with logical structure
+static struct json_object * respondd_provider_hoodselector(void) {
+ struct json_object *ret = json_object_new_object();
+
+ struct json_object *hoodinfo = get_hoodselector();
+ if(hoodinfo)
+ json_object_object_add(ret, "hoodinfo", hoodinfo);
+
+ struct json_object *mesh_on_lan_wan = get_mesh_on_lan_wan();
+ if(mesh_on_lan_wan)
+ json_object_object_add(ret, "mesh", mesh_on_lan_wan);
+
+ json_object_object_add(ret, "mac", gluonutil_wrap_and_free_string(gluonutil_get_sysconfig("primary_mac")));
+ return ret;
+}
+
+// related to respondd_provider_hoodselector
+const struct respondd_provider_info respondd_providers[] = {
+ {"hoodselector", respondd_provider_hoodselector},
+ {}
+};
--
2.15.1
From 7f769f7ea4114afeb6c13ab3786db4bb61e2f6fb Mon Sep 17 00:00:00 2001
From: Jan-Tarek Butt <tarek@ring0.de>
Date: Sat, 19 Aug 2017 17:25:15 +0200
Subject: [PATCH 5/5] gluon-config-mode-geo-location: add subpackages
- add gluon-config-mode-geo-location-with-map
- add gluon-config-mode-geo-location-with-geloc
- add gluon-config-mode-geo-location-with-geloc-map
* gluon-config-mode-geo-location: add js for map
* gluon-config-mode-geo-location: add cpp to generate lua file
* gluon-config-mode-geo-location: wizardgen.cpp add withspace
* gluon-config-mode-geo-location: add checkgen.cpp
* gluon-config-mode-geo-location: add i18ndefaultgen.cpp
* gluon-config-mode-geo-location: rm check_site.lua
* gluon-config-mode-geo-location: rm gluon-config-mode-geo-location.pot
* gluon-config-mode-geo-location: add i18ndegen.cpp
* gluon-config-mode-geo-location: rm i18n dir
* gluon-config-mode-geo-location: i18ndefaultgen.cpp fix typo
* gluon-config-mode-geo-location: add i18ndegen.cpp
* gluon-config-mode-geo-location: wizardgen.cpp fix typo
* gluon-config-mode-geo-location: add i18nfrgen.cpp
* gluon-config-mode-geo-location: add src/Makefile
* Add preprocessor prepared 0400-geo-location.lua.in file
* add preprocessor prepared check_site.lua.in file
* add preprocessor prepared de.po.in file
* add preprocessoer prepared fr.po.in file
* add preprocessor prepared gluon-config-mode-geo-location.pot.in file
* gluon-node-info: change default conf set sharelocation to 1
* delete cpp files
* 0400-geo-location.lua: show last selected pos on map if router get reconfigured
* gluon-config-mode-geo-location: fix translation
* gluon-config-mode-geo-location: prepare Makefile to generate pkg
* gluon-config-mode-geo-location prepare Makefile to generate pkg files
* gluon-config-mode-geo-location: rm luasrc dir because of pkg generating
* Prepare Makefile for each subpackage
* gluon-config-mode-geo-location change Makefile:
- add gluon-geolocator to conflic for gluon-config-mode-geo-location
- add gluon-geolocator to conflic for gluon-config-mode-geo-location-with-map
---
package/gluon-config-mode-geo-location/Makefile | 132 ++++++++++++-
.../gluon-config-mode-geo-location/check_site.lua | 3 -
package/gluon-config-mode-geo-location/i18n/de.po | 30 ---
package/gluon-config-mode-geo-location/i18n/fr.po | 30 ---
.../i18n/gluon-config-mode-geo-location.pot | 19 --
.../gluon-config-mode-geo-location/jssrc/build.js | 6 +
.../jssrc/src/osm.js | 69 +++++++
.../gluon/config-mode/wizard/0400-geo-location.lua | 64 ------
.../src/0400-geo-location.lua.in | 218 +++++++++++++++++++++
.../src/check_site.lua.in | 8 +
.../gluon-config-mode-geo-location/src/de.po.in | 86 ++++++++
.../gluon-config-mode-geo-location/src/fr.po.in | 83 ++++++++
.../src/gluon-config-mode-geo-location.pot.in | 53 +++++
.../files/etc/config/gluon-node-info | 2 +-
14 files changed, 650 insertions(+), 153 deletions(-)
delete mode 100644 package/gluon-config-mode-geo-location/check_site.lua
delete mode 100644 package/gluon-config-mode-geo-location/i18n/de.po
delete mode 100644 package/gluon-config-mode-geo-location/i18n/fr.po
delete mode 100644 package/gluon-config-mode-geo-location/i18n/gluon-config-mode-geo-location.pot
create mode 100644 package/gluon-config-mode-geo-location/jssrc/build.js
create mode 100644 package/gluon-config-mode-geo-location/jssrc/src/osm.js
delete mode 100644 package/gluon-config-mode-geo-location/luasrc/lib/gluon/config-mode/wizard/0400-geo-location.lua
create mode 100644 package/gluon-config-mode-geo-location/src/0400-geo-location.lua.in
create mode 100644 package/gluon-config-mode-geo-location/src/check_site.lua.in
create mode 100644 package/gluon-config-mode-geo-location/src/de.po.in
create mode 100644 package/gluon-config-mode-geo-location/src/fr.po.in
create mode 100644 package/gluon-config-mode-geo-location/src/gluon-config-mode-geo-location.pot.in
diff --git a/package/gluon-config-mode-geo-location/Makefile b/package/gluon-config-mode-geo-location/Makefile
index af523f09..b47d2a86 100644
--- a/package/gluon-config-mode-geo-location/Makefile
+++ b/package/gluon-config-mode-geo-location/Makefile
@@ -8,35 +8,155 @@ PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
include ../gluon.mk
PKG_CONFIG_DEPENDS += $(GLUON_I18N_CONFIG)
+PKG_BUILD_DEPENDS:=node/host
+RJS_VERSION:=2.1.10
+RJS:=r-$(RJS_VERSION).js
+define Download/rjs
+ FILE:=$(RJS)
+ URL:=http://requirejs.org/docs/release/$(RJS_VERSION)
+ URL_FILE:=r.js
+ HASH:=d0b7cfd962a7f8ac52a5d528df486341eed856609d9c75fa2566a32900f5b143
+endef
define Package/gluon-config-mode-geo-location
SECTION:=gluon
CATEGORY:=Gluon
- TITLE:=Set geographic location of a node
- DEPENDS:=gluon-config-mode-core-virtual +gluon-node-info
+ TITLE:=Set geographic location of a node manualy and share it.
+ CONFLICTS:=+gluon-config-mode-geo-location-with-geloc-map +gluon-config-mode-geo-location-with-geloc +gluon-config-mode-geo-location-with-map +gluon-geolocator
+ DEPENDS:=+gluon-config-mode-core +gluon-node-info
+endef
+
+define Package/gluon-config-mode-geo-location-with-map
+ SECTION:=gluon
+ CATEGORY:=Gluon
+ TITLE:=Set geographic location of a node manualy and share it, optionally show a map if internet available.
+ CONFLICTS:=+gluon-config-mode-geo-location +gluon-config-mode-geo-location-with-geloc-map +gluon-config-mode-geo-location-with-geloc +gluon-geolocator
+ DEPENDS:=+gluon-config-mode-core +gluon-node-info
endef
+define Package/gluon-config-mode-geo-location-with-geloc
+ SECTION:=gluon
+ CATEGORY:=Gluon
+ TITLE:=Set geographic location of a node manualy or automatically recive geo locations via surrunding wifis and share it.
+ CONFLICTS:=+gluon-config-mode-geo-location +gluon-config-mode-geo-location-with-geloc-map +gluon-config-mode-geo-location-with-map
+ DEPENDS:=+gluon-config-mode-core +gluon-node-info +gluon-geolocator
+endef
+
+define Package/gluon-config-mode-geo-location-with-geloc-map
+ SECTION:=gluon
+ CATEGORY:=Gluon
+ TITLE:=Set geographic location of a node manualy or automatically recive geo locations via surrunding wifis and share it, optionally show a map if internet available.
+ CONFLICTS:=+gluon-config-mode-geo-location +gluon-config-mode-geo-location-with-geloc +gluon-config-mode-geo-location-with-map
+ DEPENDS:=+gluon-config-mode-core +gluon-node-info +gluon-geolocator
+endef
+
+$(eval $(call Download,rjs))
+
define Build/Prepare
mkdir -p $(PKG_BUILD_DIR)
+ $(CP) $(DL_DIR)/$(RJS) $(PKG_BUILD_DIR)/r.js
endef
define Build/Configure
+ $(CP) ./src/* $(PKG_BUILD_DIR)/
+ $(CP) ./jssrc/* $(PKG_BUILD_DIR)/
+
+ $(INSTALL_DIR) $(PKG_BUILD_DIR)/gluon-config-mode-geo-location/luasrc/lib/gluon/config-mode/wizard/
+ $(INSTALL_DIR) $(PKG_BUILD_DIR)/gluon-config-mode-geo-location/i18n/
+
+ $(INSTALL_DIR) $(PKG_BUILD_DIR)/gluon-config-mode-geo-location-with-map/luasrc/lib/gluon/config-mode/wizard/
+ $(INSTALL_DIR) $(PKG_BUILD_DIR)/gluon-config-mode-geo-location-with-map/i18n/
+
+ $(INSTALL_DIR) $(PKG_BUILD_DIR)/gluon-config-mode-geo-location-with-geloc/luasrc/lib/gluon/config-mode/wizard/
+ $(INSTALL_DIR) $(PKG_BUILD_DIR)/gluon-config-mode-geo-location-with-geloc/i18n/
+
+ $(INSTALL_DIR) $(PKG_BUILD_DIR)/gluon-config-mode-geo-location-with-geloc-map/luasrc/lib/gluon/config-mode/wizard/
+ $(INSTALL_DIR) $(PKG_BUILD_DIR)/gluon-config-mode-geo-location-with-geloc-map/i18n/
endef
define Build/Compile
- $(call GluonBuildI18N,gluon-config-mode-geo-location,i18n)
- $(call GluonSrcDiet,./luasrc,$(PKG_BUILD_DIR)/luadest/)
+ $(CC) -E -x c -P $(PKG_BUILD_DIR)/0400-geo-location.lua.in -o $(PKG_BUILD_DIR)/gluon-config-mode-geo-location/luasrc/lib/gluon/config-mode/wizard/0400-geo-location.lua
+ $(CC) -E -x c -P $(PKG_BUILD_DIR)/gluon-config-mode-geo-location.pot.in -o $(PKG_BUILD_DIR)/gluon-config-mode-geo-location/i18n/gluon-config-mode-geo-location.pot
+ $(CC) -E -x c -P $(PKG_BUILD_DIR)/check_site.lua.in -o $(PKG_BUILD_DIR)/gluon-config-mode-geo-location/check_site.lua
+ $(CC) -E -x c -P $(PKG_BUILD_DIR)/de.po.in -o $(PKG_BUILD_DIR)/gluon-config-mode-geo-location/de.po
+ $(CC) -E -x c -P $(PKG_BUILD_DIR)/fr.po.in -o $(PKG_BUILD_DIR)/gluon-config-mode-geo-location/fr.po
+ $(call GluonBuildI18N,gluon-config-mode-geo-location,$(PKG_BUILD_DIR)/gluon-config-mode-geo-location/i18n)
+ $(call GluonSrcDiet,$(PKG_BUILD_DIR)/gluon-config-mode-geo-location/luasrc,$(PKG_BUILD_DIR)/gluon-config-mode-geo-location/luadest/)
+
+ $(CC) -DWITHMAP -E -x c -P $(PKG_BUILD_DIR)/0400-geo-location.lua.in -o $(PKG_BUILD_DIR)/gluon-config-mode-geo-location-with-map/luasrc/lib/gluon/config-mode/wizard/0400-geo-location.lua
+ $(CC) -DWITHMAP -E -x c -P $(PKG_BUILD_DIR)/gluon-config-mode-geo-location.pot.in -o $(PKG_BUILD_DIR)/gluon-config-mode-geo-location-with-map/i18n/gluon-config-mode-geo-location-with-map.pot
+ $(CC) -DWITHMAP -E -x c -P $(PKG_BUILD_DIR)/check_site.lua.in -o $(PKG_BUILD_DIR)/gluon-config-mode-geo-location-with-map/check_site.lua
+ $(CC) -DWITHMAP -E -x c -P $(PKG_BUILD_DIR)/de.po.in -o $(PKG_BUILD_DIR)/gluon-config-mode-geo-location-with-map/de.po
+ $(CC) -DWITHMAP -E -x c -P $(PKG_BUILD_DIR)/fr.po.in -o $(PKG_BUILD_DIR)/gluon-config-mode-geo-location-with-map/fr.po
+ $(call GluonBuildI18N,gluon-config-mode-geo-location-with-map,$(PKG_BUILD_DIR)/gluon-config-mode-geo-location-with-map/i18n)
+ $(call GluonSrcDiet,$(PKG_BUILD_DIR)/gluon-config-mode-geo-location-with-map/luasrc,$(PKG_BUILD_DIR)/gluon-config-mode-geo-location-with-map/luadest/)
+
+ $(CC) -DWITHGELOC -E -x c -P $(PKG_BUILD_DIR)/0400-geo-location.lua.in -o $(PKG_BUILD_DIR)/gluon-config-mode-geo-location-with-geloc/luasrc/lib/gluon/config-mode/wizard/0400-geo-location.lua
+ $(CC) -DWITHGELOC -E -x c -P $(PKG_BUILD_DIR)/gluon-config-mode-geo-location.pot.in -o $(PKG_BUILD_DIR)/gluon-config-mode-geo-location-with-geloc/i18n/gluon-config-mode-geo-location-with-geloc.pot
+ $(CC) -DWITHGELOC -E -x c -P $(PKG_BUILD_DIR)/check_site.lua.in -o $(PKG_BUILD_DIR)/gluon-config-mode-geo-location-with-geloc/check_site.lua
+ $(CC) -DWITHGELOC -E -x c -P $(PKG_BUILD_DIR)/de.po.in -o $(PKG_BUILD_DIR)/gluon-config-mode-geo-location-with-geloc/de.po
+ $(CC) -DWITHGELOC -E -x c -P $(PKG_BUILD_DIR)/fr.po.in -o $(PKG_BUILD_DIR)/gluon-config-mode-geo-location-with-geloc/fr.po
+ $(call GluonBuildI18N,gluon-config-mode-geo-location-with-geloc,$(PKG_BUILD_DIR)/gluon-config-mode-geo-location-with-geloc/i18n)
+ $(call GluonSrcDiet,$(PKG_BUILD_DIR)/gluon-config-mode-geo-location-with-geloc/luasrc,$(PKG_BUILD_DIR)/gluon-config-mode-geo-location-with-geloc/luadest/)
+
+ $(CC) -DWITHMAP -DWITHGELOC -E -x c -P $(PKG_BUILD_DIR)/0400-geo-location.lua.in -o $(PKG_BUILD_DIR)/gluon-config-mode-geo-location-with-geloc-map/luasrc/lib/gluon/config-mode/wizard/0400-geo-location.lua
+ $(CC) -DWITHMAP -DWITHGELOC -E -x c -P $(PKG_BUILD_DIR)/gluon-config-mode-geo-location.pot.in -o $(PKG_BUILD_DIR)/gluon-config-mode-geo-location-with-geloc-map/i18n/gluon-config-mode-geo-location-with-geloc-map.pot
+ $(CC) -DWITHMAP -DWITHGELOC -E -x c -P $(PKG_BUILD_DIR)/check_site.lua.in -o $(PKG_BUILD_DIR)/gluon-config-mode-geo-location-with-geloc-map/check_site.lua
+ $(CC) -DWITHMAP -DWITHGELOC -E -x c -P $(PKG_BUILD_DIR)/de.po.in -o $(PKG_BUILD_DIR)/gluon-config-mode-geo-location-with-geloc-map/de.po
+ $(CC) -DWITHMAP -DWITHGELOC -E -x c -P $(PKG_BUILD_DIR)/fr.po.in -o $(PKG_BUILD_DIR)/gluon-config-mode-geo-location-with-geloc-map/fr.po
+ $(call GluonBuildI18N,gluon-config-mode-geo-location-with-geloc-map,$(PKG_BUILD_DIR)/gluon-config-mode-geo-location-with-geloc-map/i18n)
+ $(call GluonSrcDiet,$(PKG_BUILD_DIR)/gluon-config-mode-geo-location-with-geloc-map/luasrc,$(PKG_BUILD_DIR)/gluon-config-mode-geo-location-with-geloc-map/luadest/)
+
+ cd $(PKG_BUILD_DIR) && \
+ node r.js -o build.js
endef
define Package/gluon-config-mode-geo-location/install
- $(CP) $(PKG_BUILD_DIR)/luadest/* $(1)/
+ $(CP) $(PKG_BUILD_DIR)/gluon-config-mode-geo-location/luadest/* $(1)/
$(call GluonInstallI18N,gluon-config-mode-geo-location,$(1))
endef
+define Package/gluon-config-mode-geo-location-with-map/install
+ $(CP) $(PKG_BUILD_DIR)/gluon-config-mode-geo-location-with-map/luadest/* $(1)/
+ $(INSTALL_DIR) $(1)/lib/gluon/web/www/static/gluon/
+ $(INSTALL_DATA) $(PKG_BUILD_DIR)/osm.js $(1)/lib/gluon/web/www/static/gluon/
+ $(call GluonInstallI18N,gluon-config-mode-geo-location-with-map,$(1))
+endef
+
+define Package/gluon-config-mode-geo-location-with-geloc/install
+ $(CP) $(PKG_BUILD_DIR)/gluon-config-mode-geo-location-with-geloc/luadest/* $(1)/
+ $(call GluonInstallI18N,gluon-config-mode-geo-location-with-geloc,$(1))
+endef
+
+define Package/gluon-config-mode-geo-location-with-geloc-map/install
+ $(CP) $(PKG_BUILD_DIR)/gluon-config-mode-geo-location-with-geloc-map/luadest/* $(1)/
+ $(INSTALL_DIR) $(1)/lib/gluon/web/www/static/gluon/
+ $(INSTALL_DATA) $(PKG_BUILD_DIR)/osm.js $(1)/lib/gluon/web/www/static/gluon/
+ $(call GluonInstallI18N,gluon-config-mode-geo-location-with-geloc-map,$(1))
+endef
+
define Package/gluon-config-mode-geo-location/postinst
#!/bin/sh
-$(call GluonCheckSite,check_site.lua)
+$(call GluonCheckSite,$(PKG_BUILD_DIR)/gluon-config-mode-geo-location/check_site.lua)
+endef
+
+define Package/gluon-config-mode-geo-location-with-map/postinst
+#!/bin/sh
+$(call GluonCheckSite,$(PKG_BUILD_DIR)/gluon-config-mode-geo-location-with-map/check_site.lua)
+endef
+
+define Package/gluon-config-mode-geo-location-with-geloc/postinst
+#!/bin/sh
+$(call GluonCheckSite,$(PKG_BUILD_DIR)/gluon-config-mode-geo-location-with-geloc/check_site.lua)
+endef
+
+define Package/gluon-config-mode-geo-location-with-geloc-map/postinst
+#!/bin/sh
+$(call GluonCheckSite,$(PKG_BUILD_DIR)/gluon-config-mode-geo-location-with-geloc-map/check_site.lua)
endef
$(eval $(call BuildPackage,gluon-config-mode-geo-location))
+$(eval $(call BuildPackage,gluon-config-mode-geo-location-with-map))
+$(eval $(call BuildPackage,gluon-config-mode-geo-location-with-geloc))
+$(eval $(call BuildPackage,gluon-config-mode-geo-location-with-geloc-map))
diff --git a/package/gluon-config-mode-geo-location/check_site.lua b/package/gluon-config-mode-geo-location/check_site.lua
deleted file mode 100644
index 509226fe..00000000
--- a/package/gluon-config-mode-geo-location/check_site.lua
+++ /dev/null
@@ -1,3 +0,0 @@
-if need_table('config_mode', nil, false) and need_table('config_mode.geo_location', nil, false) then
- need_boolean('config_mode.geo_location.show_altitude', false)
-end
diff --git a/package/gluon-config-mode-geo-location/i18n/de.po b/package/gluon-config-mode-geo-location/i18n/de.po
deleted file mode 100644
index c8bc906a..00000000
--- a/package/gluon-config-mode-geo-location/i18n/de.po
+++ /dev/null
@@ -1,30 +0,0 @@
-msgid ""
-msgstr ""
-"Project-Id-Version: gluon-config-mode-geo-location\n"
-"PO-Revision-Date: 2015-03-23 02:18+0100\n"
-"Last-Translator: Martin Weinelt <martin@darmstadt.freifunk.net>\n"
-"Language-Team: German\n"
-"Language: de\n"
-"MIME-Version: 1.0\n"
-"Content-Type: text/plain; charset=UTF-8\n"
-"Content-Transfer-Encoding: 8bit\n"
-"Plural-Forms: nplurals=2; plural=(n != 1);\n"
-
-msgid ""
-"If you want the location of your node to be displayed on the map, you can "
-"enter its coordinates here."
-msgstr ""
-"Um deinen Knoten auf der Karte anzeigen zu können, benötigen wir seine "
-"Koordinaten. Hier hast du die Möglichkeit, diese zu hinterlegen."
-
-msgid "Latitude"
-msgstr "Breitengrad"
-
-msgid "Longitude"
-msgstr "Längengrad"
-
-msgid "Show node on the map"
-msgstr "Knoten auf der Karte anzeigen"
-
-msgid "e.g. %s"
-msgstr "z.B. %s"
diff --git a/package/gluon-config-mode-geo-location/i18n/fr.po b/package/gluon-config-mode-geo-location/i18n/fr.po
deleted file mode 100644
index d3d7c6e8..00000000
--- a/package/gluon-config-mode-geo-location/i18n/fr.po
+++ /dev/null
@@ -1,30 +0,0 @@
-msgid ""
-msgstr ""
-"Content-Type: text/plain; charset=UTF-8\n"
-"Project-Id-Version: PACKAGE VERSION\n"
-"PO-Revision-Date: 2015-08-12 23:30+0100\n"
-"Last-Translator:Tobias Bernot <tqbs@airmail.cc>\n"
-"Language-Team: French\n"
-"Language: fr\n"
-"MIME-Version: 1.0\n"
-"Content-Transfer-Encoding: 8bit\n"
-"Plural-Forms: nplurals=2; plural=(n != 1);\n"
-
-msgid ""
-"If you want the location of your node to be displayed on the map, you can "
-"enter its coordinates here."
-msgstr ""
-"Pour Afficher votre nœud sur la Carte nous avons besoin de ses coordonnées. "
-"Ici vous pouvez entrer sa position."
-
-msgid "Latitude"
-msgstr "Latitude"
-
-msgid "Longitude"
-msgstr "Longitude"
-
-msgid "Show node on the map"
-msgstr "Afficher le nœud sur la carte"
-
-msgid "e.g. %s"
-msgstr "Ex: %s"
diff --git a/package/gluon-config-mode-geo-location/i18n/gluon-config-mode-geo-location.pot b/package/gluon-config-mode-geo-location/i18n/gluon-config-mode-geo-location.pot
deleted file mode 100644
index 7acf7f28..00000000
--- a/package/gluon-config-mode-geo-location/i18n/gluon-config-mode-geo-location.pot
+++ /dev/null
@@ -1,19 +0,0 @@
-msgid ""
-msgstr "Content-Type: text/plain; charset=UTF-8"
-
-msgid ""
-"If you want the location of your node to be displayed on the map, you can "
-"enter its coordinates here."
-msgstr ""
-
-msgid "Latitude"
-msgstr ""
-
-msgid "Longitude"
-msgstr ""
-
-msgid "Show node on the map"
-msgstr ""
-
-msgid "e.g. %s"
-msgstr ""
diff --git a/package/gluon-config-mode-geo-location/jssrc/build.js b/package/gluon-config-mode-geo-location/jssrc/build.js
new file mode 100644
index 00000000..146bbd10
--- /dev/null
+++ b/package/gluon-config-mode-geo-location/jssrc/build.js
@@ -0,0 +1,6 @@
+({
+ baseUrl: "src",
+ include: "osm.js",
+ optimize: "uglify2",
+ out: "osm.js",
+})
diff --git a/package/gluon-config-mode-geo-location/jssrc/src/osm.js b/package/gluon-config-mode-geo-location/jssrc/src/osm.js
new file mode 100644
index 00000000..e2f3f2ff
--- /dev/null
+++ b/package/gluon-config-mode-geo-location/jssrc/src/osm.js
@@ -0,0 +1,69 @@
+function findObj(name) {
+ list = document.getElementsByClassName("gluon-input-text");
+ for(i = 0; i < list.length; i++) {
+ item = list.item(i);
+ if(item.id.indexOf(name) >= 0) return item;
+ }
+ return false;
+}
+
+function showMap() {
+ if ("object" == typeof OpenLayers && false !== findObj("longitude")) {
+ document.getElementById("locationPickerMap").style.display = "block";
+ var e = new OpenLayers.Projection("EPSG:4326"),
+ a = new OpenLayers.Projection("EPSG:900913"),
+ t = 12,
+ n = new OpenLayers.Layer.Markers("Markers");
+ OpenLayers.Control.Click = OpenLayers.Class(OpenLayers.Control, {
+ defaultHandlerOptions: {
+ single: !0,
+ "double": !1,
+ pixelTolerance: 0,
+ stopSingle: !1,
+ stopDouble: !1
+ },
+ initialize: function() {
+ this.handlerOptions = OpenLayers.Util.extend({}, this.defaultHandlerOptions), OpenLayers.Control.prototype.initialize.apply(this, arguments), this.handler = new OpenLayers.Handler.Click(this, {
+ click: this.trigger
+ }, this.handlerOptions)
+ },
+ trigger: function(t) {
+ var i = osmMap.getLonLatFromPixel(t.xy);
+ oLon = findObj("longitude");
+ oLat = findObj("latitude");
+ lonlat1 = new OpenLayers.LonLat(i.lon, i.lat).transform(a, e),
+ oLon.value = lonlat1.lon,
+ oLat.value = lonlat1.lat,
+ n.clearMarkers(),
+ n.addMarker(new OpenLayers.Marker(i)),
+ oLon.className = oLon.className.replace(/ gluon-input-invalid/g, ""),
+ oLat.className = oLat.className.replace(/ gluon-input-invalid/g, "");
+ //Anyone knows how to trigger the change event?
+ //oLon.onChange()
+ //oLat.onChange()
+ }
+ }), osmMap = new OpenLayers.Map("locationPickerMap", {
+ controls: [new OpenLayers.Control.Navigation, new OpenLayers.Control.PanZoomBar, new OpenLayers.Control.MousePosition],
+ maxExtent: new OpenLayers.Bounds(-20037508.34, -20037508.34, 20037508.34, 20037508.34),
+ numZoomLevels: 18,
+ maxResolution: 156543,
+ units: "m",
+ projection: a,
+ displayProjection: e
+ });
+ var i = new OpenLayers.Layer.OSM("OpenStreetMap");
+ osmMap.addLayer(i), osmMap.addLayer(n);
+ var o = longitude,
+ r = latitude;
+ oLon = findObj("longitude");
+ oLat = findObj("latitude");
+ "" != oLon.value && (o = oLon.value),
+ "" != oLat.value && (r = oLat.value),
+ n.addMarker(new OpenLayers.Marker(new OpenLayers.LonLat(o, r).transform(e, a)));
+ var l = new OpenLayers.LonLat(o, r),
+ d = l.transform(e, a);
+ osmMap.setCenter(d, t);
+ var s = new OpenLayers.Control.Click;
+ osmMap.addControl(s), s.activate()
+ } else setTimeout(showMap, 1e3)
+}
diff --git a/package/gluon-config-mode-geo-location/luasrc/lib/gluon/config-mode/wizard/0400-geo-location.lua b/package/gluon-config-mode-geo-location/luasrc/lib/gluon/config-mode/wizard/0400-geo-location.lua
deleted file mode 100644
index 4d7fec01..00000000
--- a/package/gluon-config-mode-geo-location/luasrc/lib/gluon/config-mode/wizard/0400-geo-location.lua
+++ /dev/null
@@ -1,64 +0,0 @@
-return function(form, uci)
- local site = require 'gluon.site_config'
-
- local location = uci:get_first("gluon-node-info", "location")
-
- local function show_altitude()
- if ((site.config_mode or {}).geo_location or {}).show_altitude ~= false then
- return true
- end
-
- return uci:get_bool("gluon-node-info", location, "altitude")
- end
-
- local text = translate(
- 'If you want the location of your node to ' ..
- 'be displayed on the map, you can enter its coordinates here.'
- )
- if show_altitude() then
- text = text .. ' ' .. translate("gluon-config-mode:altitude-help")
- end
-
- local s = form:section(Section, nil, text)
-
- local o
-
- local share_location = s:option(Flag, "location", translate("Show node on the map"))
- share_location.default = uci:get_bool("gluon-node-info", location, "share_location")
- function share_location:write(data)
- uci:set("gluon-node-info", location, "share_location", data)
- end
-
- o = s:option(Value, "latitude", translate("Latitude"), translatef("e.g. %s", "53.873621"))
- o.default = uci:get("gluon-node-info", location, "latitude")
- o:depends(share_location, true)
- o.datatype = "float"
- function o:write(data)
- uci:set("gluon-node-info", location, "latitude", data)
- end
-
- o = s:option(Value, "longitude", translate("Longitude"), translatef("e.g. %s", "10.689901"))
- o.default = uci:get("gluon-node-info", location, "longitude")
- o:depends(share_location, true)
- o.datatype = "float"
- function o:write(data)
- uci:set("gluon-node-info", location, "longitude", data)
- end
-
- if show_altitude() then
- o = s:option(Value, "altitude", translate("gluon-config-mode:altitude-label"), translatef("e.g. %s", "11.51"))
- o.default = uci:get("gluon-node-info", location, "altitude")
- o:depends(share_location, true)
- o.datatype = "float"
- o.optional = true
- function o:write(data)
- if data then
- uci:set("gluon-node-info", location, "altitude", data)
- else
- uci:delete("gluon-node-info", location, "altitude")
- end
- end
- end
-
- return {'gluon-node-info'}
-end
diff --git a/package/gluon-config-mode-geo-location/src/0400-geo-location.lua.in b/package/gluon-config-mode-geo-location/src/0400-geo-location.lua.in
new file mode 100644
index 00000000..7cc96bf6
--- /dev/null
+++ b/package/gluon-config-mode-geo-location/src/0400-geo-location.lua.in
@@ -0,0 +1,218 @@
+return function(form, uci)
+ local site = require 'gluon.site_config'
+
+ local location = uci:get_first("gluon-node-info", "location")
+ local uci_latitude = uci:get("gluon-node-info", location, "latitude")
+ local uci_longitude = uci:get("gluon-node-info", location, "longitude")
+
+#ifdef WITHMAP
+
+ local function show_lon()
+ if uci_longitude ~= nil then
+ return uci_longitude
+ end
+ if ((site.config_mode or {}).geo_location or {}).map_lon ~= nil then
+ return site.config_mode.geo_location.map_lon
+ end
+ return 0.0
+ end
+
+ local function show_lat()
+ if uci_latitude ~= nil then
+ return uci_latitude
+ end
+ if ((site.config_mode or {}).geo_location or {}).map_lat ~= nil then
+ return site.config_mode.geo_location.map_lat
+ end
+ return 0.0
+ end
+
+ local function show_olurl()
+ if ((site.config_mode or {}).geo_location or {}).olurl ~= nil then
+ return site.config_mode.geo_location.olurl
+ end
+ return 'http://dev.openlayers.org/OpenLayers.js'
+ end
+
+#endif
+
+ local function show_altitude()
+ if ((site.config_mode or {}).geo_location or {}).show_altitude ~= false then
+ return true
+ end
+ return uci:get_bool("gluon-node-info", location, "altitude")
+ end
+
+ local text = translate(
+ 'If you want the location of your node to be displayed on the map, you can ' ..
+#ifdef WITHGELOC
+ 'set an automatically localization of your router or ' ..
+#endif
+ 'enter its coordinates here. ' ..
+
+#ifdef WITHMAP
+
+ 'If your PC is connected to the internet you can also click on the map displayed below. ' ..
+
+#endif
+
+ 'Please keep in mind setting a location can also enhance the network quality.'
+ )
+
+ if show_altitude() then
+ text = text .. ' ' .. translate("gluon-config-mode:altitude-help")
+ end
+
+#ifdef WITHMAP
+
+ text = text .. [[
+ <div id="locationPickerMap" style="width:100%; height:300px; display: none;"></div>
+ <script src="]] .. show_olurl() .. [["></script>
+ <script src="/static/gluon/osm.js"></script>
+ <script>
+ var latitude=]] .. show_lon() .. ",longitude=" .. show_lat() .. [[;
+ document.addEventListener("DOMContentLoaded", showMap, false);
+ setInterval(function() {
+ if(false !== findObj("longitude")) {
+ document.getElementById("locationPickerMap").style.display="block";
+ }else{
+ document.getElementById("locationPickerMap").style.display="none";
+ }
+ }, 1000);
+ </script>
+ ]]
+
+#endif
+
+ local s = form:section(Section, nil, text)
+
+
+ local uci_share_location = uci:get_bool("gluon-node-info", location, "share_location")
+
+ local geolocation = s:option(ListValue, "geolocation", translate("Geo-Location"))
+#ifdef WITHGELOC
+ geolocation:value("automatic", translate("Automatic (geolocator)"))
+ geolocation:value("auto_static", translate("Automatic & Static"))
+#endif
+ geolocation:value("static", translate("Static location"))
+ geolocation:value("none", translate("Disabled"))
+#ifdef WITHGELOC
+ local auto_location = uci:get_bool("geolocator", "settings", "auto_location")
+ local static_location = uci:get_bool("geolocator", "settings", "static_location")
+ if auto_location == false and static_location == false then
+#else
+ if uci_latitude == nil and uci_longitude == nil and uci_share_location == false then
+#endif
+ geolocation.default = "none"
+#ifndef WITHGELOC
+ else
+ geolocation.default = "static"
+#endif
+ end
+#ifdef WITHGELOC
+ if auto_location == true and static_location == true then
+ geolocation.default = "auto_static"
+ end
+ if auto_location == false and static_location == true then
+ geolocation.default = "static"
+ end
+#endif
+
+ local share_location = s:option(Flag, "sharelocation", translate("Share your location to see your router on the map"))
+ share_location.default = uci_share_location
+#ifdef WITHGELOC
+ share_location:depends(geolocation, "automatic")
+ share_location:depends(geolocation, "auto_static")
+#endif
+ share_location:depends(geolocation, "static")
+
+#ifdef WITHGELOC
+ --[[ -- Currently not available
+ o = s:option(DummyValue, "automatic_disc", " ", translatef("Automaticaly location service over wifi."))
+ o:depends(geolocation, "automatic")
+ o.description = translatef("Automaticaly location service over wifi.")
+ --]]
+
+ local interval = s:option(Value, "interval", translate("Interval in minutes"), translatef("Set refresh interval"))
+ interval.default = uci:get("geolocator", "settings", "refresh_interval")
+ interval:depends(geolocation, "automatic")
+ interval:depends(geolocation, "auto_static")
+ interval.datatype = "uinteger"
+#endif
+
+ local latitude = s:option(Value, "latitude", translate("Latitude"), translatef("e.g. %s", "50.364931"))
+ latitude.default = uci_latitude
+ latitude:depends(geolocation, "static")
+#ifdef WITHGELOC
+ latitude:depends(geolocation, "auto_static")
+#endif
+ latitude.datatype = "float"
+
+ local longitude = s:option(Value, "longitude", translate("Longitude"), translatef("e.g. %s", "7.606417"))
+ longitude.default = uci_longitude
+ longitude:depends(geolocation, "static")
+#ifdef WITHGELOC
+ longitude:depends(geolocation, "auto_static")
+#endif
+ longitude.datatype = "float"
+
+ local altitude;
+ if show_altitude() then
+ altitude = s:option(Value, "altitude", translate("gluon-config-mode:altitude-label"), translatef("e.g. %s", "11.51"))
+ altitude.default = uci:get("gluon-node-info", location, "altitude")
+ altitude:depends(geolocation, "static")
+#ifdef WITHGELOC
+ altitude:depends(geolocation, "auto_static")
+#endif
+ altitude.datatype = "float"
+ altitude.optional = true
+ end
+ function geolocation:write(data)
+#ifdef WITHGELOC
+ if data == "automatic" or data == "auto_static" then
+ uci:set("geolocator", "settings", "auto_location", 1)
+ if interval.data ~= nil and tonumber(interval.data) >= 1 and tonumber(interval.data) <= 43200 then
+ uci:set("geolocator", "settings", "refresh_interval", interval.data)
+ elseif tonumber(interval.data) > 43200 then
+ uci:set("geolocator", "settings", "refresh_interval", 43200)
+ end
+ else
+ uci:set("geolocator", "settings", "auto_location", 0)
+ end
+ if data == "static" or data == "auto_static" then
+ uci:set("geolocator", "settings", "static_location", 1)
+#else
+ if data == "static" then
+#endif
+ uci:set("gluon-node-info", location, "latitude", latitude.data)
+ uci:set("gluon-node-info", location, "longitude", longitude.data)
+ if show_altitude() then
+ if altitude.data then
+ uci:set("gluon-node-info", location, "altitude", altitude.data)
+ else
+ uci:delete("gluon-node-info", location, "altitude")
+ end
+ end
+#ifdef WITHGELOC
+ else
+ uci:set("geolocator", "settings", "static_location", 0)
+#endif
+ end
+ if data == "none" then
+ uci:delete("gluon-node-info", location, "altitude")
+ uci:delete("gluon-node-info", location, "latitude")
+ uci:delete("gluon-node-info", location, "longitude")
+ uci:set("gluon-node-info", location, "share_location", 0)
+#ifdef WITHGELOC
+ uci:set("geolocator", "settings", "auto_location", 0)
+#endif
+ else
+ uci:set("gluon-node-info", location, "share_location", share_location.data)
+ end
+ end
+#ifdef WITHGELOC
+ return {'gluon-node-info', 'geolocator'}
+#else
+ return {'gluon-node-info'}
+#endif
+end
diff --git a/package/gluon-config-mode-geo-location/src/check_site.lua.in b/package/gluon-config-mode-geo-location/src/check_site.lua.in
new file mode 100644
index 00000000..a378e58f
--- /dev/null
+++ b/package/gluon-config-mode-geo-location/src/check_site.lua.in
@@ -0,0 +1,8 @@
+if need_table('config_mode', nil, false) and need_table('config_mode.geo_location', nil, false) then
+ need_boolean('config_mode.geo_location.show_altitude', false)
+#ifdef WITHMAP
+ need_string('config_mode.geo_location.olurl', false)
+ need_number('config_mode.geo_location.map_lon', false)
+ need_number('config_mode.geo_location.map_lat', false)
+#endif
+end
diff --git a/package/gluon-config-mode-geo-location/src/de.po.in b/package/gluon-config-mode-geo-location/src/de.po.in
new file mode 100644
index 00000000..0393e3d9
--- /dev/null
+++ b/package/gluon-config-mode-geo-location/src/de.po.in
@@ -0,0 +1,86 @@
+msgid ""
+msgstr ""
+#ifdef WITHMAP
+#ifdef WITHGELOC
+"Project-Id-Version: gluon-config-mode-geo-location-with-geloc-map\n"
+#else
+"Project-Id-Version: gluon-config-mode-geo-location-with-map\n"
+#endif
+#else
+#ifdef WITHGELOC
+"Project-Id-Version: gluon-config-mode-geo-location-with-geloc\n"
+#else
+"Project-Id-Version: gluon-config-mode-geo-location\n"
+#endif
+#endif
+"PO-Revision-Date: 2017-08-22 12:14+0100\n"
+"Last-Translator: Jan-Tarek Butt <tarek@ring0.de>\n"
+"Language-Team: German\n"
+"Language: de\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=2; plural=(n != 1);\n"
+
+msgid ""
+"If you want the location of your node to be displayed on the map, you can "
+#ifdef WITHGELOC
+"set an automatically localization of your router or "
+#endif
+"enter its coordinates here. "
+#ifdef WITHMAP
+"If your PC is connected to the internet you can also click on the map displayed below. "
+#endif
+"Please keep in mind setting a location can also enhance the network quality."
+msgstr ""
+"Um Deinen Router auf der Karte anzeigen zu können, benötigen wir seine "
+"Koordinaten. Hier hast Du die Möglichkeit, "
+#ifdef WITHGELOC
+"das der Router seine Position automatisch bestimmt. Eine andere Option ist, "
+#endif
+"die Koordinaten händisch zu hinterlegen."
+#ifdef WITHMAP
+"Wenn dein Computer mit dem du den Router einrichtes am Internet angeschlossen ist, "
+"hast du die Möglichkeit auf der unten angezeigten Karte an die stelle zu klicken wo "
+"der Router Stehen wird."
+#endif
+"Bitte berücksichtige das, das setzen einer Position die Netzwerk Qualität verbessern kann."
+
+msgid "Geo-Location"
+msgstr "Geo-Position"
+
+#ifdef WITHGELOC
+msgid "Automatic (geolocator)"
+msgstr "Automatisch (geolocator)"
+#endif
+
+msgid "Static location"
+msgstr "Manuelle Position"
+
+#ifdef WITHGELOC
+msgid "Automatic & Static"
+msgstr "Automatisch & Manuell"
+#endif
+
+msgid "Disabled"
+msgstr "Deaktiviert"
+
+msgid "Share your location to see your router on the map"
+msgstr "Position für die Karte freigeben"
+
+#ifdef WITHGELOC
+msgid "Interval in minutes"
+msgstr "Intervall in Minuten"
+
+msgid "Set refresh interval"
+msgstr "Setze aktuallisierungs Intervall"
+#endif
+
+msgid "Latitude"
+msgstr "Breitengrad"
+
+msgid "Longitude"
+msgstr "Längengrad"
+
+msgid "e.g. %s"
+msgstr "z.B. %s"
diff --git a/package/gluon-config-mode-geo-location/src/fr.po.in b/package/gluon-config-mode-geo-location/src/fr.po.in
new file mode 100644
index 00000000..25de07b6
--- /dev/null
+++ b/package/gluon-config-mode-geo-location/src/fr.po.in
@@ -0,0 +1,83 @@
+msgid ""
+msgstr ""
+#ifdef WITHMAP
+#ifdef WITHGELOC
+"Project-Id-Version: gluon-config-mode-geo-location-with-geloc-map\n"
+#else
+"Project-Id-Version: gluon-config-mode-geo-location-with-map\n"
+#endif
+#else
+#ifdef WITHGELOC
+"Project-Id-Version: gluon-config-mode-geo-location-with-geloc\n"
+#else
+"Project-Id-Version: gluon-config-mode-geo-location\n"
+#endif
+#endif
+"PO-Revision-Date: 2017-08-22 12:14+0100\n"
+"Last-Translator: Jan-Tarek Butt <tarek@ring0.de>\n"
+"Language-Team: French\n"
+"Language: fr\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=2; plural=(n != 1);\n"
+
+msgid ""
+"If you want the location of your node to be displayed on the map, you can "
+#ifdef WITHGELOC
+"set an automatically localization of your router or "
+#endif
+"enter its coordinates here. "
+#ifdef WITHMAP
+"If your PC is connected to the internet you can also click on the map displayed below. "
+#endif
+"Please keep in mind setting a location can also enhance the network quality."
+msgstr ""
+"Si vous souhaitez que l'emplacement de votre nœud soit affiché sur la carte, vous pouvez "
+#ifdef WITHGELOC
+"définir une localisation automatique de votre routeur ou "
+#endif
+"entrer ses coordonnées ici."
+#ifdef WITHMAP
+"Si votre PC est connecté à Internet, vous pouvez également cliquer sur la carte ci-dessous."
+#endif
+"Gardez à l'esprit que la définition d'un emplacement peut également améliorer la qualité du réseau."
+
+msgid "Geo-Location"
+msgstr "Géolocalisation"
+
+#ifdef WITHGELOC
+msgid "Automatic (geolocator)"
+msgstr "Automatique (geolocator)"
+#endif
+
+msgid "Static location"
+msgstr "position manuelle"
+
+#ifdef WITHGELOC
+msgid "Automatic & Static"
+msgstr "Automatique et manuel"
+#endif
+
+msgid "Disabled"
+msgstr "Désactivé"
+
+msgid "Share your location to see your router on the map"
+msgstr "Partagez votre emplacement pour voir votre routeur sur la carte"
+
+#ifdef WITHGELOC
+msgid "Interval in minutes"
+msgstr "Intervalle en minutes"
+
+msgid "Set refresh interval"
+msgstr "Définir l'intervalle"
+#endif
+
+msgid "Latitude"
+msgstr "Latitude"
+
+msgid "Longitude"
+msgstr "Longitude"
+
+msgid "e.g. %s"
+msgstr "Ex: %s"
diff --git a/package/gluon-config-mode-geo-location/src/gluon-config-mode-geo-location.pot.in b/package/gluon-config-mode-geo-location/src/gluon-config-mode-geo-location.pot.in
new file mode 100644
index 00000000..799afc9c
--- /dev/null
+++ b/package/gluon-config-mode-geo-location/src/gluon-config-mode-geo-location.pot.in
@@ -0,0 +1,53 @@
+msgid ""
+msgstr "Content-Type: text/plain; charset=UTF-8"
+
+msgid ""
+"If you want the location of your node to be displayed on the map, you can "
+#ifdef WITHGELOC
+"set an automatically localization of your router or "
+#endif
+"enter its coordinates here. "
+#ifdef WITHMAP
+"If your PC is connected to the internet you can also click on the map displayed below. "
+#endif
+"Please keep in mind setting a location can also enhance the network quality."
+msgstr ""
+
+msgid "Geo-Location"
+msgstr ""
+
+#ifdef WITHGELOC
+msgid "Automatic (geolocator)"
+msgstr ""
+#endif
+
+msgid "Static location"
+msgstr ""
+
+#ifdef WITHGELOC
+msgid "Automatic & Static"
+msgstr ""
+#endif
+
+msgid "Disabled"
+msgstr ""
+
+msgid "Share your location to see your router on the map"
+msgstr ""
+
+#ifdef WITHGELOC
+msgid "Interval in minutes"
+msgstr ""
+
+msgid "Set refresh interval"
+msgstr ""
+#endif
+
+msgid "Latitude"
+msgstr ""
+
+msgid "Longitude"
+msgstr ""
+
+msgid "e.g. %s"
+msgstr ""
diff --git a/package/gluon-node-info/files/etc/config/gluon-node-info b/package/gluon-node-info/files/etc/config/gluon-node-info
index 8f6f472f..70026b5c 100644
--- a/package/gluon-node-info/files/etc/config/gluon-node-info
+++ b/package/gluon-node-info/files/etc/config/gluon-node-info
@@ -1,5 +1,5 @@
config location
- option share_location '0'
+ option share_location '1'
config owner
--
2.16.1
features({
'autoupdater',
'ebtables-filter-multicast',
'ebtables-filter-ra-dhcp',
'mesh-batman-adv-15',
%A
'respondd',
'status-page',
'web-advanced',
'web-wizard',
'ebtables-source-filter',
'radv-filterd',
'lock-password',
'web-private-wifi',
'web-logging',
'geolocator',
'config-mode-geo-location-osm',
'hoodselector'
})
packages({
'ffnw-banner',
'respondd-module-airtime',
'iwinfo',
'wget-ssl',
'ca-bundle',
'ca-certificates'
})
if not device_class('tiny') then
features({
'wireless-encryption-wpa3',
'web-cellular'
})
end
-- Custom package lists
local pkgs_usb_hid = {
'kmod-usb-hid',
'kmod-hid-generic'
}
local pkgs_usb_serial = {
'kmod-usb-serial',
'kmod-usb-serial-ch341',
'kmod-usb-serial-cp210x',
'kmod-usb-serial-ftdi',
'kmod-usb-serial-pl2303'
}
local pkgs_usb_storage = {
'block-mount',
'blkid',
'kmod-fs-ext4',
'kmod-fs-ntfs',
'kmod-fs-vfat',
'kmod-usb-storage',
'kmod-usb-storage-extras', -- Card Readers
'kmod-usb-storage-uas', -- USB Attached SCSI (UAS/UASP)
'kmod-nls-base',
'kmod-nls-cp1250', -- NLS Codepage 1250 (Eastern Europe)
'kmod-nls-cp437', -- NLS Codepage 437 (United States, Canada)
'kmod-nls-cp850', -- NLS Codepage 850 (Europe)
'kmod-nls-cp852', -- NLS Codepage 852 (Europe)
'kmod-nls-iso8859-1', -- NLS ISO 8859-1 (Latin 1)
'kmod-nls-iso8859-13', -- NLS ISO 8859-13 (Latin 7; Baltic)
'kmod-nls-iso8859-15', -- NLS ISO 8859-15 (Latin 9)
'kmod-nls-iso8859-2', -- NLS ISO 8859-2 (Latin 2)
'kmod-nls-utf8' -- NLS UTF-8
}
local pkgs_usb_net = {
'kmod-mii',
'kmod-usb-net',
'kmod-usb-net-asix',
'kmod-usb-net-asix-ax88179',
'kmod-usb-net-cdc-eem',
'kmod-usb-net-cdc-ether',
'kmod-usb-net-cdc-subset',
'kmod-usb-net-dm9601-ether',
'kmod-usb-net-hso',
'kmod-usb-net-ipheth',
'kmod-usb-net-mcs7830',
'kmod-usb-net-pegasus',
'kmod-usb-net-rndis',
'kmod-usb-net-rtl8152',
'kmod-usb-net-smsc95xx',
}
local pkgs_pci = {
'pciutils'
}
local pkgs_pci_net = {
'kmod-bnx2'
}
if target('ath79') then
if device({
'buffalo-wzr-hp-ag300h',
'devolo-wifi-pro-1750e',
'buffalo-wzr-600dhp',
'buffalo-wzr-hp-g300nh-rtl8366s',
'd-link-dir825b1',
'gl.inet-gl-ar150',
'gl.inet-6416',
'gl.inet-gl-ar150',
'gl.inet-gl-ar300m-nor',
'gl.inet-gl-ar300m-lite',
'gl.inet-gl-ar750',
'gl.inet-gl-ar750s-nor',
'gl.inet-gl-xe300',
'librerouter-v1',
'netgear-wndr3700',
'netgear-wndr3700-v2',
'netgear-wndr3700-v4',
'netgear-wndr3800',
'netgear-wndr3800ch',
'netgear-wndr4300',
'tp-link-archer-a7-v5',
'tp-link-archer-c5-v1',
'tp-link-archer-c7-v2',
'tp-link-archer-c7-v4',
'tp-link-archer-c7-v5',
'tp-link-archer-c59-v1',
'tp-link-tl-wdr3500-v1',
'tp-link-tl-wdr3600-v1',
'tp-link-tl-wdr4300-v1',
'tp-link-tl-wr842n-v3',
'tp-link-tl-wr902ac-v1',
'tp-link-tl-wr1043nd-v2',
'tp-link-tl-wr1043nd-v3',
'tp-link-tl-wr1043nd-v4',
}) then
packages(pkgs_usb_serial)
end
end
if target('ipq40xx') then
packages(pkgs_usb_serial)
packages(pkgs_usb_storage)
end
if target('ipq806x') then
packages(pkgs_usb_serial)
packages(pkgs_usb_storage)
end
if target('mediatek') then
packages(pkgs_usb_serial)
packages(pkgs_usb_storage)
end
if target('mpc85xx') then
packages(pkgs_usb_serial)
packages(pkgs_usb_storage)
end
if target('ramips', 'mt7621') then
packages(pkgs_usb_serial)
end
if target('rockchip') then
-- No PCI / video
packages(pkgs_usb_net)
packages(pkgs_usb_serial)
packages(pkgs_usb_storage)
end
if target('sunxi') then
-- No PCI / video
packages(pkgs_usb_serial)
packages(pkgs_usb_storage)
end
-- Include all custom packages for RaspberryPi
if target('bcm27xx') then
packages(pkgs_usb_hid)
packages(pkgs_usb_net)
packages(pkgs_usb_serial)
packages(pkgs_usb_storage)
end
-- Include all custom packages for x86
if target('x86') then
packages(pkgs_pci)
packages(pkgs_pci_net)
packages(pkgs_usb_hid)
packages(pkgs_usb_net)
packages(pkgs_usb_serial)
packages(pkgs_usb_storage)
end
-- the Network-activated setup-mode allows us to unbreak the device
if device({'zyxel-nwa55axe'}) then
broken(false)
packages({'ffda-network-setup-mode'})
end
GLUON_SITE_FEEDS='ffnw ffho tecff'
GLUON_SITE_FEEDS='ffnw community'
PACKAGES_FFNW_REPO=https://git.nordwest.freifunk.net/ffnw-firmware/packages.git
PACKAGES_FFNW_REPO=https://git.ffnw.de/ffnw-firmware/packages.git
PACKAGES_FFNW_BRANCH=master
PACKAGES_FFNW_COMMIT=64ba97cb4238c9cdbda1a8c54989fd72a98ce5f9
PACKAGES_FFNW_COMMIT=44d6aeca186e5ff92e8372f0a7e774d5ca443d3e
PACKAGES_FFHO_REPO=https://git.ffho.net/FreifunkHochstift/ffho-packages.git
PACKAGES_FFHO_BRANCH=v2017.1.x
PACKAGES_FFHO_COMMIT=806f98a8f4bc0896ba29b903a8b9f72c39db2f09
PACKAGES_TECFF_REPO=https://github.com/tecff/gluon-packages.git
PACKAGES_TECFF_BRANCH=v2018.1.x
PACKAGES_TECFF_COMMIT=7964a2884f1b43d994f8d1da931e89c5d36d3890
PACKAGES_COMMUNITY_REPO=https://github.com/freifunk-gluon/community-packages.git
PACKAGES_COMMUNITY_COMMIT=bd78c4cea3fd2e203c0628ded1098c7a92cb3ae4
PACKAGES_COMMUNITY_BRANCH=master
......@@ -2,9 +2,7 @@
hostname_prefix = 'ffnw-',
site_name = 'Freifunk Nordwest',
site_code = 'ffnw',
domain_seed = '7e960cab48068f4b17f865a04c211a27478dc25873d693775034ecf46d90a0cb',
prefix6 = 'fd74:fdaa:9dc4::/64',
default_domain = 'default',
timezone = 'CET-1CEST,M3.5.0,M10.5.0/3', -- Europe/Berlin
......@@ -18,77 +16,62 @@
regdom = 'DE',
radv_filterd = {
threshold = 20,
},
wifi24 = {
channel = 6,
supported_rates = {6000, 9000, 12000, 18000, 24000, 36000, 48000, 54000},
basic_rate = {6000, 9000, 18000, 36000, 54000},
ap = {
ssid = 'testing.nordwest.freifunk.net',
},
mesh = {
id = 't-ffnw-mesh_02:00:0A:12:E0:00',
mcast_rate = 12000,
},
},
wifi5 = {
channel = 44,
ap = {
ssid = 'testing.nordwest.freifunk.net',
},
outdoor_chanlist = '100-140',
mesh = {
id = 't-ffnw-mesh_02:00:0A:12:E0:00',
mcast_rate = 12000,
},
},
dns = {
servers = {'2001:1b60:3:34:7711:1:0:1','2001:67c:1400:2250::1'},
},
next_node = {
name = { 'node.ffnw', 'nextnode', 'nn' },
ip6 = 'fd74:fdaa:9dc4::127',
mac = '16:41:95:40:f7:dc',
dns = {
cacheentries = 5000,
servers = {'2a06:e881:2000:8::1','2a06:e881:2000:7::1'},
},
mesh = {
vxlan = false,
batman_adv = {
gw_sel_class = 1, --class 1 is calculated from both the TQ and the announced bandwidth.
routing_algo = "BATMAN_IV", -- also possible: "BATMAN_V" and "BATMAN_IV_LEGACY", but this value may not be unset
},
},
mesh_vpn = {
enabled = true,
mtu = 1312,
fastd = {
methods = { 'null','salsa2012+umac' },
configurable = true,
groups = {
backbone = {
limit = 1,
peers = {
default06 = {
key ='22e270ff9b2d1017c3a0b00dd22a58ef7e5915a355eeb16f0b8b52d7eb377869',
remotes = {'"default06.ffnw.de" port 11111'},
},
},
},
},
},
tunneldigger = {
brokers = {'default06.ffnw.de:9000'}
mtu = 1312,
},
-- The bandwidth limit can be enabled by default here.
bandwidth_limit = {
enabled = false,
-- Default upload limit (kbit/s).
egress = 1800,
-- Default download limit (kbit/s).
ingress = 14400,
},
},
mesh_on_wan = false,
mesh_on_lan = false,
poe_passthrough = false,
interfaces = {
lan = {
default_roles = { 'client' },
},
wan = {
default_roles = { 'uplink' },
},
single = {
default_roles = { 'uplink' },
},
},
autoupdater = {
branch = 'stable',
......@@ -98,45 +81,54 @@
mirrors = {
%B
},
good_signatures = 4,
good_signatures = 3,
pubkeys = {
'22c79b193a36269fd7fd51531e762b776e982926c90822df80b56f2be11648d4', --bjo
'99c420e95dd0923ee6277af5c306f9ae6b97f8793b08edd41448925df5fe35b9', --floh1111
'd2b1366a38514e0fac47b119a8a08973ea8020bf9c138908d32b56a5d99f3079', --baranator
'5d95cc2ef3ad17fe3716469e1effde4a49a25d4de9befa4a6eb260e4cda79ab0', --tata
'0e6704ba26c150185514a391658455a612839c35bd83e0faffa81e0be48356e2', --sk
'1f45d9be8a07cc2b6fcc384c71685fc0895a54be0d884aa4637c93ec4f36d970', --stefan6
'36dff98a686a15d7fb129fe98df7977c7d53919aa512b825356bd8d638fca534', --PowerPan
'13f022eb0704007a58a6a68952feaa5a91af4015db46f13bf3eb676a06e926f2', --fkr
'785004680028afc482a5c92b392d6d7ebdfa26a48e678cb447e78d9b2eb84556', --f700w
'd3a4cbc90a2d4dbfc5386dd035016a04bfdfe1e7615fa8ea25bea5c048a7f106', --lrnzo
'e3d2e96563b9be3e95a3d748c0ff50a6f854208b68b4a1181667641d74754c76', --stefan
},
},
rc = {
name = 'stable',
mirrors = {
%C
},
good_signatures = 1,
pubkeys = {
'99c420e95dd0923ee6277af5c306f9ae6b97f8793b08edd41448925df5fe35b9', --floh1111
'5d95cc2ef3ad17fe3716469e1effde4a49a25d4de9befa4a6eb260e4cda79ab0', --tata
'0e6704ba26c150185514a391658455a612839c35bd83e0faffa81e0be48356e2', --sk
'785004680028afc482a5c92b392d6d7ebdfa26a48e678cb447e78d9b2eb84556', --f700w
'd3a4cbc90a2d4dbfc5386dd035016a04bfdfe1e7615fa8ea25bea5c048a7f106', --lrnzo
'e3d2e96563b9be3e95a3d748c0ff50a6f854208b68b4a1181667641d74754c76', --stefan
},
},
testing = {
name = 'testing',
mirrors = {
%C
%D
},
good_signatures = 1,
pubkeys = {
'22c79b193a36269fd7fd51531e762b776e982926c90822df80b56f2be11648d4', --bjo
'99c420e95dd0923ee6277af5c306f9ae6b97f8793b08edd41448925df5fe35b9', --floh1111
'd2b1366a38514e0fac47b119a8a08973ea8020bf9c138908d32b56a5d99f3079', --baranator
'5d95cc2ef3ad17fe3716469e1effde4a49a25d4de9befa4a6eb260e4cda79ab0', --tata
'0e6704ba26c150185514a391658455a612839c35bd83e0faffa81e0be48356e2', --sk
'1f45d9be8a07cc2b6fcc384c71685fc0895a54be0d884aa4637c93ec4f36d970', --stefan6
'36dff98a686a15d7fb129fe98df7977c7d53919aa512b825356bd8d638fca534', --PowerPan
'13f022eb0704007a58a6a68952feaa5a91af4015db46f13bf3eb676a06e926f2', --fkr
'785004680028afc482a5c92b392d6d7ebdfa26a48e678cb447e78d9b2eb84556', --f700w
'd3a4cbc90a2d4dbfc5386dd035016a04bfdfe1e7615fa8ea25bea5c048a7f106', --lrnzo
'e3d2e96563b9be3e95a3d748c0ff50a6f854208b68b4a1181667641d74754c76', --stefan
},
},
nightly_master = {
name = 'nightly_master',
mirrors = {
%D
%E
},
good_signatures = 1,
pubkeys = {
'f89880c62f6975facbffa582f6a7078a63102477f1770f429f4e6e2a1ac7506f', --runner01.ffnw.de
'f89880c62f6975facbffa582f6a7078a63102477f1770f429f4e6e2a1ac7506f', --runner01.ffnw.de
},
},
},
......@@ -144,40 +136,13 @@
config_mode = {
geo_location = {
map_lon = 52.951947558,
map_lat = 7.844238281,
show_altitude = true,
osm = {
center = {
lat = 53.084126922,
lon = 7.915649414,
},
},
},
},
geolocator = {
autolocation = true,
interval = 1000,
blacklist = {
'02:00:0A:12:E0:00',
'02:00:0A:12:80:00',
'02:00:0A:12:88:00',
'02:00:0A:12:98:00',
'02:00:0A:12:90:00',
'02:00:0A:12:B0:00',
'02:00:0A:12:B8:00',
'02:00:0A:12:A0:00',
'02:00:0A:12:A8:00',
'02:00:0A:12:C0:00',
'02:00:0A:12:C8:00',
'02:00:0A:12:D0:00',
'02:00:0A:12:28:00',
'02:00:0A:12:E8:00',
'02:00:0A:12:20:00',
'02:00:0A:12:38:00',
'02:00:0A:12:30:00',
'02:00:0A:12:48:00',
'02:00:0A:12:40:00',
'02:00:0A:12:50:00',
'02:00:0A:12:58:00',
'02:00:0A:12:60:00',
'02:00:0A:12:18:00',
'02:00:0A:12:68:00',
'02:00:0A:12:D8:00',
},
},
}
GLUON_FEATURES := \
web-wizard \
autoupdater \
web-advanced \
status-page \
mesh-batman-adv-15 \
%A
ebtables-filter-multicast \
ebtables-filter-ra-dhcp \
ebtables-limit-arp \
radvd \
radv-filterd \
web-private-wifi \
geolocator \
web-logging \
hoodselector
GLUON_SITE_PACKAGES := \
-gluon-config-mode-geo-location \
gluon-config-mode-geo-location-with-geloc-map \
-gluon-web-autoupdater \
ffho-web-autoupdater \
haveged \
iwinfo \
tecff-ath9k-broken-wifi-workaround \
ffnw-banner \
ffnw-hoods \
ffnw-multiple-v6-watchdoog
USB_BASIC := \
kmod-usb-core \
kmod-usb2 \
kmod-usb-hid
USB_NIC := \
kmod-usb-net \
kmod-usb-net-asix \
kmod-usb-net-rtl8150 \
kmod-usb-net-rtl8152 \
kmod-usb-net-dm9601-ether \
kmod-usb-net-mcs7830
ifeq ($(GLUON_TARGET),x86-generic)
GLUON_SITE_PACKAGES += \
$(USB_BASIC) \
kmod-usb-ohci-pci \
$(USB_NIC) \
kmod-phy-broadcom
endif
ifeq ($(GLUON_TARGET),x86-64)
GLUON_SITE_PACKAGES += \
$(USB_BASIC) \
$(USB_NIC) \
kmod-phy-broadcom \
kmod-igb
endif
GLUON_ATH10K_MESH := 11s
GLUON_MULTIDOMAIN=1
# Allow overriding from the command line
%B
%C
GLUON_AUTOUPDATER_ENABLED ?= 1
GLUON_DEPRECATED ?= upgrade
GLUON_LANGS ?= de en
GLUON_PRIORITY ?= 0
GLUON_REGION ?= eu
GLUON_LANGS ?= de en