Compare commits

...

7 Commits

Author SHA1 Message Date
Christian Dresel bd092168bb Merge branch 'ipv4snatV2' of https://git.freifunk-franken.de/ChristianD/firmware into CHD-20210220 2021-02-20 07:21:00 +00:00
Christian Dresel f0c53a61cb Merge branch 'mqtt' of https://git.freifunk-franken.de/ChristianD/firmware into CHD-20210220 2021-02-20 07:20:08 +00:00
Christian Dresel fe06eae15c packages/fff: Add package fff-web-mqtt
With this package the mqtt settings can configure over the webui

Each user kann use its own mqtt broker or a broker from a other user
This means that the user has a free choice of where to send or get data

Signed-off-by: Christian Dresel <freifunk@dresel.systems>
2021-02-14 10:39:16 +01:00
Christian Dresel ab5c00fb51 packages/fff: Add package fff-mqtt-monitoring
This package send Alfred data to the mqtt broker

Anyone can access this data and can build its own monitoring

Signed-off-by: Christian Dresel <freifunk@dresel.systems>
2021-02-14 10:39:13 +01:00
Christian Dresel 0b585e5273 Add package fff-layer3-ipv4snat
With this package it is possible to make SNAT with IPv4 on the router

The user must set a peer_ip setting in gateway.meta.peer_ip to get a single ip for peering interfaces.
At ipaddr the user must set a ip that not use in babel (e.g. 192.168.0.1/16) for the clients

With this package the ipaddr address is SNAT to the peer_ip and every router need only one
freifunk ip and can use the same ipaddr on every router.

It is a system like cgnat from big provider

Signed-off-by: Christian Dresel <freifunk@dresel.systems>
2021-02-13 17:45:18 +01:00
Christian Dresel 93106ff9d6 fff-firewall: Flush nat und mangle iptables table
We should flush all tables and not only filter to reset the complete firewall

Signed-off-by: Christian Dresel <freifunk@dresel.systems>
2021-01-28 09:48:12 +01:00
Christian Dresel 706736eeca packages/fff: Add package fff-mqtt
This package provides mosquitto and set default settings

mosquitto is used for mqtt communication.
With mqtt we can use a distributed mqtt broker for decentralized communication

We can use this for monitoring data or router configuration

Signed-off-by: Christian Dresel <freifunk@dresel.systems>
2021-01-01 11:08:14 +01:00
14 changed files with 221 additions and 0 deletions

View File

@ -2,6 +2,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=fff-firewall
PKG_RELEASE:=6
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
include $(INCLUDE_DIR)/package.mk

View File

@ -5,5 +5,11 @@ ebtables -X
iptables -F
iptables -X
iptables -F -t nat
iptables -X -t nat
iptables -F -t mangle
iptables -X -t mangle
ip6tables -F
ip6tables -X

View File

@ -0,0 +1,32 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=fff-layer3-ipv4snat
PKG_RELEASE:=1
include $(INCLUDE_DIR)/package.mk
define Package/fff-layer3-ipv4snat
SECTION:=base
CATEGORY:=Freifunk
TITLE:=Freifunk-Franken layer3 configuration with SNAT
URL:=https://www.freifunk-franken.de
DEPENDS:= \
+iptables-mod-nat-extra \
+fff-firewall \
+fff-layer3-config
endef
define Package/fff-layer3-ipv4snat/description
With this package it is possible to make SNAT with IPv4 on the router
endef
define Build/Compile
# nothing
endef
define Package/fff-layer3-ipv4snat/install
$(CP) ./files/* $(1)/
endef
$(eval $(call BuildPackage,fff-layer3-ipv4snat))

View File

@ -0,0 +1,31 @@
configure() {
# first we delete the snat config
uci -q del network.client.nat
if [ "$(uci -q get gateway.@client[0].nat)" = '1' ]; then
# first check the config is plausible
if ! peer_ip=$(uci get gateway.meta.peer_ip); then
echo "ERROR: No peer_ip set! For SNAT use you must set a peer_ip"
return 1
fi
if ! ipaddr=$(uci get gateway.@client[0].ipaddr); then
echo "ERROR: No ipaddr set! For SNAT use you must set ipaddr"
return 1
fi
# We set the snat config
uci set network.client.nat=1
fi
}
reload() {
/etc/init.d/fff-firewall start
}
apply() {
uci commit network
}
revert() {
uci revert network
}

View File

@ -0,0 +1,7 @@
if [ "$(uci -q get gateway.@client[0].nat)" = '1' ]; then
peer_ip=$(uci get gateway.meta.peer_ip)
ipaddr=$(uci get gateway.@client[0].ipaddr)
for ip in $ipaddr; do
iptables -t nat -A POSTROUTING -s $ip -j SNAT --to-source $peer_ip
done
fi

View File

@ -2,6 +2,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=fff-layer3
PKG_RELEASE:=8
PKG_BUILD_DIR:=$(BUILD_DIR)/fff-layer3
include $(INCLUDE_DIR)/package.mk
@ -15,8 +16,11 @@ define Package/fff-layer3
+fff-boardname \
+fff-dhcp \
+fff-layer3-config \
+fff-mqtt-monitoring \
+fff-layer3-ipv4snat \
+fff-network \
+fff-ra \
+fff-web-mqtt \
+fff-wireguard \
+arptables \
+bmon \

View File

@ -0,0 +1,35 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=fff-mqtt-monitoring
PKG_RELEASE:=1
PKG_BUILD_DIR:=$(BUILD_DIR)/fff-mqtt-monitoring
include $(INCLUDE_DIR)/package.mk
define Package/fff-mqtt-monitoring
SECTION:=base
CATEGORY:=Freifunk
TITLE:=Freifunk-Franken mqtt configuration
URL:=https://www.freifunk-franken.de
DEPENDS:= \
+alfred-json \
+fff-mqtt \
+micrond \
+fff-alfred
endef
define Package/fff-mqtt-monitoring/description
This package send monitoring informations to
the mqtt broker
endef
define Build/Compile
# nothing
endef
define Package/fff-mqtt-monitoring/install
$(CP) ./files/* $(1)/
endef
$(eval $(call BuildPackage,fff-mqtt-monitoring))

View File

@ -0,0 +1 @@
*/5 * * * * sleep $(/usr/bin/random 70 85); /usr/sbin/alfred-mqtt-proxy

View File

@ -0,0 +1,8 @@
#!/bin/sh
MACADDR=$(cat /sys/class/net/br-client/address | /bin/sed 's/://g')
fetch_id="64"
if [ -n "$(uci -q get fff.mqtt.server)" ] ; then
mosquitto_pub -h "$(uci get fff.mqtt.server)" -p 1883 -t /monitoring/v1/$MACADDR -m "$(/bin/alfred-json -r "$fetch_id")"
fi

View File

@ -0,0 +1,34 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=fff-mqtt
PKG_RELEASE:=1
PKG_BUILD_DIR:=$(BUILD_DIR)/fff-mqtt
include $(INCLUDE_DIR)/package.mk
define Package/fff-mqtt
SECTION:=base
CATEGORY:=Freifunk
TITLE:=Freifunk-Franken mqtt configuration
URL:=https://www.freifunk-franken.de
DEPENDS:= \
+fff-config \
+libmosquitto-ssl \
+mosquitto-client-ssl \
+mosquitto-ssl
endef
define Package/fff-mqtt/description
This package provides mosquitto and settings
endef
define Build/Compile
# nothing
endef
define Package/fff-mqtt/install
$(CP) ./files/* $(1)/
endef
$(eval $(call BuildPackage,fff-mqtt))

View File

@ -0,0 +1,3 @@
uci set fff.mqtt=mqtt
exit 0

View File

@ -0,0 +1,32 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=fff-web-mqtt
PKG_RELEASE:=1
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
include $(INCLUDE_DIR)/package.mk
define Package/fff-web-mqtt
SECTION:=base
CATEGORY:=Freifunk
TITLE:=Freifunk-Franken mqtt config webui
URL:=http://www.freifunk-franken.de
DEPENDS:= \
+fff-mqtt \
+fff-web-ui
endef
define Package/fff-web-mqtt/description
Configure mqtt via a web UI
endef
define Build/Compile
# nothing
endef
define Package/fff-web-mqtt/install
$(CP) ./files/* $(1)/
endef
$(eval $(call BuildPackage,fff-web-mqtt))

View File

@ -0,0 +1 @@
mqtt,MQTT-Einstellungen

View File

@ -0,0 +1,26 @@
#!/usr/bin/haserl
<%in /www/include/header %>
<%in /www/include/helpers %>
<% show_msg %>
<%
# write
if [ "$REQUEST_METHOD" = "POST" ] ; then
uci -q set "fff.mqtt.server=${POST_server}"
uci commit fff
fi
%>
<form method="post">
<fieldset style="min-height: 7em;" class="smallinput">
<legend>MQTT</legend>
<table>
<tr><th>Server:</th><td><input type="text" name="server" value="<%= $(uci -q get fff.mqtt.server) %>" /></td></tr>
</table>
</fieldset>
<input type="submit" style="margin-top: 5px; margin-left: 3px;" />
</form>
<%in /www/include/footer %>