client: remove useless ClientOptions
This commit is contained in:
parent
78a971908b
commit
ef3657aadb
|
@ -11,21 +11,17 @@ use js_sys::{ArrayBuffer, Uint8Array};
|
||||||
use wasm_bindgen_futures::JsFuture;
|
use wasm_bindgen_futures::JsFuture;
|
||||||
use web_sys::{Headers, Request, RequestInit, Response};
|
use web_sys::{Headers, Request, RequestInit, Response};
|
||||||
|
|
||||||
pub struct ClientOptions {
|
|
||||||
pub upstream_urls: Vec<String>,
|
|
||||||
}
|
|
||||||
|
|
||||||
// The DNS client implementation
|
// The DNS client implementation
|
||||||
pub struct Client {
|
pub struct Client {
|
||||||
options: ClientOptions,
|
upstream_urls: Vec<String>,
|
||||||
cache: DnsCache,
|
cache: DnsCache,
|
||||||
override_resolver: OverrideResolver,
|
override_resolver: OverrideResolver,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Client {
|
impl Client {
|
||||||
pub fn new(options: ClientOptions, override_resolver: OverrideResolver) -> Client {
|
pub fn new(upstream_urls: Vec<String>, override_resolver: OverrideResolver) -> Client {
|
||||||
Client {
|
Client {
|
||||||
options,
|
upstream_urls,
|
||||||
cache: DnsCache::new(),
|
cache: DnsCache::new(),
|
||||||
override_resolver,
|
override_resolver,
|
||||||
}
|
}
|
||||||
|
@ -78,8 +74,8 @@ impl Client {
|
||||||
|
|
||||||
// Select an upstream randomly
|
// Select an upstream randomly
|
||||||
fn select_upstream(&self) -> String {
|
fn select_upstream(&self) -> String {
|
||||||
let idx = crate::util::random_range(0, self.options.upstream_urls.len() as u16);
|
let idx = crate::util::random_range(0, self.upstream_urls.len() as u16);
|
||||||
self.options.upstream_urls[idx as usize].clone()
|
self.upstream_urls[idx as usize].clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build UDP wireformat query from a list of questions
|
// Build UDP wireformat query from a list of questions
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use crate::client::*;
|
use crate::client::Client;
|
||||||
use crate::r#override::OverrideResolver;
|
use crate::r#override::OverrideResolver;
|
||||||
use async_static::async_static;
|
use async_static::async_static;
|
||||||
use domain::base::iana::{Opcode, Rcode};
|
use domain::base::iana::{Opcode, Rcode};
|
||||||
|
@ -60,9 +60,7 @@ impl Server {
|
||||||
fn new(options: ServerOptions) -> Server {
|
fn new(options: ServerOptions) -> Server {
|
||||||
Server {
|
Server {
|
||||||
client: Client::new(
|
client: Client::new(
|
||||||
ClientOptions {
|
options.upstream_urls.clone(),
|
||||||
upstream_urls: options.upstream_urls.clone(),
|
|
||||||
},
|
|
||||||
OverrideResolver::new(options.overrides.clone(), options.override_ttl),
|
OverrideResolver::new(options.overrides.clone(), options.override_ttl),
|
||||||
),
|
),
|
||||||
options,
|
options,
|
||||||
|
|
Loading…
Reference in a new issue