Changed format of DNS-listen options. Added DNS-thread count options to config.

This commit is contained in:
Revertron
2021-03-06 22:54:17 +01:00
parent ac915a1e92
commit ce212ab749
5 changed files with 21 additions and 20 deletions
+3 -6
View File
@@ -45,8 +45,7 @@ pub struct ServerContext {
pub cache: SynchronizedCache,
pub filters: Vec<Box<dyn DnsFilter + Sync + Send>>,
pub client: Box<dyn DnsClient + Sync + Send>,
pub dns_host: String,
pub dns_port: u16,
pub dns_listen: String,
pub api_port: u16,
pub resolve_strategy: ResolveStrategy,
pub allow_recursive: bool,
@@ -70,8 +69,7 @@ impl ServerContext {
cache: SynchronizedCache::new(),
filters: Vec::new(),
client: Box::new(DnsNetworkClient::new(10000 + (rand::random::<u16>() % 20000))),
dns_host: String::from("0.0.0.0"),
dns_port: 53,
dns_listen: String::from("0.0.0.0:53"),
api_port: 5380,
resolve_strategy: ResolveStrategy::Recursive,
allow_recursive: true,
@@ -125,8 +123,7 @@ pub mod tests {
cache: SynchronizedCache::new(),
filters: Vec::new(),
client: Box::new(DnsStubClient::new(callback)),
dns_host: String::from("0.0.0.0"),
dns_port: 53,
dns_listen: String::from("0.0.0.0:53"),
api_port: 5380,
resolve_strategy: ResolveStrategy::Recursive,
allow_recursive: true,
+2 -2
View File
@@ -176,7 +176,7 @@ impl DnsServer for DnsUdpServer {
/// This method takes ownership of the server, preventing the method from being called multiple times.
fn run_server(self) -> Result<()> {
// Bind the socket
let socket = UdpSocket::bind((self.context.dns_host.as_str(), self.context.dns_port))?;
let socket = UdpSocket::bind(self.context.dns_listen.as_str())?;
// Spawn threads for handling requests
for thread_id in 0..self.thread_count {
@@ -291,7 +291,7 @@ impl DnsTcpServer {
impl DnsServer for DnsTcpServer {
fn run_server(mut self) -> Result<()> {
let socket = TcpListener::bind((self.context.dns_host.as_str(), self.context.dns_port))?;
let socket = TcpListener::bind(self.context.dns_listen.as_str())?;
// Spawn threads for handling requests, and create the channels
for thread_id in 0..self.thread_count {