update 2024-12-15 20:39:06

This commit is contained in:
kenzok8 2024-12-15 20:39:06 +08:00
parent 67a21ba01d
commit a1f338df38
4 changed files with 10 additions and 8 deletions

View File

@ -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);
}

View File

@ -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);

View File

@ -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) {

View File

@ -63,12 +63,12 @@ include './cfg.php';
<a href="#" class="col btn btn-lg">⚙️ 配置</a>
<a href="./singbox.php" class="col btn btn-lg"></i>📦 订阅</a>
<a href="./settings.php" class="col btn btn-lg">🛠️ 设定</a>
<h2 class="text-center p-2">配置</h2>
<form action="configs.php" method="post">
<div class="container text-center justify-content-md-center">
<div class="row justify-content-md-center">
<div class="col input-group mb-3 justify-content-md-center">
<select class="form-select" name="clashconfig" aria-label="themex">
<div class="col mb-3 justify-content-md-center">
<h2 for="clashconfig" class="form-label p-4 m-2">选择 Mihomo 配置文件</h2>
<select id="clashconfig" class="form-select" name="clashconfig" aria-label="themex">
<option selected><?php echo basename($selected_config); ?></option>
<?php foreach ($arrFiles as $file) echo "<option value=\"" . basename($file) . '">' . basename($file) . "</option>"; ?>
</select>