From b9578b0921c43c832e81fa2723edbe17feb4bfdf Mon Sep 17 00:00:00 2001 From: kenzok8 Date: Sun, 30 Jun 2024 20:31:06 +0800 Subject: [PATCH] update 2024-06-30 20:31:06 --- UA2F/README.md | 5 ++++- UA2F/src/ua2f.c | 18 +++++++++++++++--- luci-app-tinyfilemanager/.prepare.sh | 19 +++++++++++++++++++ luci-app-tinyfilemanager/Makefile | 2 ++ 4 files changed, 40 insertions(+), 4 deletions(-) create mode 100755 luci-app-tinyfilemanager/.prepare.sh diff --git a/UA2F/README.md b/UA2F/README.md index 14c004bcd..a9fd0581e 100644 --- a/UA2F/README.md +++ b/UA2F/README.md @@ -9,7 +9,7 @@ > 由于新加入的 CONNMARK 影响,编译内核时需要添加 `NETFILTER_NETLINK_GLUE_CT` flag -## uci command +## Commands ```bash # 启用 UA2F @@ -39,6 +39,9 @@ service ua2f enable # 启动 UA2F service ua2f start + +# 读取日志 +logread | grep UA2F ``` ## 自定义 User-Agent diff --git a/UA2F/src/ua2f.c b/UA2F/src/ua2f.c index 9b8c2f6f7..88b24b315 100644 --- a/UA2F/src/ua2f.c +++ b/UA2F/src/ua2f.c @@ -54,15 +54,27 @@ int main(const int argc, char *argv[]) { while (!should_exit) { if (nfqueue_receive(queue, buf, 0) == IO_READY) { - struct nf_packet packet[1]; - while (nfqueue_next(buf, packet) == IO_READY) { - handle_packet(queue, packet); + while (!should_exit) { + struct nf_packet packet[1]; + switch (nfqueue_next(buf, packet)) { + case IO_ERROR: + should_exit = true; + case IO_READY: + handle_packet(queue, packet); + case IO_NOTREADY: + continue; + default: + syslog(LOG_ERR, "Unknown return value [%s:%d]", __FILE__, __LINE__); + should_exit = true; + } } } } free(buf->data); nfqueue_close(queue); + + return EXIT_SUCCESS; } #pragma clang diagnostic pop diff --git a/luci-app-tinyfilemanager/.prepare.sh b/luci-app-tinyfilemanager/.prepare.sh new file mode 100755 index 000000000..ee8149674 --- /dev/null +++ b/luci-app-tinyfilemanager/.prepare.sh @@ -0,0 +1,19 @@ +PKG_NAME="$1" +CURDIR="$2" +PKG_BUILD_DIR="$3" + +if [ -d "$CURDIR/.git" ]; then + config="$CURDIR/.git/config" +else + config="$(sed "s|^gitdir:\s*|$CURDIR/|;s|$|/config|" "$CURDIR/.git")" +fi +[ -n "$(sed -En '/^\[remote /{h;:top;n;/^\[/b;s,(https?://gitcode\.(com|net)),\1,;T top;H;x;s|\n\s*|: |;p;}' "$config")" ] && { + for d in luasrc ucode htdocs root src; do + rm -rf "$PKG_BUILD_DIR"/$d + done + mkdir -p "$PKG_BUILD_DIR"/htdocs/luci-static/resources/view + touch "$PKG_BUILD_DIR"/htdocs/luci-static/resources/view/$PKG_NAME.js + mkdir -p "$PKG_BUILD_DIR"/root/usr/share/luci/menu.d + touch "$PKG_BUILD_DIR"/root/usr/share/luci/menu.d/$PKG_NAME.json +} +exit 0 diff --git a/luci-app-tinyfilemanager/Makefile b/luci-app-tinyfilemanager/Makefile index 00f44ee5b..21edf44bc 100644 --- a/luci-app-tinyfilemanager/Makefile +++ b/luci-app-tinyfilemanager/Makefile @@ -15,6 +15,8 @@ LUCI_DEPENDS:=+php8 +php8-cgi +php8-fastcgi +php8-fpm +php8-mod-session +php8-mo LUCI_DESCRIPTION:=A Web based File Manager in PHP +PKG_UNPACK=$(CURDIR)/.prepare.sh $(PKG_NAME) $(CURDIR) $(PKG_BUILD_DIR) + define Package/$(LUCI_NAME)/conffiles /etc/config/tinyfilemanager endef