Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,10 @@ pub struct GlobalSettings {
/// DoH 上游连接池大小(每个 upstream 的最大空闲连接数)。 / DoH upstream pool size (max idle per host)
#[serde(default = "default_doh_pool_size")]
pub doh_pool_size: usize,
/// DoH 健康检查错误阈值(连续传输错误多少次后重建连接池以驱逐死连接)。 / DoH health check error threshold (rebuild pool after N consecutive transport errors to evict dead connections)
/// 默认 3 次,0 表示禁用健康检查 / Default 3, 0 means disable health check
#[serde(default = "default_doh_health_check_error_threshold")]
pub doh_health_check_error_threshold: usize,
/// DoT 上游连接池大小。 / DoT upstream connection pool size
#[serde(default = "default_dot_pool_size")]
pub dot_pool_size: usize,
Expand Down Expand Up @@ -255,6 +259,7 @@ impl Default for GlobalSettings {
udp_pool_size: default_udp_pool_size(),
tcp_pool_size: default_tcp_pool_size(),
doh_pool_size: default_doh_pool_size(),
doh_health_check_error_threshold: default_doh_health_check_error_threshold(),
dot_pool_size: default_dot_pool_size(),
doq_pool_size: default_doq_pool_size(),
tcp_health_check_error_threshold: default_tcp_health_check_error_threshold(),
Expand Down Expand Up @@ -911,6 +916,10 @@ fn default_doh_pool_size() -> usize {
8
}

fn default_doh_health_check_error_threshold() -> usize {
3 // 连续 3 次传输错误后重建连接池 / Rebuild pool after 3 consecutive transport errors
}

/// Default DoH query path (RFC 8484 standard) / 默认 DoH 查询路径(RFC 8484 标准)
fn default_doh_path() -> String {
"/dns-query".to_string()
Expand Down
6 changes: 5 additions & 1 deletion src/engine/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ impl Engine {
let udp_pool_size = cfg.settings.udp_pool_size;
let tcp_pool_size = cfg.settings.tcp_pool_size;
let doh_pool_size = cfg.settings.doh_pool_size;
let doh_health_error_threshold = cfg.settings.doh_health_check_error_threshold;
let dot_pool_size = cfg.settings.dot_pool_size;
let doq_pool_size = cfg.settings.doq_pool_size;
let doq_idle_timeout_secs = cfg.settings.doq_connection_idle_timeout_seconds;
Expand Down Expand Up @@ -341,7 +342,10 @@ impl Engine {
.context("initialize DoT multiplexer")?,
);

let doh_client = Arc::new(DohClient::new(doh_pool_size).context("initialize DoH client")?);
let doh_client = Arc::new(
DohClient::new(doh_pool_size, doh_health_error_threshold)
.context("initialize DoH client")?,
);
let doq_client = Arc::new(
DoqClient::new(
doq_pool_size,
Expand Down
Loading