From 8940c4bfa7b73ef4dc9871f4f1aa637b1494d15b Mon Sep 17 00:00:00 2001 From: remittor Date: Wed, 16 Oct 2024 16:37:00 +0300 Subject: [PATCH] Add support for custom txt-configs Example: /opt/zapret/ipset/cust1.txt --- .../luci-static/resources/view/zapret/settings.js | 12 ++++++++++++ .../luci-static/resources/view/zapret/tools.js | 2 ++ zapret/Makefile | 4 ++++ zapret/ipset/cust1.txt | 0 zapret/ipset/cust2.txt | 0 zapret/ipset/cust3.txt | 0 zapret/ipset/cust4.txt | 0 7 files changed, 18 insertions(+) create mode 100644 zapret/ipset/cust1.txt create mode 100644 zapret/ipset/cust2.txt create mode 100644 zapret/ipset/cust3.txt create mode 100644 zapret/ipset/cust4.txt diff --git a/luci-app-zapret/htdocs/luci-static/resources/view/zapret/settings.js b/luci-app-zapret/htdocs/luci-static/resources/view/zapret/settings.js index 173328c..1ff1a5a 100644 --- a/luci-app-zapret/htdocs/luci-static/resources/view/zapret/settings.js +++ b/luci-app-zapret/htdocs/luci-static/resources/view/zapret/settings.js @@ -247,6 +247,18 @@ return view.extend({ 15 ).show(); + add_delim(s); + + for (let num = 1; num <= tools.custFileMax; num++) { + let fn = tools.custFileTemplate.format(num.toString()); + let name = _('Custom file #' + num); + o = s.taboption(tabname, form.Button, '_cust_file%d_btn'.format(num), name); + o.inputtitle = _('Edit'); + o.inputstyle = 'edit btn'; + o.description = fn; + o.onclick = () => new tools.fileEditDialog(fn, name, '', '', 15).show(); + } + let map_promise = m.render(); map_promise.then(node => node.classList.add('fade-in')); return map_promise; diff --git a/luci-app-zapret/htdocs/luci-static/resources/view/zapret/tools.js b/luci-app-zapret/htdocs/luci-static/resources/view/zapret/tools.js index 61756b1..ed751e8 100644 --- a/luci-app-zapret/htdocs/luci-static/resources/view/zapret/tools.js +++ b/luci-app-zapret/htdocs/luci-static/resources/view/zapret/tools.js @@ -42,6 +42,8 @@ return baseclass.extend({ iplstExcludeFN : '/opt/zapret/ipset/zapret-ip-exclude.txt', iplstUserFN : '/opt/zapret/ipset/zapret-ip-user.txt', iplstUserExcludeFN: '/opt/zapret/ipset/zapret-ip-user-exclude.txt', + custFileMax : 4, + custFileTemplate : '/opt/zapret/ipset/cust%s.txt', infoLabelStarting : '' + _('Starting') + '', infoLabelRunning : '' + _('Enabled') + '', diff --git a/zapret/Makefile b/zapret/Makefile index 1c1f9f2..a413df6 100644 --- a/zapret/Makefile +++ b/zapret/Makefile @@ -85,6 +85,10 @@ define Package/$(PKG_NAME)/install $(INSTALL_CONF) ./ipset/zapret-ip-user.txt $(1)/opt/zapret/ipset/zapret-ip-user.txt $(INSTALL_CONF) ./ipset/zapret-ip-user-exclude.txt $(1)/opt/zapret/ipset/zapret-ip-user-exclude.txt $(INSTALL_CONF) ./ipset/zapret-ip-user-ipban.txt $(1)/opt/zapret/ipset/zapret-ip-user-ipban.txt + $(INSTALL_CONF) ./ipset/cust1.txt $(1)/opt/zapret/ipset/cust1.txt + $(INSTALL_CONF) ./ipset/cust2.txt $(1)/opt/zapret/ipset/cust2.txt + $(INSTALL_CONF) ./ipset/cust3.txt $(1)/opt/zapret/ipset/cust3.txt + $(INSTALL_CONF) ./ipset/cust4.txt $(1)/opt/zapret/ipset/cust4.txt $(INSTALL_BIN) ./sync_config.sh $(1)/opt/zapret/sync_config.sh endef diff --git a/zapret/ipset/cust1.txt b/zapret/ipset/cust1.txt new file mode 100644 index 0000000..e69de29 diff --git a/zapret/ipset/cust2.txt b/zapret/ipset/cust2.txt new file mode 100644 index 0000000..e69de29 diff --git a/zapret/ipset/cust3.txt b/zapret/ipset/cust3.txt new file mode 100644 index 0000000..e69de29 diff --git a/zapret/ipset/cust4.txt b/zapret/ipset/cust4.txt new file mode 100644 index 0000000..e69de29