Skip to content

Commit

Permalink
feat(local): local-dns client_cache_size set default when creating se…
Browse files Browse the repository at this point in the history
…rver instance
  • Loading branch information
zonyitoo committed Sep 23, 2023
1 parent 0c5f693 commit 09c6b23
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,9 @@ Example configuration:
// Remote DNS address, DNS queries will be sent through ssserver to this address
"remote_dns_address": "8.8.8.8",
// OPTIONAL. Remote DNS's port, 53 by default
"remote_dns_port": 53
"remote_dns_port": 53,
// OPTIONAL. DNS Client Cache (TCP & UDP sockets)
"client_cache_size": 5
},
{
// Tun local server (feature = "local-tun")
Expand Down
9 changes: 8 additions & 1 deletion crates/shadowsocks-service/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -925,7 +925,7 @@ impl LocalConfig {
#[cfg(feature = "local-dns")]
remote_dns_addr: None,
#[cfg(feature = "local-dns")]
client_cache_size: Some(5),
client_cache_size: None,

#[cfg(feature = "local-tun")]
tun_interface_name: None,
Expand Down Expand Up @@ -1553,6 +1553,11 @@ impl Config {
});
}

#[cfg(feature = "local-dns")]
{
local_config.client_cache_size = local.client_cache_size;
}

#[cfg(feature = "local-tun")]
if let Some(tun_interface_address) = local.tun_interface_address {
match tun_interface_address.parse::<IpNet>() {
Expand Down Expand Up @@ -2464,6 +2469,8 @@ impl fmt::Display for Config {
Address::DomainNameAddress(.., port) => Some(*port),
},
},
#[cfg(feature = "local-dns")]
client_cache_size: local.client_cache_size.clone(),
#[cfg(feature = "local-tun")]
tun_interface_name: local.tun_interface_name.clone(),
#[cfg(feature = "local-tun")]
Expand Down
2 changes: 1 addition & 1 deletion crates/shadowsocks-service/src/local/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ impl Server {
let mut server_builder = {
let local_addr = local_config.local_dns_addr.expect("missing local_dns_addr");
let remote_addr = local_config.remote_dns_addr.expect("missing remote_dns_addr");
let client_cache_size = local_config.client_cache_size.unwrap();
let client_cache_size = local_config.client_cache_size.unwrap_or_else(5);

DnsBuilder::with_context(
context.clone(),
Expand Down

0 comments on commit 09c6b23

Please sign in to comment.