feat(local): local-dns client_cache_size set default when creating server instance

This commit is contained in:
zonyitoo
2023-09-23 15:25:47 +08:00
parent 0c5f693e9a
commit 09c6b23f34
3 changed files with 12 additions and 3 deletions

View File

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

View File

@@ -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,
@@ -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>() {
@@ -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")]

View File

@@ -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(),