Skip to content

Commit 09c6b23

Browse files
committed
feat(local): local-dns client_cache_size set default when creating server instance
1 parent 0c5f693 commit 09c6b23

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,9 @@ Example configuration:
596596
// Remote DNS address, DNS queries will be sent through ssserver to this address
597597
"remote_dns_address": "8.8.8.8",
598598
// OPTIONAL. Remote DNS's port, 53 by default
599-
"remote_dns_port": 53
599+
"remote_dns_port": 53,
600+
// OPTIONAL. DNS Client Cache (TCP & UDP sockets)
601+
"client_cache_size": 5
600602
},
601603
{
602604
// Tun local server (feature = "local-tun")

crates/shadowsocks-service/src/config.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -925,7 +925,7 @@ impl LocalConfig {
925925
#[cfg(feature = "local-dns")]
926926
remote_dns_addr: None,
927927
#[cfg(feature = "local-dns")]
928-
client_cache_size: Some(5),
928+
client_cache_size: None,
929929

930930
#[cfg(feature = "local-tun")]
931931
tun_interface_name: None,
@@ -1553,6 +1553,11 @@ impl Config {
15531553
});
15541554
}
15551555

1556+
#[cfg(feature = "local-dns")]
1557+
{
1558+
local_config.client_cache_size = local.client_cache_size;
1559+
}
1560+
15561561
#[cfg(feature = "local-tun")]
15571562
if let Some(tun_interface_address) = local.tun_interface_address {
15581563
match tun_interface_address.parse::<IpNet>() {
@@ -2464,6 +2469,8 @@ impl fmt::Display for Config {
24642469
Address::DomainNameAddress(.., port) => Some(*port),
24652470
},
24662471
},
2472+
#[cfg(feature = "local-dns")]
2473+
client_cache_size: local.client_cache_size.clone(),
24672474
#[cfg(feature = "local-tun")]
24682475
tun_interface_name: local.tun_interface_name.clone(),
24692476
#[cfg(feature = "local-tun")]

crates/shadowsocks-service/src/local/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ impl Server {
353353
let mut server_builder = {
354354
let local_addr = local_config.local_dns_addr.expect("missing local_dns_addr");
355355
let remote_addr = local_config.remote_dns_addr.expect("missing remote_dns_addr");
356-
let client_cache_size = local_config.client_cache_size.unwrap();
356+
let client_cache_size = local_config.client_cache_size.unwrap_or_else(5);
357357

358358
DnsBuilder::with_context(
359359
context.clone(),

0 commit comments

Comments
 (0)