From 7be758d995798679b959532aec6847d385c616ec Mon Sep 17 00:00:00 2001 From: NewUse <7342068+NewUse@users.noreply.github.com> Date: Thu, 26 Sep 2024 00:54:01 +0300 Subject: [PATCH] Add simple luci configuration for tpws --- .../zapret/luci-app-zapret-tpws/Makefile | 17 +++++++++++ .../luasrc/controller/zapret-tpws.lua | 6 ++++ .../luasrc/model/cbi/zapret-tpws.lua | 29 +++++++++++++++++++ .../root/etc/uci-defaults/90_luci-zapret-tpws | 4 +++ .../rpcd/acl.d/luci-app-zapret-tpws.json | 18 ++++++++++++ 5 files changed, 74 insertions(+) create mode 100644 docs/compile/openwrt/package/zapret/luci-app-zapret-tpws/Makefile create mode 100644 docs/compile/openwrt/package/zapret/luci-app-zapret-tpws/luasrc/controller/zapret-tpws.lua create mode 100644 docs/compile/openwrt/package/zapret/luci-app-zapret-tpws/luasrc/model/cbi/zapret-tpws.lua create mode 100644 docs/compile/openwrt/package/zapret/luci-app-zapret-tpws/root/etc/uci-defaults/90_luci-zapret-tpws create mode 100644 docs/compile/openwrt/package/zapret/luci-app-zapret-tpws/root/usr/share/rpcd/acl.d/luci-app-zapret-tpws.json diff --git a/docs/compile/openwrt/package/zapret/luci-app-zapret-tpws/Makefile b/docs/compile/openwrt/package/zapret/luci-app-zapret-tpws/Makefile new file mode 100644 index 0000000..4a9a837 --- /dev/null +++ b/docs/compile/openwrt/package/zapret/luci-app-zapret-tpws/Makefile @@ -0,0 +1,17 @@ +# Copyright 2024 +# This is free software, licensed under the GNU General Public License v2. + +include $(TOPDIR)/rules.mk + +PKG_LICENSE:=GPL-2.0-or-later +PKG_MAINTAINER:=Zapret +PKG_VERSION:=0.1.7 + +LUCI_TITLE:=Zapret TPWS Web UI +LUCI_DESCRIPTION:=Provides Web UI for Zapret tpws transparent proxy +LUCI_DEPENDS:=+luci-compat +luci-mod-admin-full +tpws +LUCI_PKGARCH:=all + +include ../../../feeds/luci/luci.mk + +# call BuildPackage - OpenWrt buildroot signature diff --git a/docs/compile/openwrt/package/zapret/luci-app-zapret-tpws/luasrc/controller/zapret-tpws.lua b/docs/compile/openwrt/package/zapret/luci-app-zapret-tpws/luasrc/controller/zapret-tpws.lua new file mode 100644 index 0000000..b9c430f --- /dev/null +++ b/docs/compile/openwrt/package/zapret/luci-app-zapret-tpws/luasrc/controller/zapret-tpws.lua @@ -0,0 +1,6 @@ +module("luci.controller.zapret-tpws", package.seeall) +function index() + if nixio.fs.access("/etc/config/zapret") then + entry({"admin", "services", "zapret-tpws"}, cbi("zapret-tpws"), _("TPWS Configuration")).acl_depends = { "luci-app-zapret-tpws" } + end +end diff --git a/docs/compile/openwrt/package/zapret/luci-app-zapret-tpws/luasrc/model/cbi/zapret-tpws.lua b/docs/compile/openwrt/package/zapret/luci-app-zapret-tpws/luasrc/model/cbi/zapret-tpws.lua new file mode 100644 index 0000000..0760f1e --- /dev/null +++ b/docs/compile/openwrt/package/zapret/luci-app-zapret-tpws/luasrc/model/cbi/zapret-tpws.lua @@ -0,0 +1,29 @@ +m = Map("zapret", translate("TPWS Proxy Settings")) +c = m:section(NamedSection, "tpws", "zapret", translate("Configuration")) +opt = c:option(Value, "opts", translate("TPWS Options")) +opt.placeholder = "--split-pos=2" +function checkDoubleMinus(inputString) + -- Split the string into words + local words = {} + for word in inputString:gmatch("%S+") do + table.insert(words, word) + end + + -- Check each word + for _, word in ipairs(words) do + if not word:sub(1, 2) == "--" then + return false, translate("Error: Not all words start with double minuses.") + end + end + + return true +end +opt.validate = checkDoubleMinus(opt.Value) +b = c:option(Flag, "block_quic", "Block QUIC", translate("Block QUIC protocol to come outside")) +lp = c:option(Value, "port", translate("Listen Port")) +lp.datatype = "port" +lp.placeholder = "8088" +fp = c:option(Value, "forward_ports", translate("Ports, forwarded to proxy")) +fp.datatype = "list(neg(portrange))" +fp.placeholder = "80 443" +return m diff --git a/docs/compile/openwrt/package/zapret/luci-app-zapret-tpws/root/etc/uci-defaults/90_luci-zapret-tpws b/docs/compile/openwrt/package/zapret/luci-app-zapret-tpws/root/etc/uci-defaults/90_luci-zapret-tpws new file mode 100644 index 0000000..b42fa58 --- /dev/null +++ b/docs/compile/openwrt/package/zapret/luci-app-zapret-tpws/root/etc/uci-defaults/90_luci-zapret-tpws @@ -0,0 +1,4 @@ +#!/bin/sh +rm -rf /var/luci-modulecache/; rm -f /var/luci-indexcache; +[ -x /etc/init.d/rpcd ] && /etc/init.d/rpcd reload +exit 0 diff --git a/docs/compile/openwrt/package/zapret/luci-app-zapret-tpws/root/usr/share/rpcd/acl.d/luci-app-zapret-tpws.json b/docs/compile/openwrt/package/zapret/luci-app-zapret-tpws/root/usr/share/rpcd/acl.d/luci-app-zapret-tpws.json new file mode 100644 index 0000000..46589fa --- /dev/null +++ b/docs/compile/openwrt/package/zapret/luci-app-zapret-tpws/root/usr/share/rpcd/acl.d/luci-app-zapret-tpws.json @@ -0,0 +1,18 @@ +{ + "luci-app-zapret-tpws": { + "description": "Grant UCI and file access for luci-app-zapret-tpws", + "read": { + "cgi-io": [ + "exec" + ], + "uci": [ + "zapret" + ] + }, + "write": { + "uci": [ + "zapret" + ] + } + } +}