Implemented setting bind-host for DNS-resolver.
This commit is contained in:
@@ -46,6 +46,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 api_port: u16,
|
||||
pub resolve_strategy: ResolveStrategy,
|
||||
@@ -70,6 +71,7 @@ impl ServerContext {
|
||||
cache: SynchronizedCache::new(),
|
||||
filters: Vec::new(),
|
||||
client: Box::new(DnsNetworkClient::new(34255)),
|
||||
dns_host: String::from("0.0.0.0"),
|
||||
dns_port: 53,
|
||||
api_port: 5380,
|
||||
resolve_strategy: ResolveStrategy::Recursive,
|
||||
@@ -127,6 +129,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,
|
||||
api_port: 5380,
|
||||
resolve_strategy: ResolveStrategy::Recursive,
|
||||
|
||||
+2
-2
@@ -175,7 +175,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_port))?;
|
||||
let socket = UdpSocket::bind((self.context.dns_host.as_str(), self.context.dns_port))?;
|
||||
|
||||
// Spawn threads for handling requests
|
||||
for thread_id in 0..self.thread_count {
|
||||
@@ -290,7 +290,7 @@ impl DnsTcpServer {
|
||||
|
||||
impl DnsServer for DnsTcpServer {
|
||||
fn run_server(mut self) -> Result<()> {
|
||||
let socket = TcpListener::bind(("::", self.context.dns_port))?;
|
||||
let socket = TcpListener::bind((self.context.dns_host.as_str(), self.context.dns_port))?;
|
||||
|
||||
// Spawn threads for handling requests, and create the channels
|
||||
for thread_id in 0..self.thread_count {
|
||||
|
||||
Reference in New Issue
Block a user