diff --git a/net/wifidog-ng/Makefile b/net/wifidog-ng/Makefile index a4d440284..700aee578 100644 --- a/net/wifidog-ng/Makefile +++ b/net/wifidog-ng/Makefile @@ -8,13 +8,13 @@ include $(TOPDIR)/rules.mk PKG_NAME:=wifidog-ng -PKG_VERSION:=1.3.0 +PKG_VERSION:=1.4.0 PKG_RELEASE:=1 PKG_SOURCE_PROTO:=git PKG_SOURCE_VERSION:=v$(PKG_VERSION) PKG_SOURCE_URL=https://github.com/zhaojh329/wifidog-ng.git -PKG_MIRROR_HASH:=a65ecad48dd3668a1f7416fd7882386a57b8bccf503e353224dbca54c398f052 +PKG_MIRROR_HASH:=f9c48e09baff777c3437363068f31bc47b943ef4768d68fb8530ea855b5d9997 PKG_BUILD_DIR=$(BUILD_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)/$(PKG_SOURCE_SUBDIR) @@ -32,7 +32,7 @@ define Package/wifidog-ng/default CATEGORY:=Network TITLE:=Next generation WifiDog DEPENDS:=+kmod-wifidog-ng +libuci +libuclient +libblobmsg-json +libubus +libcares \ - +ipset +libpcap + +libipset +libpcap endef define Package/wifidog-ng-nossl @@ -67,12 +67,14 @@ define Package/wifidog-ng-mbedtls endef define Package/wifidog-ng/default/install - $(INSTALL_DIR) $(1)/usr/bin $(1)/etc/init.d $(1)/etc/config $(1)/etc/wifidog-ng + $(INSTALL_DIR) $(1)/usr/bin $(1)/etc/init.d $(1)/etc/config \ + $(1)/etc/wifidog-ng $(1)//etc/hotplug.d/dhcp $(INSTALL_BIN) $(PKG_BUILD_DIR)/src/wifidog-ng $(1)/usr/bin $(INSTALL_BIN) ./files/wifidog-ng.init $(1)/etc/init.d/wifidog-ng $(INSTALL_CONF) ./files/wifidog-ng.config $(1)/etc/config/wifidog-ng $(INSTALL_CONF) ./files/wifidog-ng.key $(1)/etc/wifidog-ng $(INSTALL_CONF) ./files/wifidog-ng.crt $(1)/etc/wifidog-ng + $(INSTALL_DATA) ./files/wifidog-ng.hotplug $(1)/etc/hotplug.d/dhcp/00-wifidog-ng endef Package/wifidog-ng-nossl/install = $(Package/wifidog-ng/default/install) diff --git a/net/wifidog-ng/files/wifidog-ng.hotplug b/net/wifidog-ng/files/wifidog-ng.hotplug new file mode 100644 index 000000000..b1c284227 --- /dev/null +++ b/net/wifidog-ng/files/wifidog-ng.hotplug @@ -0,0 +1,3 @@ +[ "$ACTION" = "add" -o "$ACTION" = "update" ] || exit 0 +ubus list wifidog-ng > /dev/null 2>&1 || exit 0 +ubus call wifidog-ng roam "{\"mac\":\"$MACADDR\", \"ip\":\"$IPADDR\"}" diff --git a/net/wifidog-ng/files/wifidog-ng.init b/net/wifidog-ng/files/wifidog-ng.init index 28dd2769c..145ee6dc5 100755 --- a/net/wifidog-ng/files/wifidog-ng.init +++ b/net/wifidog-ng/files/wifidog-ng.init @@ -5,32 +5,38 @@ START=95 BIN=/usr/bin/wifidog-ng -parse_whitelist() { +parse_whitelist_mac() { local cfg="$1" - local domain mac + local mac uci_validate_section wifidog-ng whitelist "${1}" \ - 'domain:list(host)' \ - 'mac:list(macaddr)' + 'mac:macaddr' [ $? -ne 0 ] && { - echo "validation failed" >&2 + echo "validation whitelist_mac failed" >&2 exit 1 } +} + +parse_whitelist_domain() { + local cfg="$1" + local domain + + uci_validate_section wifidog-ng whitelist "${1}" \ + 'domain:host' - for m in $mac; do - echo "!$m" > /proc/wifidog-ng/term - done + [ $? -ne 0 ] && { + echo "validation whitelist_domain failed" >&2 + exit 1 + } } start_service() { modprobe wifidog-ng - ipset create wifidog-ng-mac hash:mac - ipset create wifidog-ng-ip hash:ip timeout 10000 - config_load wifidog-ng - config_foreach parse_whitelist whitelist + config_foreach parse_whitelist_mac whitelist_mac + config_foreach parse_whitelist_domain whitelist_domain procd_open_instance procd_set_param command $BIN @@ -40,7 +46,4 @@ start_service() { stop_service() { rmmod wifidog-ng - - ipset destroy wifidog-ng-mac - ipset destroy wifidog-ng-ip }