From e47f42d8114312229dfc9131e24d1747dd20ee1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20Kr=C3=BCger?= Date: Thu, 7 Apr 2022 16:49:45 +0200 Subject: [PATCH] web-private-ap: init --- package/gluon-web-private-ap/Makefile | 12 +++ package/gluon-web-private-ap/i18n/de.po | 59 +++++++++++++ package/gluon-web-private-ap/i18n/fr.po | 50 +++++++++++ .../i18n/gluon-web-private-ap.pot | 47 +++++++++++ .../controller/admin/privateap.lua | 8 ++ .../config-mode/model/admin/privateap.lua | 84 +++++++++++++++++++ 6 files changed, 260 insertions(+) create mode 100644 package/gluon-web-private-ap/Makefile create mode 100644 package/gluon-web-private-ap/i18n/de.po create mode 100644 package/gluon-web-private-ap/i18n/fr.po create mode 100644 package/gluon-web-private-ap/i18n/gluon-web-private-ap.pot create mode 100644 package/gluon-web-private-ap/luasrc/lib/gluon/config-mode/controller/admin/privateap.lua create mode 100644 package/gluon-web-private-ap/luasrc/lib/gluon/config-mode/model/admin/privateap.lua diff --git a/package/gluon-web-private-ap/Makefile b/package/gluon-web-private-ap/Makefile new file mode 100644 index 00000000..2c40e740 --- /dev/null +++ b/package/gluon-web-private-ap/Makefile @@ -0,0 +1,12 @@ +include $(TOPDIR)/rules.mk + +PKG_NAME:=gluon-web-private-ap + +include ../gluon.mk + +define Package/gluon-web-private-ap + DEPENDS:=+gluon-web-admin +gluon-private-ap + TITLE:=UI for activating a private AP +endef + +$(eval $(call BuildPackageGluon,gluon-web-private-ap)) diff --git a/package/gluon-web-private-ap/i18n/de.po b/package/gluon-web-private-ap/i18n/de.po new file mode 100644 index 00000000..fe13ce51 --- /dev/null +++ b/package/gluon-web-private-ap/i18n/de.po @@ -0,0 +1,59 @@ +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"PO-Revision-Date: 2015-05-04 02:25+0200\n" +"Last-Translator: \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 "8-63 characters" +msgstr "8-63 Zeichen" + +msgid "Disabled" +msgstr "Deaktiviert" + +msgid "Enabled" +msgstr "Aktiviert" + +msgid "Encryption" +msgstr "Verschlüsselung" + +msgid "Key" +msgstr "Schlüssel" + +msgid "Management Frame Protection" +msgstr "" + +msgid "Name (SSID)" +msgstr "Name (SSID)" + +msgid "Optional" +msgstr "" + +msgid "Private WLAN" +msgstr "Privates WLAN" + +msgid "Required" +msgstr "Aktiviert" + +msgid "WPA2" +msgstr "" + +msgid "WPA2 / WPA3" +msgstr "" + +msgid "WPA3" +msgstr "" + +msgid "" +"Your node can additionally offer a private client access point " +"which allows you to use the mesh like regular private wifi " +"with your own network, LAN addresses, password, etc." +msgstr "" +"Dein Knoten kann zusätzlich einen privaten Klient Zugangspunkt anbieten. " +"Das erlaubt dir das mesh wie ein normales Privat-WLAN zu verwenden, " +"das ein eigenes Netz, eigene LAN-Addressesn, ein eigens Passwort, etc hat." diff --git a/package/gluon-web-private-ap/i18n/fr.po b/package/gluon-web-private-ap/i18n/fr.po new file mode 100644 index 00000000..271307be --- /dev/null +++ b/package/gluon-web-private-ap/i18n/fr.po @@ -0,0 +1,50 @@ +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"PO-Revision-Date: 2015-08-19 23:30+0100\n" +"Last-Translator:Tobias Bernot \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 "8-63 characters" +msgstr "8-63 charactères" + +msgid "Disabled" +msgstr "" + +msgid "Enabled" +msgstr "Activé" + +msgid "Encryption" +msgstr "" + +msgid "Key" +msgstr "Clé" + +msgid "Management Frame Protection" +msgstr "" + +msgid "Name (SSID)" +msgstr "Nom (SSID)" + +msgid "Optional" +msgstr "" + +msgid "Private WLAN" +msgstr "Wi-Fi privé" + +msgid "Required" +msgstr "" + +msgid "WPA2" +msgstr "" + +msgid "WPA2 / WPA3" +msgstr "" + +msgid "WPA3" +msgstr "" diff --git a/package/gluon-web-private-ap/i18n/gluon-web-private-ap.pot b/package/gluon-web-private-ap/i18n/gluon-web-private-ap.pot new file mode 100644 index 00000000..ed0a147f --- /dev/null +++ b/package/gluon-web-private-ap/i18n/gluon-web-private-ap.pot @@ -0,0 +1,47 @@ +msgid "" +msgstr "Content-Type: text/plain; charset=UTF-8" + +msgid "8-63 characters" +msgstr "" + +msgid "Disabled" +msgstr "" + +msgid "Enabled" +msgstr "" + +msgid "Encryption" +msgstr "" + +msgid "Key" +msgstr "" + +msgid "Management Frame Protection" +msgstr "" + +msgid "Name (SSID)" +msgstr "" + +msgid "Optional" +msgstr "" + +msgid "Private WLAN" +msgstr "" + +msgid "Required" +msgstr "" + +msgid "WPA2" +msgstr "" + +msgid "WPA2 / WPA3" +msgstr "" + +msgid "WPA3" +msgstr "" + +msgid "" +"Your node can additionally offer a private client access point " +"which allows you to use the mesh like regular private wifi " +"with your own network, LAN addresses, password, etc." +msgstr "" diff --git a/package/gluon-web-private-ap/luasrc/lib/gluon/config-mode/controller/admin/privateap.lua b/package/gluon-web-private-ap/luasrc/lib/gluon/config-mode/controller/admin/privateap.lua new file mode 100644 index 00000000..6c364a5b --- /dev/null +++ b/package/gluon-web-private-ap/luasrc/lib/gluon/config-mode/controller/admin/privateap.lua @@ -0,0 +1,8 @@ +local uci = require("simple-uci").cursor() +local wireless = require 'gluon.wireless' + +package 'gluon-web-private-ap' + +if wireless.device_uses_wlan(uci) then + entry({"admin", "privatewifi"}, model("admin/privateap"), _("Private AP"), 30) +end diff --git a/package/gluon-web-private-ap/luasrc/lib/gluon/config-mode/model/admin/privateap.lua b/package/gluon-web-private-ap/luasrc/lib/gluon/config-mode/model/admin/privateap.lua new file mode 100644 index 00000000..635ece34 --- /dev/null +++ b/package/gluon-web-private-ap/luasrc/lib/gluon/config-mode/model/admin/privateap.lua @@ -0,0 +1,84 @@ +local uci = require("simple-uci").cursor() +local wireless = require 'gluon.wireless' + +-- where to read the configuration from +local primary_iface = 'ap_radio0' + +local f = Form(translate("Private AP")) + +local s = f:section(Section, nil, translate( + 'Your node can additionally offer a private client access point ' + .. 'which allows you to use the mesh like regular private wifi ' + .. 'with your own network, LAN addresses, password, etc.' +)) + +local enabled = s:option(Flag, "enabled", translate("Enabled")) +enabled.default = uci:get('wireless', primary_iface) and not uci:get_bool('wireless', primary_iface, "disabled") + +local ssid = s:option(Value, "ssid", translate("Name (SSID)")) +ssid:depends(enabled, true) +ssid.datatype = "maxlength(32)" +ssid.default = uci:get('wireless', primary_iface, "ssid") + +local key = s:option(Value, "key", translate("Key"), translate("8-63 characters")) +key:depends(enabled, true) +key.datatype = "wpakey" +key.default = uci:get('wireless', primary_iface, "key") + +local encryption = s:option(ListValue, "encryption", translate("Encryption")) +encryption:depends(enabled, true) +encryption:value("psk2", translate("WPA2")) +if wireless.device_supports_wpa3() then + encryption:value("psk3-mixed", translate("WPA2 / WPA3")) + encryption:value("psk3", translate("WPA3")) +end +encryption.default = uci:get('wireless', primary_iface, 'encryption') or "psk2" + +local mfp = s:option(ListValue, "mfp", translate("Management Frame Protection")) +mfp:depends(enabled, true) +mfp:value("0", translate("Disabled")) +if wireless.device_supports_mfp(uci) then + mfp:value("1", translate("Optional")) + mfp:value("2", translate("Required")) +end +mfp.default = uci:get('wireless', primary_iface, 'ieee80211w') or "0" + +-- TODO: ipv4 when prefix4() set? or always? allow custom cidr +-- TODO: allow mesh (regular meshing) on private net? + +function f:write() + wireless.foreach_radio(uci, function(radio, index) + local radio_name = radio['.name'] + local suffix = radio_name:match('^radio(%d+)$') + local name = "ap_" .. radio_name + + if enabled.data then + local macaddr = wireless.get_wlan_mac(uci, radio, index, 5) + + uci:section('wireless', 'wifi-iface', name, { + device = radio_name, + network = 'ap', + mode = 'ap', + encryption = encryption.data, + ssid = ssid.data, + key = key.data, + macaddr = macaddr, + ifname = suffix and 'ap' .. suffix, + disabled = false, + }) + + -- hostapd-mini won't start in case 802.11w is configured + if wireless.device_supports_mfp(uci) then + uci:set('wireless', name, 'ieee80211w', mfp.data) + else + uci:delete('wireless', name, 'ieee80211w') + end + else + uci:set('wireless', name, "disabled", true) + end + end) + + uci:commit('wireless') +end + +return f