use hickory-dns resovler

This commit is contained in:
Toshit Chawda 2024-09-08 20:50:02 -07:00
parent 732679feb9
commit 70ddb2ac21
No known key found for this signature in database
GPG key ID: 91480ED99E2B3D9D
5 changed files with 366 additions and 24 deletions

View file

@ -6,6 +6,10 @@ use clap::Parser;
use config::{validate_config_cache, Cli, Config};
use dashmap::DashMap;
use handle::{handle_wisp, handle_wsproxy};
use hickory_resolver::{
config::{NameServerConfigGroup, ResolverConfig, ResolverOpts},
TokioAsyncResolver,
};
use lazy_static::lazy_static;
use listener::ServerListener;
use log::{error, info};
@ -32,6 +36,22 @@ lazy_static! {
}
};
pub static ref CLIENTS: DashMap<String, Client> = DashMap::new();
pub static ref RESOLVER: TokioAsyncResolver = {
let (config, opts) = if CONFIG.stream.dns_servers.is_empty() {
hickory_resolver::system_conf::read_system_conf().unwrap()
} else {
(
ResolverConfig::from_parts(
None,
Vec::new(),
NameServerConfigGroup::from_ips_clear(&CONFIG.stream.dns_servers, 53, true),
),
ResolverOpts::default(),
)
};
TokioAsyncResolver::tokio(config, opts)
};
}
fn format_stream_type(stream_type: StreamType) -> &'static str {