From badbe68a1c2e21184f1fd36d4d4801f5411bcf89 Mon Sep 17 00:00:00 2001 From: Jan Date: Thu, 2 May 2019 11:59:49 +0200 Subject: [PATCH] Added wifi encrypt --- package/gluon-wlan-encryption-psk/Makefile | 13 ++++++++++++ package/gluon-wlan-encryption-psk/Readme.md | 15 +++++++++++++ .../gluon-wlan-encryption-psk/check_site.lua | 1 + .../upgrade/390-gluon-wlan-encryption-psk | 21 +++++++++++++++++++ 4 files changed, 50 insertions(+) create mode 100644 package/gluon-wlan-encryption-psk/Makefile create mode 100644 package/gluon-wlan-encryption-psk/Readme.md create mode 100644 package/gluon-wlan-encryption-psk/check_site.lua create mode 100755 package/gluon-wlan-encryption-psk/luasrc/lib/gluon/upgrade/390-gluon-wlan-encryption-psk diff --git a/package/gluon-wlan-encryption-psk/Makefile b/package/gluon-wlan-encryption-psk/Makefile new file mode 100644 index 00000000..5122da5f --- /dev/null +++ b/package/gluon-wlan-encryption-psk/Makefile @@ -0,0 +1,13 @@ +include $(TOPDIR)/rules.mk + +PKG_NAME:=gluon-wlan-encryption-psk +PKG_VERSION:=1 + +include ../gluon.mk + +define Package/gluon-wlan-encryption-psk + TITLE:=Encrypt wlan using a pre-shared key (psk) + DEPENDS:=+gluon-core +wpad-mesh-wolfssl +endef + +$(eval $(call BuildPackageGluon,gluon-wlan-encryption-psk)) diff --git a/package/gluon-wlan-encryption-psk/Readme.md b/package/gluon-wlan-encryption-psk/Readme.md new file mode 100644 index 00000000..9b4e94c2 --- /dev/null +++ b/package/gluon-wlan-encryption-psk/Readme.md @@ -0,0 +1,15 @@ +# Gluon wlan encrypt +Encrypt wireless networks in a non-Freifunk setup. + +This package allows to encrypt 802.11s and infrastructure networks using a pre shared key (psk). + +This setup results in passwords being stored in plain-text. Site-configuration, Firmware-downloads and +Devices must be protected against unauthorized access + +*make sure to use exclude hostapd-mini site.mk* + +Example configuration: + +```lua +wlan_encryption_psk = { mesh = '802.11s.passwd', ap = ' infrastructure.passwd', }, +``` diff --git a/package/gluon-wlan-encryption-psk/check_site.lua b/package/gluon-wlan-encryption-psk/check_site.lua new file mode 100644 index 00000000..11341585 --- /dev/null +++ b/package/gluon-wlan-encryption-psk/check_site.lua @@ -0,0 +1 @@ +need_table({'wlan_encryption_psk'}) diff --git a/package/gluon-wlan-encryption-psk/luasrc/lib/gluon/upgrade/390-gluon-wlan-encryption-psk b/package/gluon-wlan-encryption-psk/luasrc/lib/gluon/upgrade/390-gluon-wlan-encryption-psk new file mode 100755 index 00000000..3cdc2066 --- /dev/null +++ b/package/gluon-wlan-encryption-psk/luasrc/lib/gluon/upgrade/390-gluon-wlan-encryption-psk @@ -0,0 +1,21 @@ +#!/usr/bin/lua + +local site = require 'gluon.site' +local uci = require('simple-uci').cursor() + +local ap_password = site.wlan_encryption_psk()["ap"] +local mesh_password = site.wlan_encryption_psk()["mesh"] + + +uci:foreach('wireless', 'wifi-iface', function(wifi_if) + local ifname = wifi_if['.name'] + if wifi_if.mode == 'ap' and ap_password ~= nil and ap_password ~= '' then + uci:set('wireless', ifname, 'encryption', 'psk2') + uci:set('wireless', ifname, 'key', ap_password) + elseif wifi_if.mode == "mesh" and mesh_password ~= nil and mesh_password ~= '' then + uci:set('wireless', ifname, 'encryption', 'psk2/aes') + uci:set('wireless', ifname, 'key', mesh_password) + end +end) + +uci:save('wireless')