From 4dfb70607321289a4f4e4a44cb942f66bba0d7d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A1=A5=E4=B8=8B=E7=BA=A2=E8=8D=AF?= Date: Fri, 16 Jan 2026 22:28:57 +0800 Subject: [PATCH] update --- .github/workflows/rust.yml | 9 +++++++++ Cargo.toml | 10 +++++----- src/server.rs | 1 + 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index ceed348..a3b52f2 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -40,6 +40,8 @@ jobs: run: cargo test --verbose - name: Build examples run: cargo build --examples --verbose + - name: Build examples with mimalloc + run: cargo build --examples --verbose --features mimalloc # 测试不同的 feature 组合 test-features: @@ -74,3 +76,10 @@ jobs: else cargo test --verbose --features "${{ matrix.features }}" fi + - name: Build examples with features + run: | + if [ -z "${{ matrix.features }}" ]; then + cargo build --examples --verbose + else + cargo build --examples --verbose --features "${{ matrix.features }}" + fi \ No newline at end of file diff --git a/Cargo.toml b/Cargo.toml index 0bb06da..598e529 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "dht-crawler" -version = "0.0.3" +version = "0.0.4" edition = "2021" authors = ["桥下红药 <1121744186@qq.com>"] description = "高性能的 Rust DHT(分布式哈希表)爬虫库,用于爬取 BitTorrent DHT 网络中的种子信息" @@ -15,7 +15,7 @@ name = "dht_crawler" path = "src/lib.rs" [dependencies] -tokio = { version = "1.35", features = ["full"] } +tokio = { version = "1.35", features = ["rt", "rt-multi-thread", "net", "sync", "time", "macros"] } serde = { version = "1.0", features = ["derive"] } serde_bencode = "0.2" sha1 = "0.10" @@ -24,19 +24,19 @@ rand = "0.8" log = "0.4" thiserror = "1.0" socket2 = { version = "0.5", features = ["all"] } -rbit = "0.1" +rbit = "0.2" bytes = "1.0" bloomfilter = "1.0" ahash = "0.8" serde_bytes = "0.11.19" -mimalloc = { version = "0.1", optional = true } [dev-dependencies] tracing-subscriber = { version = "0.3", features = ["env-filter", "fmt"] } +mimalloc = "0.1" [features] default = [] -mimalloc = ["dep:mimalloc"] +mimalloc = [] [[example]] name = "dht_crawler_example" diff --git a/src/server.rs b/src/server.rs index 549b074..5174f38 100644 --- a/src/server.rs +++ b/src/server.rs @@ -409,6 +409,7 @@ impl DHTServer { Ok((size, addr)) => { // 🛡️ 安全检查1:拒绝异常大的包(DHT 消息通常 < 2KB) if size > 8192 { + #[cfg(debug_assertions)] log::trace!("⚠️ 拒绝异常大的 UDP 包: {} 字节 from {}", size, addr); continue; }