From a1f338df387d9ce4c6459e17272d0bee071a8373 Mon Sep 17 00:00:00 2001 From: kenzok8 Date: Sun, 15 Dec 2024 20:39:06 +0800 Subject: [PATCH] update 2024-12-15 20:39:06 --- UA2F/src/cache.c | 2 +- UA2F/src/handler.c | 4 +++- UA2F/test/cache_test.cc | 6 +++--- luci-app-nekobox/htdocs/nekobox/configs.php | 6 +++--- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/UA2F/src/cache.c b/UA2F/src/cache.c index 383b7837b..598244ec1 100644 --- a/UA2F/src/cache.c +++ b/UA2F/src/cache.c @@ -22,7 +22,7 @@ _Noreturn static void* check_cache(void* arg __attribute__((unused))) { struct cache *cur, *tmp; HASH_ITER(hh, not_http_dst_cache, cur, tmp) { - if (difftime(now, cur->last_time) > check_interval * 2) { + if (difftime(now, cur->last_time) > check_interval) { HASH_DEL(not_http_dst_cache, cur); free(cur); } diff --git a/UA2F/src/handler.c b/UA2F/src/handler.c index e6649fd96..0c8feceb9 100644 --- a/UA2F/src/handler.c +++ b/UA2F/src/handler.c @@ -237,7 +237,7 @@ void handle_packet(const struct nf_queue *queue, const struct nf_packet *pkt) { goto end; } - int type = get_pkt_ip_version(pkt); + const int type = get_pkt_ip_version(pkt); if (type == IP_UNK) { // will this happen? send_verdict(queue, pkt, get_next_mark(pkt, false), NULL); @@ -246,8 +246,10 @@ void handle_packet(const struct nf_queue *queue, const struct nf_packet *pkt) { if (type == IPV4) { assert(ipv4_set_transport_header(pkt_buff)); + count_ipv4_packet(); } else if (type == IPV6) { assert(ipv6_set_transport_header(pkt_buff)); + count_ipv6_packet(); } const __auto_type tcp_hdr = nfq_tcp_get_hdr(pkt_buff); diff --git a/UA2F/test/cache_test.cc b/UA2F/test/cache_test.cc index bd1f7dc52..978942384 100644 --- a/UA2F/test/cache_test.cc +++ b/UA2F/test/cache_test.cc @@ -11,13 +11,13 @@ protected: void SetUp() override { test_addr.addr.ip4 = 12345; test_addr.port = 80; - init_not_http_cache(2); + init_not_http_cache(1); } void TearDown() override { pthread_rwlock_wrlock(&cacheLock); // Clear the cache after each test - struct cache *cur, *tmp; + cache *cur, *tmp; HASH_ITER(hh, not_http_dst_cache, cur, tmp) { HASH_DEL(not_http_dst_cache, cur); free(cur); @@ -39,7 +39,7 @@ TEST_F(CacheTest, AddAndRemoveFromCache) { cache_add(test_addr); EXPECT_TRUE(cache_contains(test_addr)); sleep(5); - EXPECT_TRUE(cache_contains(test_addr)); + EXPECT_FALSE(cache_contains(test_addr)); } TEST_F(CacheTest, CacheDoesNotContainNonexistentEntry) { diff --git a/luci-app-nekobox/htdocs/nekobox/configs.php b/luci-app-nekobox/htdocs/nekobox/configs.php index 9db5fd097..64e7a282b 100644 --- a/luci-app-nekobox/htdocs/nekobox/configs.php +++ b/luci-app-nekobox/htdocs/nekobox/configs.php @@ -63,12 +63,12 @@ include './cfg.php'; ⚙️ 配置 📦 订阅 🛠️ 设定 -

配置

-
- ' . basename($file) . ""; ?>