Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Vinh Duong committed Apr 27, 2020
1 parent a832a43 commit 9870c49
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@ clap = "2.32"
lazy_static = "1.4"
ajson = "0.2"
async-std = { version = "1.5", features = ["std"], default-features = false }

[target.'cfg(not(windows))'.dependencies]
rlimit = "0.3"
8 changes: 7 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ use tokio_io_timeout::TimeoutReader;

use async_std::sync::{Arc, RwLock};
use clap::{value_t, Arg};
use rlimit;
use std::collections::HashMap;
use twoway::find_bytes;
extern crate ajson;
Expand All @@ -27,6 +26,9 @@ extern crate lazy_static;
#[macro_use]
extern crate clap;

#[cfg(not(windows))]
use rlimit;

type HttpClient = Client<hyper::client::HttpConnector>;
type HttpsClient = Client<HttpsConnector<hyper::client::HttpConnector>>;
static mut DOH_ENDPOINT: &'static str = "https://1.1.1.1/dns-query";
Expand Down Expand Up @@ -149,7 +151,10 @@ async fn main() {
}))
}
});

#[cfg(not(windows))]
set_max_rlimit_nofile();

let server = Server::bind(&SocketAddr::from((
[127, 0, 0, 1],
value_t!(matches, "port", u16).unwrap(),
Expand Down Expand Up @@ -373,6 +378,7 @@ where
}
}

#[cfg(not(windows))]
fn set_max_rlimit_nofile() {
if rlimit::Resource::NOFILE
.set(rlimit::RLIM_INFINITY, rlimit::RLIM_INFINITY)
Expand Down

0 comments on commit 9870c49

Please sign in to comment.