Skip to content

Commit e8eaddf

Browse files
committed
Fix Rlimit breaking change. (#283)
* Replace rlimit::rlim with rlimit::RawRlim Signed-off-by: u5surf <[email protected]>
1 parent 872eeb6 commit e8eaddf

File tree

4 files changed

+14
-15
lines changed

4 files changed

+14
-15
lines changed

Cargo.lock

Lines changed: 2 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ colored = "2.0.0"
2121
structopt = "0.3.20"
2222
async-std = "1.6.4"
2323
futures = "0.3"
24-
rlimit = "0.4.0"
24+
rlimit = "0.5.2"
2525
shell-words = "1.0.0"
2626
log = "0.4.0"
2727
env_logger = "0.7.1"

src/input.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ pub struct Opts {
103103

104104
/// Automatically ups the ULIMIT with the value you provided.
105105
#[structopt(short, long)]
106-
pub ulimit: Option<rlimit::rlim>,
106+
pub ulimit: Option<rlimit::RawRlim>,
107107

108108
/// The order of scanning to be performed. The "serial" option will
109109
/// scan ports in ascending order while the "random" option will scan
@@ -205,7 +205,7 @@ pub struct Config {
205205
timeout: Option<u32>,
206206
tries: Option<u8>,
207207
no_nmap: Option<bool>,
208-
ulimit: Option<rlimit::rlim>,
208+
ulimit: Option<rlimit::RawRlim>,
209209
scan_order: Option<ScanOrder>,
210210
command: Option<Vec<String>>,
211211
}

src/main.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use benchmark::{Benchmark, NamedTimer};
1717
use cidr_utils::cidr::IpCidr;
1818
use colorful::{Color, Colorful};
1919
use futures::executor::block_on;
20-
use rlimit::{getrlimit, setrlimit, Resource};
20+
use rlimit::{getrlimit, setrlimit, Resource, Rlim, RawRlim};
2121
use std::collections::HashMap;
2222
use std::fs::File;
2323
use std::io::{prelude::*, BufReader};
@@ -31,9 +31,9 @@ extern crate colorful;
3131
extern crate dirs;
3232

3333
// Average value for Ubuntu
34-
const DEFAULT_FILE_DESCRIPTORS_LIMIT: rlimit::rlim = 8000;
34+
const DEFAULT_FILE_DESCRIPTORS_LIMIT: RawRlim = 8000;
3535
// Safest batch size based on experimentation
36-
const AVERAGE_BATCH_SIZE: rlimit::rlim = 3000;
36+
const AVERAGE_BATCH_SIZE: RawRlim = 3000;
3737

3838
#[macro_use]
3939
extern crate log;
@@ -67,7 +67,7 @@ fn main() {
6767
std::process::exit(1);
6868
}
6969

70-
let ulimit: rlimit::rlim = adjust_ulimit_size(&opts);
70+
let ulimit: RawRlim = adjust_ulimit_size(&opts);
7171
let batch_size: u16 = infer_batch_size(&opts, ulimit);
7272

7373
let scanner = Scanner::new(
@@ -319,9 +319,9 @@ fn build_nmap_arguments<'a>(
319319
arguments
320320
}
321321

322-
fn adjust_ulimit_size(opts: &Opts) -> rlimit::rlim {
322+
fn adjust_ulimit_size(opts: &Opts) -> RawRlim {
323323
if opts.ulimit.is_some() {
324-
let limit: rlimit::rlim = opts.ulimit.unwrap();
324+
let limit: Rlim = Rlim::from_raw(opts.ulimit.unwrap());
325325

326326
match setrlimit(Resource::NOFILE, limit, limit) {
327327
Ok(_) => {
@@ -343,11 +343,11 @@ fn adjust_ulimit_size(opts: &Opts) -> rlimit::rlim {
343343

344344
let (rlim, _) = getrlimit(Resource::NOFILE).unwrap();
345345

346-
rlim
346+
rlim.as_raw()
347347
}
348348

349-
fn infer_batch_size(opts: &Opts, ulimit: rlimit::rlim) -> u16 {
350-
let mut batch_size: rlimit::rlim = opts.batch_size.into();
349+
fn infer_batch_size(opts: &Opts, ulimit: RawRlim) -> u16 {
350+
let mut batch_size: RawRlim = opts.batch_size.into();
351351

352352
// Adjust the batch size when the ulimit value is lower than the desired batch size
353353
if ulimit < batch_size {

0 commit comments

Comments
 (0)