Skip to content

Commit 9870c49

Browse files
author
Vinh Duong
committed
fix
1 parent a832a43 commit 9870c49

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,6 @@ clap = "2.32"
1717
lazy_static = "1.4"
1818
ajson = "0.2"
1919
async-std = { version = "1.5", features = ["std"], default-features = false }
20+
21+
[target.'cfg(not(windows))'.dependencies]
2022
rlimit = "0.3"

src/main.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ use tokio_io_timeout::TimeoutReader;
1818

1919
use async_std::sync::{Arc, RwLock};
2020
use clap::{value_t, Arg};
21-
use rlimit;
2221
use std::collections::HashMap;
2322
use twoway::find_bytes;
2423
extern crate ajson;
@@ -27,6 +26,9 @@ extern crate lazy_static;
2726
#[macro_use]
2827
extern crate clap;
2928

29+
#[cfg(not(windows))]
30+
use rlimit;
31+
3032
type HttpClient = Client<hyper::client::HttpConnector>;
3133
type HttpsClient = Client<HttpsConnector<hyper::client::HttpConnector>>;
3234
static mut DOH_ENDPOINT: &'static str = "https://1.1.1.1/dns-query";
@@ -149,7 +151,10 @@ async fn main() {
149151
}))
150152
}
151153
});
154+
155+
#[cfg(not(windows))]
152156
set_max_rlimit_nofile();
157+
153158
let server = Server::bind(&SocketAddr::from((
154159
[127, 0, 0, 1],
155160
value_t!(matches, "port", u16).unwrap(),
@@ -373,6 +378,7 @@ where
373378
}
374379
}
375380

381+
#[cfg(not(windows))]
376382
fn set_max_rlimit_nofile() {
377383
if rlimit::Resource::NOFILE
378384
.set(rlimit::RLIM_INFINITY, rlimit::RLIM_INFINITY)

0 commit comments

Comments
 (0)