mirror of
https://dev.iopsys.eu/feed/iopsys.git
synced 2025-12-10 07:44:50 +01:00
urlfilter: add datamodel with micro-service
This commit is contained in:
parent
548be0303f
commit
63fd69ad75
4 changed files with 59 additions and 124 deletions
|
|
@ -6,7 +6,7 @@ include $(TOPDIR)/rules.mk
|
|||
include $(INCLUDE_DIR)/kernel.mk
|
||||
|
||||
PKG_NAME:=urlfilter
|
||||
PKG_VERSION:=1.1.9
|
||||
PKG_VERSION:=1.1.10
|
||||
|
||||
LOCAL_DEV:=0
|
||||
ifneq ($(LOCAL_DEV),1)
|
||||
|
|
@ -21,7 +21,6 @@ PKG_LICENSE:=GPL-2.0-only
|
|||
PKG_LICENSE_FILES:=LICENSE
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
include ../bbfdm/bbfdm.mk
|
||||
|
||||
define Package/urlfilter
|
||||
SECTION:=utils
|
||||
|
|
@ -47,10 +46,12 @@ define Package/urlfilter/install
|
|||
$(INSTALL_DIR) $(1)/usr/sbin
|
||||
$(INSTALL_DIR) $(1)/etc/config
|
||||
$(INSTALL_DIR) $(1)/etc/init.d
|
||||
$(INSTALL_DIR) $(1)/etc/urlfilter
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/urlfilter $(1)/usr/sbin
|
||||
$(INSTALL_BIN) ./files/etc/init.d/urlfilter $(1)/etc/init.d/
|
||||
$(INSTALL_DATA) ./files/etc/config/urlfilter $(1)/etc/config/
|
||||
$(call BbfdmInstallPlugin,$(1),./files/etc/bbfdm/plugins/urlfilter.json)
|
||||
$(INSTALL_BIN) ./files/etc/urlfilter/urlfilter.json $(1)/etc/urlfilter
|
||||
$(INSTALL_BIN) ./files/etc/urlfilter/input.json $(1)/etc/urlfilter
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,urlfilter))
|
||||
|
|
|
|||
|
|
@ -1,11 +1,14 @@
|
|||
#!/bin/sh /etc/rc.common
|
||||
|
||||
START=21
|
||||
START=60
|
||||
STOP=10
|
||||
|
||||
USE_PROCD=1
|
||||
NAME=urlfilter
|
||||
PROG=/usr/sbin/urlfilter
|
||||
URLFILTER_INPUT_JSON="/etc/urlfilter/input.json"
|
||||
|
||||
. /etc/bbfdm/bbfdm_services.sh
|
||||
|
||||
configure_firewall()
|
||||
{
|
||||
|
|
@ -37,6 +40,8 @@ configure_firewall()
|
|||
}
|
||||
|
||||
start_service() {
|
||||
bbfdm_add_service "bbfdm.urlfilter" "${URLFILTER_INPUT_JSON}"
|
||||
|
||||
if [ "$(uci -q get urlfilter.globals.enable)" == "1" ]; then
|
||||
procd_open_instance urlfilter
|
||||
procd_set_param command ${PROG}
|
||||
|
|
|
|||
15
urlfilter/files/etc/urlfilter/input.json
Normal file
15
urlfilter/files/etc/urlfilter/input.json
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
{
|
||||
"daemon": {
|
||||
"input": {
|
||||
"type": "JSON",
|
||||
"name": "/etc/urlfilter/urlfilter.json"
|
||||
},
|
||||
"output": {
|
||||
"type": "UBUS",
|
||||
"name": "bbfdm.urlfilter",
|
||||
"parent_dm": "Device.",
|
||||
"object": "{BBF_VENDOR_PREFIX}URLFilter",
|
||||
"root_obj": "bbfdm"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,8 +1,7 @@
|
|||
{
|
||||
"json_plugin_version": 1,
|
||||
"json_plugin_version": 2,
|
||||
"Device.{BBF_VENDOR_PREFIX}URLFilter.": {
|
||||
"type": "object",
|
||||
"version": "2.14",
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
"usp"
|
||||
|
|
@ -12,7 +11,6 @@
|
|||
"array": false,
|
||||
"Enable": {
|
||||
"type": "boolean",
|
||||
"version": "2.14",
|
||||
"read": true,
|
||||
"write": true,
|
||||
"protocols": [
|
||||
|
|
@ -37,7 +35,6 @@
|
|||
},
|
||||
"GlobalBlacklist": {
|
||||
"type": "boolean",
|
||||
"version": "2.14",
|
||||
"read": true,
|
||||
"write": true,
|
||||
"protocols": [
|
||||
|
|
@ -62,7 +59,6 @@
|
|||
},
|
||||
"BlacklistURL": {
|
||||
"type": "string",
|
||||
"version": "2.14",
|
||||
"read": true,
|
||||
"write": true,
|
||||
"protocols": [
|
||||
|
|
@ -92,11 +88,11 @@
|
|||
"type": "unsignedInt",
|
||||
"read": true,
|
||||
"write": false,
|
||||
"version": "2.14",
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
"usp"
|
||||
],
|
||||
"datatype": "unsignedInt",
|
||||
"description": "<<numentries>>",
|
||||
"mapping": [
|
||||
{
|
||||
|
|
@ -115,7 +111,6 @@
|
|||
},
|
||||
"Device.{BBF_VENDOR_PREFIX}URLFilter.Profile.{i}.": {
|
||||
"type": "object",
|
||||
"version": "2.14",
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
"usp"
|
||||
|
|
@ -142,7 +137,6 @@
|
|||
"type": "string",
|
||||
"read": true,
|
||||
"write": false,
|
||||
"version": "2.14",
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
"usp"
|
||||
|
|
@ -159,16 +153,9 @@
|
|||
],
|
||||
"mapping": [
|
||||
{
|
||||
"type": "uci",
|
||||
"uci": {
|
||||
"file": "urlfilter",
|
||||
"section": {
|
||||
"type": "profile"
|
||||
},
|
||||
"option": {
|
||||
"name": "@Name"
|
||||
}
|
||||
}
|
||||
"data": "@Parent",
|
||||
"type": "uci_sec",
|
||||
"key": "@Name"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
@ -176,7 +163,6 @@
|
|||
"type": "string",
|
||||
"read": true,
|
||||
"write": true,
|
||||
"version": "2.14",
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
"usp"
|
||||
|
|
@ -190,22 +176,14 @@
|
|||
],
|
||||
"mapping": [
|
||||
{
|
||||
"type": "uci",
|
||||
"uci": {
|
||||
"file": "urlfilter",
|
||||
"section": {
|
||||
"type": "profile"
|
||||
},
|
||||
"option": {
|
||||
"name": "name"
|
||||
}
|
||||
}
|
||||
"data": "@Parent",
|
||||
"type": "uci_sec",
|
||||
"key": "name"
|
||||
}
|
||||
]
|
||||
},
|
||||
"WhitelistURL": {
|
||||
"type": "string",
|
||||
"version": "2.14",
|
||||
"read": true,
|
||||
"write": true,
|
||||
"protocols": [
|
||||
|
|
@ -218,22 +196,14 @@
|
|||
},
|
||||
"mapping": [
|
||||
{
|
||||
"type": "uci",
|
||||
"uci": {
|
||||
"file": "urlfilter",
|
||||
"section": {
|
||||
"type": "profile"
|
||||
},
|
||||
"list": {
|
||||
"name": "whitelist_url"
|
||||
}
|
||||
}
|
||||
"data": "@Parent",
|
||||
"type": "uci_sec",
|
||||
"list": "whitelist_url"
|
||||
}
|
||||
]
|
||||
},
|
||||
"BlacklistURL": {
|
||||
"type": "string",
|
||||
"version": "2.14",
|
||||
"read": true,
|
||||
"write": true,
|
||||
"protocols": [
|
||||
|
|
@ -246,16 +216,9 @@
|
|||
},
|
||||
"mapping": [
|
||||
{
|
||||
"type": "uci",
|
||||
"uci": {
|
||||
"file": "urlfilter",
|
||||
"section": {
|
||||
"type": "profile"
|
||||
},
|
||||
"list": {
|
||||
"name": "blacklist_url"
|
||||
}
|
||||
}
|
||||
"data": "@Parent",
|
||||
"type": "uci_sec",
|
||||
"list": "blacklist_url"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -264,11 +227,11 @@
|
|||
"type": "unsignedInt",
|
||||
"read": true,
|
||||
"write": false,
|
||||
"version": "2.14",
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
"usp"
|
||||
],
|
||||
"datatype": "unsignedInt",
|
||||
"description": "<<numentries>>",
|
||||
"mapping": [
|
||||
{
|
||||
|
|
@ -287,7 +250,6 @@
|
|||
},
|
||||
"Device.{BBF_VENDOR_PREFIX}URLFilter.Filter.{i}.": {
|
||||
"type": "object",
|
||||
"version": "2.14",
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
"usp"
|
||||
|
|
@ -309,7 +271,6 @@
|
|||
],
|
||||
"Enable": {
|
||||
"type": "boolean",
|
||||
"version": "2.14",
|
||||
"read": true,
|
||||
"write": true,
|
||||
"protocols": [
|
||||
|
|
@ -319,51 +280,35 @@
|
|||
"description": "Enable or disable this filter instance on the CPE.",
|
||||
"mapping": [
|
||||
{
|
||||
"type": "uci",
|
||||
"uci": {
|
||||
"file": "urlfilter",
|
||||
"section": {
|
||||
"type": "filter"
|
||||
},
|
||||
"option": {
|
||||
"name": "enable"
|
||||
}
|
||||
}
|
||||
"data": "@Parent",
|
||||
"type": "uci_sec",
|
||||
"key": "enable"
|
||||
}
|
||||
]
|
||||
},
|
||||
"Profile": {
|
||||
"type": "string",
|
||||
"version": "2.14",
|
||||
"read": true,
|
||||
"write": true,
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
"usp"
|
||||
],
|
||||
"flags": [
|
||||
"flags": [
|
||||
"Reference"
|
||||
],
|
||||
"description": "Path of the <<object|Profile>> that should be applied.",
|
||||
"mapping": [
|
||||
{
|
||||
"type": "uci",
|
||||
"uci": {
|
||||
"file": "urlfilter",
|
||||
"section": {
|
||||
"type": "filter"
|
||||
},
|
||||
"option": {
|
||||
"name": "profile"
|
||||
}
|
||||
},
|
||||
"data": "@Parent",
|
||||
"type": "uci_sec",
|
||||
"key": "profile",
|
||||
"linker_obj": "Device.{BBF_VENDOR_PREFIX}URLFilter.Profile.*.Alias"
|
||||
}
|
||||
]
|
||||
},
|
||||
"MACAddress": {
|
||||
"type": "string",
|
||||
"version": "2.14",
|
||||
"read": true,
|
||||
"write": true,
|
||||
"protocols": [
|
||||
|
|
@ -376,22 +321,14 @@
|
|||
},
|
||||
"mapping": [
|
||||
{
|
||||
"type": "uci",
|
||||
"uci": {
|
||||
"file": "urlfilter",
|
||||
"section": {
|
||||
"type": "filter"
|
||||
},
|
||||
"list": {
|
||||
"name": "macaddr"
|
||||
}
|
||||
}
|
||||
"data": "@Parent",
|
||||
"type": "uci_sec",
|
||||
"list": "macaddr"
|
||||
}
|
||||
]
|
||||
},
|
||||
"Day": {
|
||||
"type": "string",
|
||||
"version": "2.14",
|
||||
"read": true,
|
||||
"write": true,
|
||||
"protocols": [
|
||||
|
|
@ -404,22 +341,14 @@
|
|||
},
|
||||
"mapping": [
|
||||
{
|
||||
"type": "uci",
|
||||
"uci": {
|
||||
"file": "urlfilter",
|
||||
"section": {
|
||||
"type": "filter"
|
||||
},
|
||||
"list": {
|
||||
"name": "day"
|
||||
}
|
||||
}
|
||||
"data": "@Parent",
|
||||
"type": "uci_sec",
|
||||
"list": "day"
|
||||
}
|
||||
]
|
||||
},
|
||||
"StartTime": {
|
||||
"type": "string",
|
||||
"version": "2.14",
|
||||
"read": true,
|
||||
"write": true,
|
||||
"protocols": [
|
||||
|
|
@ -429,22 +358,14 @@
|
|||
"description": "Time when filtering shall start.",
|
||||
"mapping": [
|
||||
{
|
||||
"type": "uci",
|
||||
"uci": {
|
||||
"file": "urlfilter",
|
||||
"section": {
|
||||
"type": "filter"
|
||||
},
|
||||
"option": {
|
||||
"name": "start_time"
|
||||
}
|
||||
}
|
||||
"data": "@Parent",
|
||||
"type": "uci_sec",
|
||||
"key": "start_time"
|
||||
}
|
||||
]
|
||||
},
|
||||
"Duration": {
|
||||
"type": "string",
|
||||
"version": "2.14",
|
||||
"read": true,
|
||||
"write": true,
|
||||
"protocols": [
|
||||
|
|
@ -454,16 +375,9 @@
|
|||
"description": "The duration in seconds to filter the URLs from start time.",
|
||||
"mapping": [
|
||||
{
|
||||
"type": "uci",
|
||||
"uci": {
|
||||
"file": "urlfilter",
|
||||
"section": {
|
||||
"type": "filter"
|
||||
},
|
||||
"option": {
|
||||
"name": "duration"
|
||||
}
|
||||
}
|
||||
"data": "@Parent",
|
||||
"type": "uci_sec",
|
||||
"key": "duration"
|
||||
}
|
||||
]
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue