mirror of
https://forgejo.ellis.link/continuwuation/continuwuity/
synced 2026-10-23 00:51:20 +00:00
feat: Add support for custom DNS servers
Adds an option `dns_servers` which takes IPs for custom servers. Does not allow for custom DNS ports as this is largely not supported in tokio and hickory, and would otherwise be a pain to implement properly. Fixes: #1866 See-Also: https://matrix.to/#/!ksTlboXVgcyWjv5GrlEeKyQuJ8ZCprnwQx2b6-BQ44Q/%24qrBGOzosK4BdRbF5jhf5ehrxQUTaIr-U-UpqTmPhkPY?via=wolfgirl.pet&via=matrix.org
This commit is contained in:
1 parent
b4a2a457a1
commit
39bb4fefa1
2 files changed
+27
-2
No files matched your search
@@ -383,6 +383,15 @@ pub struct Config {
|
||||
#[serde(default = "default_stateinfo_cache_capacity")]
|
||||
pub stateinfo_cache_capacity: u32,
|
||||
|
||||
/// DNS servers to use instead of system defaults. Does NOT accept IP:Port
|
||||
/// pairs, only plain IPs. IPv6 addresses should be without brackets.
|
||||
///
|
||||
/// Uses system configuration (/etc/resolv.conf) if empty.
|
||||
///
|
||||
/// default: []
|
||||
#[serde(default)]
|
||||
pub dns_servers: Vec<String>,
|
||||
|
||||
/// Maximum entries stored in DNS memory-cache. The size of an entry may
|
||||
/// vary so please take care if raising this value excessively. Only
|
||||
/// decrease this when using an external DNS cache. Please note that
|
||||
|
||||
@@ -4,7 +4,10 @@
|
||||
use conduwuit::{Config, Result, Server, err, trace, utils::response::LimitReadExt, warn};
|
||||
use either::Either;
|
||||
use hickory_resolver::{
|
||||
TokioResolver, config::ConnectionConfig, net::runtime::TokioRuntimeProvider,
|
||||
TokioResolver,
|
||||
config::{ConnectionConfig, NameServerConfig},
|
||||
net::runtime::TokioRuntimeProvider,
|
||||
proto::rr::IntoName,
|
||||
};
|
||||
use ipaddress::IPAddress;
|
||||
use reqwest::redirect;
|
||||
@@ -320,7 +323,20 @@ fn get_dns_resolver(server: &Arc<Server>) -> Result<Arc<TokioResolver>> {
|
||||
conf.add_search(sys_conf.clone());
|
||||
}
|
||||
|
||||
for sys_conf in sys_conf.name_servers() {
|
||||
let config_nameservers: Vec<NameServerConfig> = server
|
||||
.config
|
||||
.dns_servers
|
||||
.iter()
|
||||
.filter_map(IntoName::to_ip)
|
||||
.map(NameServerConfig::udp_and_tcp)
|
||||
.collect();
|
||||
let nameservers = if !config_nameservers.is_empty() {
|
||||
config_nameservers
|
||||
} else {
|
||||
sys_conf.name_servers().to_vec()
|
||||
};
|
||||
|
||||
for sys_conf in nameservers {
|
||||
let mut ns = sys_conf.clone();
|
||||
|
||||
if config.query_over_tcp_only {
|
||||
|
||||
Reference in new issue
Block a user