Dataset Viewer
Auto-converted to Parquet Duplicate
id
stringlengths
18
18
chunk_id
stringlengths
16
16
repo
stringclasses
1 value
repo_url
stringclasses
1 value
commit
stringclasses
1 value
license
stringclasses
1 value
path
stringclasses
13 values
kind
stringclasses
6 values
name
stringlengths
3
37
context
stringclasses
20 values
start_line
int32
3
597
end_line
int32
8
601
num_lines
int32
3
113
question
stringlengths
167
1.37k
answer
stringlengths
62
4.41k
model
stringclasses
1 value
737722ecfc73ea73-0
737722ecfc73ea73
bee-san/RustScan
https://github.com/bee-san/RustScan
937903340aa6266abb26e93ea3241026b3fd8150
GPL-3.0-only
benches/benchmark_helpers.rs
function
old_payload_for_port
40
48
9
I need a function called `old_payload_for_port` that retrieves a static byte slice payload associated with a given port from a predefined mapping. The mapping is a static `BTreeMap` where each key is a `Vec<u16>` representing valid ports, and each value is a `Vec<u8>` payload. The function should accept a `&'static BTr...
fn old_payload_for_port(udp_map: &'static BTreeMap<Vec<u16>, Vec<u8>>, port: u16) -> &'static [u8] { let mut payload: &'static [u8] = b""; for (ports, value) in udp_map.iter() { if ports.contains(&port) { payload = value.as_slice(); } } payload }
nvidia/nemotron-3.5-lightning-30b-a3b
9488ac8bbb20dc37-0
9488ac8bbb20dc37
bee-san/RustScan
https://github.com/bee-san/RustScan
937903340aa6266abb26e93ea3241026b3fd8150
GPL-3.0-only
benches/benchmark_helpers.rs
function
bench_address_parsing
20
36
17
I need a zero-argument Rust function called `bench_address_parsing` that sets up an `Opts` configuration with a mix of individual IP addresses and CIDR ranges for scanning, along with a list of excluded addresses/subnets, and then invokes `rustscan::address::parse_addresses` to parse them. The function should populate ...
fn bench_address_parsing() { let opts = Opts { addresses: vec![ "127.0.0.1".to_owned(), "10.2.0.1".to_owned(), "192.168.0.0/24".to_owned(), ], exclude_addresses: Some(vec![ "10.0.0.0/8".to_owned(), "172.16.0.0/12".to_owned(), ...
nvidia/nemotron-3.5-lightning-30b-a3b
1e2c3cecf60796c4-0
1e2c3cecf60796c4
bee-san/RustScan
https://github.com/bee-san/RustScan
937903340aa6266abb26e93ea3241026b3fd8150
GPL-3.0-only
build.rs
function
ports_v
115
159
45
I need a Rust function named `ports_v` that processes a `&BTreeMap<i32, String>` containing parsed scan file data and returns a `BTreeMap<i32, Vec<u16>>`. For each entry, the function should check if the associated string contains the prefix `udp `. If present, it strips that prefix, extracts the remaining port specifi...
/// Creates a BTreeMap of line numbers mapped to a Vec<u16> of ports /// /// # Arguments /// /// * `fp_map` - A BTreeMap containing the parsed file data /// /// # Returns /// /// A BTreeMap where keys are line numbers and values are vectors of ports fn ports_v(fp_map: &BTreeMap<i32, String>) -> BTreeMap<i32, Vec<u16>> ...
nvidia/nemotron-3.5-lightning-30b-a3b
f575944a7c207fb4-0
f575944a7c207fb4
bee-san/RustScan
https://github.com/bee-san/RustScan
937903340aa6266abb26e93ea3241026b3fd8150
GPL-3.0-only
build.rs
function
main
10
58
49
I need a Rust `main` function that reads a file named `nmap-payloads` from the current directory, parses its contents line by line to construct a `BTreeMap<i32, String>`, skipping empty lines and those starting with `#`, handling CRLF line endings by stripping trailing carriage returns, and beginning payload capture wh...
pub fn main() { let mut file_path = env::current_dir().expect("cant find curr dir"); file_path.push("./nmap-payloads"); let mut data = String::new(); let file = File::open(&file_path).expect("File not found."); let mut file_buf = BufReader::new(file); file_buf .read_to_string(&mut data)...
nvidia/nemotron-3.5-lightning-30b-a3b
bf487128e1000ecd-0
bf487128e1000ecd
bee-san/RustScan
https://github.com/bee-san/RustScan
937903340aa6266abb26e93ea3241026b3fd8150
GPL-3.0-only
build.rs
function
parser
185
216
32
Write a free Rust function `parser` that converts a quoted Nmap payload block into bytes. The function should accept a `&str` payload starting at its first opening quote, where the payload contains one or more `"..."` segments separated by whitespace. It should return `Vec<u8>` by decoding each segment with `decode_seg...
/// Converts a quoted Nmap payload block to bytes. /// /// # Arguments /// /// * `payload` - The raw block text starting at its first opening quote: /// one or more `"..."` segments separated by whitespace /// /// # Returns /// /// The decoded probe bytes: segments are decoded with [`decode_segment`] /// and concaten...
nvidia/nemotron-3.5-lightning-30b-a3b
ceeb365e5372abbf-0
ceeb365e5372abbf
bee-san/RustScan
https://github.com/bee-san/RustScan
937903340aa6266abb26e93ea3241026b3fd8150
GPL-3.0-only
benches/benchmark_helpers.rs
function
bench_port_strategy
15
18
4
I need a Rust function named `bench_port_strategy` that benchmarks port strategy selection by creating a `PortRanges` instance covering the range `1_000`, cloning it, wrapping it in `Some`, and passing it by reference to `PortStrategy::pick` along with `None` and `ScanOrder::Serial`. The function must return `()` and s...
fn bench_port_strategy() { let range = PortRanges(vec![(1, 1_000)]); let _strategy = PortStrategy::pick(&Some(range.clone()), None, ScanOrder::Serial); }
nvidia/nemotron-3.5-lightning-30b-a3b
7ea0af9bd90ad47f-0
7ea0af9bd90ad47f
bee-san/RustScan
https://github.com/bee-san/RustScan
937903340aa6266abb26e93ea3241026b3fd8150
GPL-3.0-only
build.rs
function
generate_code
60
113
54
I need a Rust function named `generate_code` that accepts a `BTreeMap<Vec<u16>, Vec<u8>>` mapping port numbers to payload data, generates a Rust source file with a function that builds and returns that map using array literals, a `once_cell::sync::Lazy` static wrapping the result, and a public function to access the st...
/// Generates a file called Generated.rs and calls cargo fmt from the command line /// /// # Arguments /// /// * `port_payload_map` - A BTreeMap mapping port numbers to payload data fn generate_code(port_payload_map: BTreeMap<Vec<u16>, Vec<u8>>) { let dest_path = PathBuf::from("src/generated.rs"); let mut gene...
nvidia/nemotron-3.5-lightning-30b-a3b
9d50fbcfe15210f6-0
9d50fbcfe15210f6
bee-san/RustScan
https://github.com/bee-san/RustScan
937903340aa6266abb26e93ea3241026b3fd8150
GPL-3.0-only
benches/benchmark_helpers.rs
function
bench_address
11
13
3
I need a Rust function named `bench_address` that takes no parameters and returns nothing. Inside the function body, it should parse the string literal `127.0.0.1` into Rust's `std::net::IpAddr` type using `.parse::<IpAddr>()`, immediately call `.unwrap()` on the resulting `Result`, and store the parsed address in a va...
fn bench_address() { let _addrs = ["127.0.0.1".parse::<IpAddr>().unwrap()]; }
nvidia/nemotron-3.5-lightning-30b-a3b
8932eab476afb3a8-0
8932eab476afb3a8
bee-san/RustScan
https://github.com/bee-san/RustScan
937903340aa6266abb26e93ea3241026b3fd8150
GPL-3.0-only
build.rs
function
port_payload_map
281
306
26
I need a Rust function called `port_payload_map` that merges two `BTreeMap`s indexed by line numbers. The first maps line numbers to vectors of port numbers (`Vec<u16>`), and the second maps line numbers to vectors of payload bytes (`Vec<u8>`). The function should iterate over both maps, match entries by identical line...
/// Combines the ports BTreeMap and the Payloads BTreeMap /// /// # Arguments /// /// * `pb_linenr` - A BTreeMap mapping line numbers to vectors of ports /// * `payb_linenr` - A BTreeMap mapping line numbers to vectors of payload bytes /// /// # Returns /// /// A BTreeMap mapping vectors of ports to vectors of payload ...
nvidia/nemotron-3.5-lightning-30b-a3b
adfb7535daebf8b4-0
adfb7535daebf8b4
bee-san/RustScan
https://github.com/bee-san/RustScan
937903340aa6266abb26e93ea3241026b3fd8150
GPL-3.0-only
build.rs
function
split_segment
218
238
21
I need a Rust function named `split_segment` that takes a string slice `text: &str` representing the content inside a quoted section (starting right after an opening `"`). The function should locate the first unescaped closing `"` character, return the segment body (the text from the start up to but not including that ...
/// Splits off the first `"..."` segment: `text` must start just after an /// opening quote. Escaped quotes (`\"`) do not terminate the segment. /// /// Returns the segment body and the remainder after the closing quote. fn split_segment(text: &str) -> Option<(&str, &str)> { let mut escaped = false; for (i, c) ...
nvidia/nemotron-3.5-lightning-30b-a3b
6de75f784fd37239-0
6de75f784fd37239
bee-san/RustScan
https://github.com/bee-san/RustScan
937903340aa6266abb26e93ea3241026b3fd8150
GPL-3.0-only
benches/benchmark_helpers.rs
function
criterion_benchmark
50
130
81
Write a Rust function named criterion_benchmark that configures performance benchmarks using the criterion crate for a network scanning application. The function should accept &mut criterion::Criterion and establish benchmark groups for address parsing and port preparation, iterating over varying port and exclusion cou...
fn criterion_benchmark(c: &mut Criterion) { // Benching helper functions c.bench_function("parse address", |b| b.iter(bench_address)); c.bench_function("port strategy", |b| b.iter(bench_port_strategy)); let mut address_group = c.benchmark_group("address parsing"); address_group.measurement_time(Du...
nvidia/nemotron-3.5-lightning-30b-a3b
4be58eb3f84c7911-0
4be58eb3f84c7911
bee-san/RustScan
https://github.com/bee-san/RustScan
937903340aa6266abb26e93ea3241026b3fd8150
GPL-3.0-only
src/address.rs
function
parse_addresses
20
44
25
I need a Rust function that parses address options into a deduplicated vector of IP addresses. The function should take a reference to an `Opts` struct, handle parsing of individual IP strings, subnet notations, and file-based inputs, resolve hostnames, and strip duplicates to prevent redundant scanning. Crucially, it'...
/// Parses the string(s) into IP addresses. /// /// Goes through all possible IP inputs (files or via argparsing). /// /// ```rust /// # use rustscan::input::Opts; /// # use rustscan::address::parse_addresses; /// let mut opts = Opts::default(); /// opts.addresses = vec!["192.168.0.0/30".to_owned()]; /// /// let ips = ...
nvidia/nemotron-3.5-lightning-30b-a3b
7718b7a6cbd992c9-0
7718b7a6cbd992c9
bee-san/RustScan
https://github.com/bee-san/RustScan
937903340aa6266abb26e93ea3241026b3fd8150
GPL-3.0-only
src/address.rs
function
resolve_ips_from_host
139
155
17
I need a Rust function that resolves IP addresses from a given hostname using DNS, attempting `to_socket_addrs` first and falling back to a provided resolver's `lookup_ip` method if resolution fails. The function should accept a string slice for the hostname and a backup resolver closure that returns a `&Resolver`, and...
/// Uses DNS to get the IPS associated with host fn resolve_ips_from_host<'a>( source: &str, backup_resolver: &impl Fn() -> &'a Resolver, ) -> Vec<IpAddr> { let mut ips: Vec<IpAddr> = Vec::new(); if let Ok(addrs) = source.to_socket_addrs() { for ip in addrs { ips.push(ip.ip()); ...
nvidia/nemotron-3.5-lightning-30b-a3b
eb834e0822234375-0
eb834e0822234375
bee-san/RustScan
https://github.com/bee-san/RustScan
937903340aa6266abb26e93ea3241026b3fd8150
GPL-3.0-only
src/address.rs
function
parse_excluded_networks
157
175
19
I need a function `parse_excluded_networks` that parses a list of excluded network addresses. It should accept an optional reference to a vector of strings and a DNS resolver, handle CIDR notation, single IP addresses, and hostnames that require resolution via the resolver, and return a vector of `IpCidr` types. The fu...
/// Parses excluded networks from a list of addresses. /// /// This function handles three types of inputs: /// 1. CIDR notation (e.g. "192.168.0.0/24") /// 2. Single IP addresses (e.g. "192.168.0.1") /// 3. Hostnames that need to be resolved (e.g. "example.com") /// /// ```rust /// # use rustscan::address::parse_exclu...
nvidia/nemotron-3.5-lightning-30b-a3b
7ea219d21a101f22-0
7ea219d21a101f22
bee-san/RustScan
https://github.com/bee-san/RustScan
937903340aa6266abb26e93ea3241026b3fd8150
GPL-3.0-only
build.rs
function
payloads_v
161
183
23
I need a Rust function named `payloads_v` that accepts a reference to a `BTreeMap<i32, String>` called `fp_map` and returns a `BTreeMap<i32, Vec<u8>>`. The function should iterate over each key-value pair in the input map, where the key is a line number and the value is a string of parsed file data. For any string cont...
/// Parses out the Payloads into a BTreeMap of line numbers mapped to vectors of payload bytes /// /// # Arguments /// /// * `fp_map` - A BTreeMap containing the parsed file data /// /// # Returns /// /// A BTreeMap where keys are line numbers and values are vectors of payload bytes fn payloads_v(fp_map: &BTreeMap<i32,...
nvidia/nemotron-3.5-lightning-30b-a3b
92397827a920d5b4-0
92397827a920d5b4
bee-san/RustScan
https://github.com/bee-san/RustScan
937903340aa6266abb26e93ea3241026b3fd8150
GPL-3.0-only
src/address.rs
function
parse_addresses_with_resolver
46
99
54
I'm working on a Rust network scanning tool and need a function named `parse_addresses_with_resolver` that converts a list of target addresses into a deduplicated, exclusion-filtered list of `IpAddr` values. The function should take a reference to an `Opts` configuration struct and a closure `create_resolver` that retu...
fn parse_addresses_with_resolver( input: &Opts, create_resolver: impl FnOnce() -> Resolver, ) -> Vec<IpAddr> { let mut ips: Vec<IpAddr> = Vec::new(); let mut unresolved_addresses: Vec<&str> = Vec::new(); // Most scans use literal IPs or CIDRs. Defer the resolver's runtime and // hosts-file loadi...
nvidia/nemotron-3.5-lightning-30b-a3b
aad9c521f92331ea-0
aad9c521f92331ea
bee-san/RustScan
https://github.com/bee-san/RustScan
937903340aa6266abb26e93ea3241026b3fd8150
GPL-3.0-only
src/address.rs
function
parse_address
101
116
16
I need a Rust function that parses a string as a host, IP address, or CIDR block for a network scanning tool. It should accept a string slice and a reference to a `hickory_resolver::Resolver`, and return a `Vec<std::net::IpAddr>`. The function should be callable every time a possible IP-or-host is available, and if the...
/// Given a string, parse it as a host, IP address, or CIDR. /// /// This allows us to pass files as hosts or cidr or IPs easily /// Call this every time you have a possible IP-or-host. /// /// If the address is a domain, we can self-resolve the domain locally /// or resolve it by dns resolver list. /// /// ```rust ///...
nvidia/nemotron-3.5-lightning-30b-a3b
8f9b1807d1bf9868-0
8f9b1807d1bf9868
bee-san/RustScan
https://github.com/bee-san/RustScan
937903340aa6266abb26e93ea3241026b3fd8150
GPL-3.0-only
src/address.rs
function
get_resolver
207
241
35
I need a function `get_resolver` that accepts `&Option<String>` and returns a `Resolver`. When the option is `Some`, it should attempt to read resolver IPs from a file at that path; if reading fails, parse the string as a comma-separated list of IP addresses and configure nameservers on UDP port 53. When the option is ...
/// Derive a DNS resolver. /// /// 1. if the `resolver` parameter has been set: /// 1. assume the parameter is a path and attempt to read IPs. /// 2. parse the input as a comma-separated list of IPs. /// 2. if `resolver` is not set: /// 1. attempt to derive a resolver from the system config. (e.g. /// ...
nvidia/nemotron-3.5-lightning-30b-a3b
5be6769e4e1ad45b-0
5be6769e4e1ad45b
bee-san/RustScan
https://github.com/bee-san/RustScan
937903340aa6266abb26e93ea3241026b3fd8150
GPL-3.0-only
src/address.rs
function
parse_single_excluded_address
188
205
18
I need a standalone Rust function named `parse_single_excluded_address` that converts a given address string into a vector of `IpCidr` values. It should accept two parameters: a string slice `addr` and a resolver factory implemented as `&impl Fn() -> &'a Resolver`. The function should first try to parse `addr` as a CID...
/// Parses a single address into an IpCidr, handling CIDR notation, IP addresses, and hostnames. fn parse_single_excluded_address<'a>( addr: &str, resolver: &impl Fn() -> &'a Resolver, ) -> Vec<IpCidr> { if let Ok(cidr) = IpCidr::from_str(addr) { return vec![cidr]; } if let Ok(ip) = IpAddr:...
nvidia/nemotron-3.5-lightning-30b-a3b
168d0a425118b833-0
168d0a425118b833
bee-san/RustScan
https://github.com/bee-san/RustScan
937903340aa6266abb26e93ea3241026b3fd8150
GPL-3.0-only
src/address.rs
function
parse_excluded_networks_with_resolver
177
186
10
I need a Rust function `parse_excluded_networks_with_resolver` that accepts an optional reference to a vector of strings for excluded network addresses and a resolver callable returning a `Resolver` with a lifetime. The function should flatten the optional input, parse each address string into an `IpCidr` using the res...
fn parse_excluded_networks_with_resolver<'a>( exclude_addresses: &Option<Vec<String>>, resolver: &impl Fn() -> &'a Resolver, ) -> Vec<IpCidr> { exclude_addresses .iter() .flatten() .flat_map(|addr| parse_single_excluded_address(addr, resolver)) .collect() }
nvidia/nemotron-3.5-lightning-30b-a3b
1806500db1b12402-0
1806500db1b12402
bee-san/RustScan
https://github.com/bee-san/RustScan
937903340aa6266abb26e93ea3241026b3fd8150
GPL-3.0-only
src/address.rs
function
resolver_opts
271
282
12
I need a free function called `resolver_opts` that returns a `ResolverOpts` value. The function should check whether the Windows system root is missing using `windows_system_root_missing()`, and if that's the case, it must disable the hosts file by setting `use_hosts_file` to `false` on the options. Otherwise, it retur...
/// Resolver options that are safe to use in the current environment. /// /// hickory-resolver eagerly loads the hosts file when `use_hosts_file` is set /// (the default), which hits the same missing-`SystemRoot` panic described in /// [`windows_system_root_missing`]; disable it in that case. fn resolver_opts() -> Reso...
nvidia/nemotron-3.5-lightning-30b-a3b
3ba9c81174ac6738-0
3ba9c81174ac6738
bee-san/RustScan
https://github.com/bee-san/RustScan
937903340aa6266abb26e93ea3241026b3fd8150
GPL-3.0-only
src/address.rs
function
system_resolver
254
269
16
I need a free Rust function called `system_resolver` that returns `std::io::Result<Resolver>`. It should first check if the Windows SystemRoot environment variable is missing by calling `windows_system_root_missing()`. If that function returns true, the function should log a debug message and return an `std::io::Error`...
/// Derives a resolver from the system configuration, e.g. `/etc/resolv.conf` /// on *nix or the registry on Windows. /// /// Returns an error without touching the system configuration when doing so /// would panic inside hickory-resolver (see [`windows_system_root_missing`]). fn system_resolver() -> std::io::Result<Re...
nvidia/nemotron-3.5-lightning-30b-a3b
ec75c28cd9afab48-0
ec75c28cd9afab48
bee-san/RustScan
https://github.com/bee-san/RustScan
937903340aa6266abb26e93ea3241026b3fd8150
GPL-3.0-only
src/address.rs
function
windows_system_root_missing
243
252
10
I need a Rust free function named `windows_system_root_missing` that returns `true` when running on Windows and the `SystemRoot` environment variable is not set, and `false` otherwise. This check is needed because `hickory-resolver` locates the hosts file via `std::env::var_os("SystemRoot").expect(...)`, which panics i...
/// `true` on Windows when the `SystemRoot` environment variable is unset. /// /// hickory-resolver locates the hosts file via /// `std::env::var_os("SystemRoot").expect(...)`, which panics when the /// variable is missing. Processes spawned with a minimal environment /// (services, scheduled tasks, WMI) can lack `Syst...
nvidia/nemotron-3.5-lightning-30b-a3b
1b548203734a3741-0
1b548203734a3741
bee-san/RustScan
https://github.com/bee-san/RustScan
937903340aa6266abb26e93ea3241026b3fd8150
GPL-3.0-only
src/address.rs
function
parse_address_with_resolver
118
137
20
Write a Rust function named parse_address_with_resolver that accepts a string slice address and a resolver closure &impl Fn() -> &'a Resolver, returning Vec<IpAddr>. First, attempt to parse address as a raw IP via IpAddr::from_str; if successful, return a vector containing that IP. If not, try parsing as a network via ...
fn parse_address_with_resolver<'a>( address: &str, resolver: &impl Fn() -> &'a Resolver, ) -> Vec<IpAddr> { if let Ok(addr) = IpAddr::from_str(address) { // `address` is an IP string vec![addr] } else if let Ok(net_addr) = IpInet::from_str(address) { // `address` is a CIDR string...
nvidia/nemotron-3.5-lightning-30b-a3b
234a1c1719c33d9d-0
234a1c1719c33d9d
bee-san/RustScan
https://github.com/bee-san/RustScan
937903340aa6266abb26e93ea3241026b3fd8150
GPL-3.0-only
build.rs
function
decode_segment
240
279
40
I need a Rust function named `decode_segment` that decodes a single Nmap payload segment formatted in C-style escape sequences. The function should accept two parameters: a string slice `segment: &str` and a mutable byte vector `bytes: &mut Vec<u8>`. It must process the segment character by character: non-backslash cha...
/// Decodes one quoted Nmap payload segment in C-style escape format: /// `\xNN` becomes a byte, common single-char escapes (`\\`, `\"`, /// `\0`, `\n`, `\r`, `\t`) decode to their value, and every other /// character contributes its literal bytes. /// /// Preserving literal text matters: several probes embed plain-tex...
nvidia/nemotron-3.5-lightning-30b-a3b
455e18fef35f76fc-0
455e18fef35f76fc
bee-san/RustScan
https://github.com/bee-san/RustScan
937903340aa6266abb26e93ea3241026b3fd8150
GPL-3.0-only
src/address.rs
function
read_ips_from_file
294
314
21
I need a Rust function that reads a file of IP addresses and parses them into IpAddr values. The function should accept a file path and a closure returning a reference to a Resolver type, read the file line by line, parse each line using a helper function parse_address_with_resolver, skip unparseable lines with a debug...
#[cfg(not(tarpaulin_include))] /// Parses an input file of IPs and uses those fn read_ips_from_file<'a>( ips: &std::path::Path, backup_resolver: &impl Fn() -> &'a Resolver, ) -> Result<Vec<IpAddr>, std::io::Error> { let file = File::open(ips)?; let reader = BufReader::new(file); let mut ips: Vec<Ip...
nvidia/nemotron-3.5-lightning-30b-a3b
dbfdaea376f8032a-0
dbfdaea376f8032a
bee-san/RustScan
https://github.com/bee-san/RustScan
937903340aa6266abb26e93ea3241026b3fd8150
GPL-3.0-only
src/benchmark/mod.rs
struct
NamedTimer
56
65
10
I need a Rust struct called `NamedTimer` that holds a name as a `&'static str`, an optional start `Instant`, and an optional end `Instant` for tracking execution time in benchmarks. The name will be presented in benchmark summaries, and the start and end instants will be used to calculate runtime. The struct should der...
/// The purpose of NamedTimer is to hold a name, /// start Instant and end Instant for a specific timer. /// The given name will be presented in the benchmark summary, /// start and end Instants will be used for calculating runtime. #[derive(Debug)] pub struct NamedTimer { name: &'static str, start: Option<Inst...
nvidia/nemotron-3.5-lightning-30b-a3b
4c833736cd54681b-0
4c833736cd54681b
bee-san/RustScan
https://github.com/bee-san/RustScan
937903340aa6266abb26e93ea3241026b3fd8150
GPL-3.0-only
src/address.rs
function
read_resolver_from_file
284
292
9
I need a Rust function that reads a text file of IP addresses (one per line), parses each line into an IpAddr after trimming whitespace, skips any lines that fail to parse, and returns a Result<Vec<IpAddr>, std::io::Error> propagating any file read errors. The function should accept a file path as a string.
/// Parses and input file of IPs for use in DNS resolution. fn read_resolver_from_file(path: &str) -> Result<Vec<IpAddr>, std::io::Error> { let ips = fs::read_to_string(path)? .lines() .filter_map(|line| IpAddr::from_str(line.trim()).ok()) .collect(); Ok(ips) }
nvidia/nemotron-3.5-lightning-30b-a3b
29e5033044df3c8f-0
29e5033044df3c8f
bee-san/RustScan
https://github.com/bee-san/RustScan
937903340aa6266abb26e93ea3241026b3fd8150
GPL-3.0-only
src/benchmark/mod.rs
method
start
impl NamedTimer
68
74
7
Write a `start` method for a `NamedTimer` struct that takes a `&'static str` as the timer's name, initializes the start time to the current instant, and returns a new `Self` with `end` set to `None`.
pub fn start(name: &'static str) -> Self { Self { name, start: Some(Instant::now()), end: None, } }
nvidia/nemotron-3.5-lightning-30b-a3b
bddae9c74ff1bb1f-0
bddae9c74ff1bb1f
bee-san/RustScan
https://github.com/bee-san/RustScan
937903340aa6266abb26e93ea3241026b3fd8150
GPL-3.0-only
src/benchmark/mod.rs
method
push
impl Benchmark
33
35
3
I need a `push` method implemented on the `Benchmark` type that takes a `NamedTimer` and appends it to the `named_timers` field, mutating `self` and returning nothing.
pub fn push(&mut self, timer: NamedTimer) { self.named_timers.push(timer); }
nvidia/nemotron-3.5-lightning-30b-a3b
208e564a0225526d-0
208e564a0225526d
bee-san/RustScan
https://github.com/bee-san/RustScan
937903340aa6266abb26e93ea3241026b3fd8150
GPL-3.0-only
src/benchmark/mod.rs
method
init
impl Benchmark
28
32
5
I need a public `init` method for the `Benchmark` type that constructs and returns a new instance with a `named_timers` field initialized to an empty `Vec`. The method should take no parameters and return `Self`, and be placed inside an `impl Benchmark` block.
pub fn init() -> Self { Self { named_timers: Vec::new(), } }
nvidia/nemotron-3.5-lightning-30b-a3b
ee2118554096a3b8-0
ee2118554096a3b8
bee-san/RustScan
https://github.com/bee-san/RustScan
937903340aa6266abb26e93ea3241026b3fd8150
GPL-3.0-only
src/benchmark/mod.rs
method
summary
impl Benchmark
37
53
17
I need a `summary` method added to `Benchmark` that produces a formatted summary string of all tracked benchmarks. The method takes `&self` and accesses `self.named_timers`, iterating over each timer. For each timer that has both `start` and `end` values, it computes the runtime duration via `saturating_duration_since`...
/// Summary of the benchmarks will destruct the vector, /// formats every element the same way and return /// a single String with all the available information /// for easy printing pub fn summary(&self) -> String { let mut summary = String::from("\nRustScan Benchmark Summary"); for timer in &self.named_timer...
nvidia/nemotron-3.5-lightning-30b-a3b
2104fc5c0d548374-0
2104fc5c0d548374
bee-san/RustScan
https://github.com/bee-san/RustScan
937903340aa6266abb26e93ea3241026b3fd8150
GPL-3.0-only
src/benchmark/mod.rs
method
end
impl NamedTimer
75
77
3
I need to implement a method `end` for a type that implements the `NamedTimer` trait. The method should take `&mut self` and set an `end` field of type `Option<Instant>` to `Some(Instant::now())`, thereby recording the current time to mark the end of a named timer interval. The method should return nothing.
pub fn end(&mut self) { self.end = Some(Instant::now()); }
nvidia/nemotron-3.5-lightning-30b-a3b
0b7f69b4bf34d4f2-0
0b7f69b4bf34d4f2
bee-san/RustScan
https://github.com/bee-san/RustScan
937903340aa6266abb26e93ea3241026b3fd8150
GPL-3.0-only
src/input.rs
enum
ScanOrder
13
20
8
I need a Rust enum called `ScanOrder` that represents the port scanning strategy. It should have two variants: `Serial`, which scans ports sequentially from start to end (e.g., 1 to 1_000), and `Random`, which randomizes the scan order. The enum must derive `Deserialize`, `Debug`, `ValueEnum`, `Clone`, `Copy`, `Partial...
/// Represents the strategy in which the port scanning will run. /// - Serial will run from start to end, for example 1 to 1_000. /// - Random will randomize the order in which ports will be scanned. #[derive(Deserialize, Debug, ValueEnum, Clone, Copy, PartialEq, Eq)] pub enum ScanOrder { Serial, Random, }
nvidia/nemotron-3.5-lightning-30b-a3b
a55882b733bf25b1-0
a55882b733bf25b1
bee-san/RustScan
https://github.com/bee-san/RustScan
937903340aa6266abb26e93ea3241026b3fd8150
GPL-3.0-only
src/input.rs
enum
ScriptsRequired
22
31
10
I need an enum in Rust called ScriptsRequired that represents the script execution mode for a scanning tool. It should have three variants: None to skip scripts and only show port scan results, Default to run the default embedded Nmap script, and Custom to read scripts from a configuration file and predefined folders. ...
/// Represents the scripts variant. /// - none will avoid running any script, only portscan results will be shown. /// - default will run the default embedded nmap script, that's part of RustScan since the beginning. /// - custom will read the ScriptConfig file and the available scripts in the predefined folders ...
nvidia/nemotron-3.5-lightning-30b-a3b
9915fab494fa4a97-0
9915fab494fa4a97
bee-san/RustScan
https://github.com/bee-san/RustScan
937903340aa6266abb26e93ea3241026b3fd8150
GPL-3.0-only
src/input.rs
method
deserialize
impl<'de> serde::Deserialize<'de> for PortRanges
54
76
23
I need to implement `serde::Deserialize` for a `PortRanges` type that deserializes from a configuration which can be either a single inclusive port range, a textual range specification, or an explicit list of pairs. The method should parse the input, convert a single or text format into a vector of `(u16, u16)` port ra...
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: serde::Deserializer<'de>, { let pairs = match PortRangesConfig::deserialize(deserializer)? { PortRangesConfig::Single { start, end } => vec![(start, end)], PortRangesConfig::Text(text) => { return parse_ranges(&tex...
nvidia/nemotron-3.5-lightning-30b-a3b
18ed702a665e43a6-0
18ed702a665e43a6
bee-san/RustScan
https://github.com/bee-san/RustScan
937903340aa6266abb26e93ea3241026b3fd8150
GPL-3.0-only
src/input.rs
enum
PortRangesConfig
40
51
12
I need a Rust enum named `PortRangesConfig` that deserializes port range configurations from a configuration file. The enum must accept three accepted spellings of `range`: a single range with `start` and `end` fields (compatible with existing configs), a plain text string such as `"1-500,1000-2500"`, and a list of int...
/// Accepted spellings of `range` in the configuration file. #[derive(Deserialize)] #[serde(untagged)] enum PortRangesConfig { /// `range = { start = 1, end = 1000 }`: the format used before multiple /// ranges were supported, kept so existing configuration files still work. Single { start: u16, end: u16 },...
nvidia/nemotron-3.5-lightning-30b-a3b
3efaad823dd682eb-0
3efaad823dd682eb
bee-san/RustScan
https://github.com/bee-san/RustScan
937903340aa6266abb26e93ea3241026b3fd8150
GPL-3.0-only
src/benchmark/mod.rs
struct
Benchmark
21
25
5
I need a public Rust struct named `Benchmark` that holds a collection of named timer entries. The struct should contain a field `named_timers` which is a `Vec<NamedTimer>`, and it should derive `Debug`. Each `NamedTimer` tracks a name along with `start` and `end` `Instant` values. The struct is intended for benchmarkin...
/// A Benchmark struct to hold NamedTimers with name, start and end Instants, #[derive(Debug)] pub struct Benchmark { named_timers: Vec<NamedTimer>, }
nvidia/nemotron-3.5-lightning-30b-a3b
d5303b410631d2a7-0
d5303b410631d2a7
bee-san/RustScan
https://github.com/bee-san/RustScan
937903340aa6266abb26e93ea3241026b3fd8150
GPL-3.0-only
src/input.rs
function
parse_range
79
96
18
I need a standalone Rust function named `parse_range` that accepts a `&str` and returns `Option<(u16, u16)>`. The function should parse a single token written as `start-end` (with optional surrounding whitespace), splitting it on the first hyphen, trimming both resulting parts, and parsing each as an unsigned 16-bit in...
#[cfg(not(tarpaulin_include))] /// Parse a single `start-end` token (e.g. "100-200") into `(start, end)`. /// Returns `None` when the token is malformed, cannot be parsed as `u16`, /// or `start > end`. fn parse_range(input: &str) -> Option<(u16, u16)> { let mut parts = input.trim().splitn(2, '-').map(str::trim); ...
nvidia/nemotron-3.5-lightning-30b-a3b
f222a9f045d2aad5-0
f222a9f045d2aad5
bee-san/RustScan
https://github.com/bee-san/RustScan
937903340aa6266abb26e93ea3241026b3fd8150
GPL-3.0-only
src/input.rs
struct
PortRanges
33
38
6
I need a Rust struct named PortRanges that models port ranges as inclusive (start, end) pairs of u16 values. The struct should wrap a Vec<(u16, u16)> and derive Debug, Clone, PartialEq, and Eq. It should be usable for representing ranges parsed from CLI arguments like -r/--range (e.g. 1-500,1000-2500) and from a config...
/// The port ranges to scan, as inclusive `(start, end)` pairs. /// /// Parsed from `-r/--range` (e.g. `1-500,1000-2500`) and from the `range` /// key of the configuration file. #[derive(Debug, Clone, PartialEq, Eq)] pub struct PortRanges(pub Vec<(u16, u16)>);
nvidia/nemotron-3.5-lightning-30b-a3b
04102dc06e891e35-0
04102dc06e891e35
bee-san/RustScan
https://github.com/bee-san/RustScan
937903340aa6266abb26e93ea3241026b3fd8150
GPL-3.0-only
src/input.rs
method
merge
impl Opts
302
310
9
I need a `merge` method on `impl Opts` that takes a `&Config` and merges configuration file values into the struct, but only if a `no_config` flag is not set. Command-line arguments should take precedence over the configuration file values. The method returns `()` and internally calls `merge_required` and `merge_option...
/// Reads the command line arguments into an Opts struct and merge /// values found within the user configuration file. Options given on the /// command line take precedence over the configuration file. pub fn merge(&mut self, config: &Config) { if !self.no_config { self.merge_required(config); self...
nvidia/nemotron-3.5-lightning-30b-a3b
d49e46359e5fa633-0
d49e46359e5fa633
bee-san/RustScan
https://github.com/bee-san/RustScan
937903340aa6266abb26e93ea3241026b3fd8150
GPL-3.0-only
src/input.rs
method
validate_platform
impl Opts
281
300
20
I need a method called validate_platform added to the Opts type that validates operating system compatibility for scan options. The method should take &self and return Result<(), String>. It must check whether the --ulimit option is used on a non-Unix platform; if so, it returns an error stating that --ulimit is only s...
/// Validates options whose availability or semantics depend on the /// operating system. /// /// # Errors /// /// Returns an error when an option is unsupported on the current platform. pub fn validate_platform(&self) -> Result<(), String> { #[cfg(not(unix))] { if self.ulimit.is_some() { re...
nvidia/nemotron-3.5-lightning-30b-a3b
1a0130187858110f-0
1a0130187858110f
bee-san/RustScan
https://github.com/bee-san/RustScan
937903340aa6266abb26e93ea3241026b3fd8150
GPL-3.0-only
src/input.rs
method
try_read_from
impl Opts
250
279
30
I need a method called `try_read_from` added to `impl Opts` that parses command-line arguments the same way `Opts::read` does, but instead of exiting on error, it returns a `Result<Self, clap::Error>`. The method should take an argument iterator, capture which arguments the user actually typed on the command line (so t...
/// Parses `args` like [`Opts::read`] does, returning an error instead of /// exiting. fn try_read_from<I, T>(args: I) -> Result<Self, clap::Error> where I: IntoIterator<Item = T>, T: Into<OsString> + Clone, { let mut command = Self::command(); let mut matches = command.try_get_matches_from_mut(args)?; ...
nvidia/nemotron-3.5-lightning-30b-a3b
02542a83db1ed412-0
02542a83db1ed412
bee-san/RustScan
https://github.com/bee-san/RustScan
937903340aa6266abb26e93ea3241026b3fd8150
GPL-3.0-only
src/input.rs
method
read
impl Opts
246
248
3
I need a public associated function `read` implemented for `impl Opts` that reads and parses configuration from `std::env::args_os()` using a `try_read_from` method on `Self`, and exits the program with the error if parsing fails. The function returns `Self`.
pub fn read() -> Self { Self::try_read_from(std::env::args_os()).unwrap_or_else(|e| e.exit()) }
nvidia/nemotron-3.5-lightning-30b-a3b
4549ea1ab6772039-0
4549ea1ab6772039
bee-san/RustScan
https://github.com/bee-san/RustScan
937903340aa6266abb26e93ea3241026b3fd8150
GPL-3.0-only
src/input.rs
method
merge_required
impl Opts
312
329
18
I need a method called `merge_required` implemented for my `Opts` struct inside `impl Opts`. The method should take a `&Config` parameter and merge specific required configuration fields from `config` into `self`, but only if each field is present in `config` and not already specified in `self.cli_args`. The fields to ...
fn merge_required(&mut self, config: &Config) { macro_rules! merge_required { ($($field: ident),+) => { $( if let Some(e) = &config.$field { if !self.cli_args.contains(stringify!($field)) { self.$field = e.clone(); }...
nvidia/nemotron-3.5-lightning-30b-a3b
2e1343e51eb08b15-0
2e1343e51eb08b15
bee-san/RustScan
https://github.com/bee-san/RustScan
937903340aa6266abb26e93ea3241026b3fd8150
GPL-3.0-only
src/input.rs
function
parse_ranges
97
121
25
I need a Rust function `parse_ranges` that takes a `&str` and returns `Result<PortRanges, String>`. It should parse a comma-separated list of `start-end` port ranges. The function must reject empty input with the message "empty input: expected one or more comma-separated 'start-end' pairs", and for each token, use a he...
#[cfg(not(tarpaulin_include))] /// Parse a comma-separated list of `start-end` ranges into `PortRanges`. /// /// Errors with a helpful message identifying the bad token. fn parse_ranges(input: &str) -> Result<PortRanges, String> { let s = input.trim(); if s.is_empty() { return Err("empty input: expected...
nvidia/nemotron-3.5-lightning-30b-a3b
a2d5007c72d57e55-0
a2d5007c72d57e55
bee-san/RustScan
https://github.com/bee-san/RustScan
937903340aa6266abb26e93ea3241026b3fd8150
GPL-3.0-only
src/input.rs
method
merge_optional
impl Opts
331
348
18
I need a method `merge_optional` implemented for `Opts` that merges optional configuration fields from a `Config` reference into the current instance. The method signature should be `fn merge_optional(&mut self, config: &Config)`. It must handle a predefined list of optional fields: `range`, `resolver`, `ulimit`, `excl...
fn merge_optional(&mut self, config: &Config) { macro_rules! merge_optional { ($($field: ident),+) => { $( if config.$field.is_some() && !self.cli_args.contains(stringify!($field)) { self.$field = config.$field.clone(); } )+ ...
nvidia/nemotron-3.5-lightning-30b-a3b
783354b58db03d5e-0
783354b58db03d5e
bee-san/RustScan
https://github.com/bee-san/RustScan
937903340aa6266abb26e93ea3241026b3fd8150
GPL-3.0-only
src/input.rs
function
legacy_dot_config_path
476
484
9
I need a Rust function called `legacy_dot_config_path` that returns the legacy configuration file path for RustScan. The function should retrieve the user's config directory using `dirs::config_dir()`, append `.rustscan.toml` to it, and return a `PathBuf`. If the config directory is unavailable, the function should pan...
/// Returns the transitional `$XDG_CONFIG_HOME/.rustscan.toml` path that older /// builds wrote to. Kept readable for backwards compatibility. pub fn legacy_dot_config_path() -> PathBuf { let Some(mut config_path) = dirs::config_dir() else { panic!("Could not infer config file path."); }; config_pat...
nvidia/nemotron-3.5-lightning-30b-a3b
91d365ab4c7e3bd8-0
91d365ab4c7e3bd8
bee-san/RustScan
https://github.com/bee-san/RustScan
937903340aa6266abb26e93ea3241026b3fd8150
GPL-3.0-only
src/input.rs
method
read
impl Config
412
461
50
I need a `read` method implemented for `Config` that accepts an `Option<PathBuf>` to specify a custom configuration file path. When called without a path, it should search for the config file starting at the XDG-standard location, then fall back to legacy dot-config and old default paths. The file should be read and pa...
/// Reads the configuration file with TOML format and parses it into a /// Config struct. /// /// # Format /// /// addresses = ["127.0.0.1", "127.0.0.1"] /// ports = [80, 443, 8080] /// greppable = true /// scan_order = "Serial" /// exclude_ports = [8080, 9090, 80] /// udp = false /// closed = false /// interval = 0 //...
nvidia/nemotron-3.5-lightning-30b-a3b
dc3149ab3d85b584-0
dc3149ab3d85b584
bee-san/RustScan
https://github.com/bee-san/RustScan
937903340aa6266abb26e93ea3241026b3fd8150
GPL-3.0-only
src/input.rs
method
default
impl Default for Opts
352
378
27
I need the `default` method implemented for `Opts` within `impl Default for Opts`. The method should return a new `Opts` instance with all fields initialized to their default values: `addresses` as an empty vector, `ports` and `range` as `None`, `greppable` as `true`, `batch_size`, `timeout`, `tries`, and `interval` as...
fn default() -> Self { Self { addresses: vec![], ports: None, range: None, greppable: true, batch_size: 0, timeout: 0, tries: 0, ulimit: None, command: vec![], accessible: false, resolver: None, scan_order: ScanOrder::Se...
nvidia/nemotron-3.5-lightning-30b-a3b
802534758d920f4f-0
802534758d920f4f
bee-san/RustScan
https://github.com/bee-san/RustScan
937903340aa6266abb26e93ea3241026b3fd8150
GPL-3.0-only
src/input.rs
struct
Opts
130
242
113
I need a Rust struct named Opts that represents the command-line options for a fast port scanning tool. The struct should include fields for target addresses Vec<String> port selection Option Vec u16 port ranges Option PortRanges configuration file path Option PathBuf scanning parameters such as batch size usize timeou...
#[allow(clippy::struct_excessive_bools)] /// Fast Port Scanner built in Rust. /// WARNING Do not use this program against sensitive infrastructure since the /// specified server may not be able to handle this many socket connections at once. /// - Discord <http://discord.skerritt.blog> /// - GitHub <https://github.com...
nvidia/nemotron-3.5-lightning-30b-a3b
57cd7bbbe76dae1d-0
57cd7bbbe76dae1d
bee-san/RustScan
https://github.com/bee-san/RustScan
937903340aa6266abb26e93ea3241026b3fd8150
GPL-3.0-only
src/input.rs
function
old_default_config_path
486
493
8
I need a Rust function named `old_default_config_path` that retrieves the home directory via the `dirs` crate and appends `.rustscan.toml` to it for backwards compatibility. The function returns a `PathBuf` and panics with the message "Could not infer config file path." if the home directory cannot be determined. It se...
/// Returns the deprecated home directory config path used for backwards compatibility. pub fn old_default_config_path() -> PathBuf { let Some(mut config_path) = dirs::home_dir() else { panic!("Could not infer config file path."); }; config_path.push(".rustscan.toml"); config_path }
nvidia/nemotron-3.5-lightning-30b-a3b
a41a2586fc2f7aeb-0
a41a2586fc2f7aeb
bee-san/RustScan
https://github.com/bee-san/RustScan
937903340aa6266abb26e93ea3241026b3fd8150
GPL-3.0-only
src/input.rs
function
default_config_path
464
474
11
Write a Rust function named `default_config_path` that returns a `PathBuf` representing the preferred configuration file path. The function should use the `dirs` crate to resolve the platform-appropriate config directory (on Linux, respecting `$XDG_CONFIG_HOME` with `~/.config` as fallback when unset, and the platform-...
/// Returns the preferred config file path: `$XDG_CONFIG_HOME/rustscan/config.toml` /// on Linux (with the usual `~/.config` fallback when the variable is unset), /// and the platform-equivalent `dirs::config_dir()` location on macOS / Windows. pub fn default_config_path() -> PathBuf { let Some(mut config_path) = d...
nvidia/nemotron-3.5-lightning-30b-a3b
08db42f6fd897299-0
08db42f6fd897299
bee-san/RustScan
https://github.com/bee-san/RustScan
937903340aa6266abb26e93ea3241026b3fd8150
GPL-3.0-only
src/main.rs
function
effective_batch_size
227
242
16
I need a Rust function `effective_batch_size` that takes `opts: &Opts` and returns `usize`. On Unix, it should adjust the batch size based on the process file-descriptor limit using `adjust_ulimit_size` and then infer the final size with `infer_batch_size`, while on non-Unix platforms it should simply return the `batch...
/// Determines the actual batch size used by the scanner. /// /// Unix systems may reduce the requested batch size according to the process /// file-descriptor limit. Other platforms, including Windows, use the batch /// size explicitly requested by the user. fn effective_batch_size(opts: &Opts) -> usize { #[cfg(un...
nvidia/nemotron-3.5-lightning-30b-a3b
08241b5ea9961f2a-0
08241b5ea9961f2a
bee-san/RustScan
https://github.com/bee-san/RustScan
937903340aa6266abb26e93ea3241026b3fd8150
GPL-3.0-only
src/main.rs
function
print_opening
263
302
40
I need a function named `print_opening` that takes `opts: &Opts` and prints the RustScan opening banner. It should render ASCII art with `.gradient(Color::Green).bold()`, then print a yellow-gradient info box with Discord and GitHub links. The function must call `funny_opening!()`, resolve the config path from `opts.co...
/// Prints the opening title of RustScan #[allow(clippy::items_after_statements, clippy::needless_raw_string_hashes)] fn print_opening(opts: &Opts) { debug!("Printing opening"); let s = r#".----. .-. .-. .----..---. .----. .---. .--. .-. .-. | {} }| { } |{ {__ {_ _}{ {__ / ___} / {} \ | `| | | .-. \| ...
nvidia/nemotron-3.5-lightning-30b-a3b
87b240416b28ca72-0
87b240416b28ca72
bee-san/RustScan
https://github.com/bee-san/RustScan
937903340aa6266abb26e93ea3241026b3fd8150
GPL-3.0-only
src/port_strategy/mod.rs
enum
PortStrategy
8
17
10
I need a Rust enum called `PortStrategy` that models port scanning strategies. It should have three variants: `Manual` for a manually specified list of ports, `Serial` for serial range scanning, and `Random` for random range scanning. The enum should derive `Debug` and include a doc comment noting that currently all op...
/// Represents options of port scanning. /// /// Right now all these options involve ranges, but in the future /// it will also contain custom lists of ports. #[derive(Debug)] pub enum PortStrategy { Manual(Vec<u16>), Serial(SerialRange), Random(RandomRange), }
nvidia/nemotron-3.5-lightning-30b-a3b
757f0ac06c355664-0
757f0ac06c355664
bee-san/RustScan
https://github.com/bee-san/RustScan
937903340aa6266abb26e93ea3241026b3fd8150
GPL-3.0-only
src/main.rs
function
run_scan
244
261
18
I need a function named `run_scan` that runs a network scan using a current-thread Tokio runtime. It should accept a `&Scanner` and return `std::io::Result<Vec<PortStatus>>`. The runtime must be created with `tokio::runtime::Builder::new_current_thread().enable_io().enable_time()`, and it should drive the scanner's `ru...
/// Runs the scan to completion on a current-thread Tokio runtime. /// /// The scanner drives every socket from a single future and never spawns /// tasks, so one thread is all it can use: a current-thread runtime runs the /// scan, the I/O driver and the timers on the calling thread, without the /// worker threads and...
nvidia/nemotron-3.5-lightning-30b-a3b
b4e78ea425db5e59-0
b4e78ea425db5e59
bee-san/RustScan
https://github.com/bee-san/RustScan
937903340aa6266abb26e93ea3241026b3fd8150
GPL-3.0-only
src/main.rs
function
adjust_ulimit_size
304
331
28
I need a Unix-exclusive function that manages the process resource limit for open file descriptors. It should accept a reference to a configuration struct that optionally specifies a ulimit value. When a value is provided, the function must attempt to set both the soft and hard `RLIMIT_NOFILE` limits to that number usi...
#[cfg(unix)] fn adjust_ulimit_size(opts: &Opts) -> usize { use rlimit::Resource; use std::convert::TryInto; if let Some(limit) = opts.ulimit { let limit = limit as u64; if Resource::NOFILE.set(limit, limit).is_ok() { detail!( format!("Automatically increasing uli...
nvidia/nemotron-3.5-lightning-30b-a3b
072b7bc53abbf334-0
072b7bc53abbf334
bee-san/RustScan
https://github.com/bee-san/RustScan
937903340aa6266abb26e93ea3241026b3fd8150
GPL-3.0-only
src/port_strategy/mod.rs
struct
SerialRange
59
64
6
I need a Rust struct named `SerialRange` that stores a collection of `u16` pairs in ascending order. The struct should derive `Debug` and use a `Vec<(u16, u16)>` as its internal field to represent the range. Please define this data type.
/// As the name implies SerialRange will always generate a vector in /// ascending order. #[derive(Debug)] pub struct SerialRange { range: Vec<(u16, u16)>, }
nvidia/nemotron-3.5-lightning-30b-a3b
899a672c2e9b4f9c-0
899a672c2e9b4f9c
bee-san/RustScan
https://github.com/bee-san/RustScan
937903340aa6266abb26e93ea3241026b3fd8150
GPL-3.0-only
src/input.rs
struct
Config
381
406
26
I need a Rust struct named `Config` that deserializes scanner configuration from a file. It should derive `Debug` and `Deserialize` so it can be loaded and then merged with command-line inputs to produce a final `Opts` struct. The struct should be gated behind `#[cfg(not(tarpaulin_include))]` and contain optional field...
/// Struct used to deserialize the options specified within our config file. /// These will be further merged with our command line arguments in order to /// generate the final Opts struct. #[cfg(not(tarpaulin_include))] #[derive(Debug, Deserialize)] pub struct Config { addresses: Option<Vec<String>>, ports: Op...
nvidia/nemotron-3.5-lightning-30b-a3b
d76d18fc3b8817ce-0
d76d18fc3b8817ce
bee-san/RustScan
https://github.com/bee-san/RustScan
937903340aa6266abb26e93ea3241026b3fd8150
GPL-3.0-only
src/port_strategy/mod.rs
method
order
impl PortStrategy
44
50
7
I need a public method order implemented on a PortStrategy enum that returns Vec<u16>. The enum has three variants: Manual which contains a port collection, and Serial and Random which each contain a range object with a generate method. The method should clone the ports from Manual and call generate() on the range for ...
pub fn order(&self) -> Vec<u16> { match self { PortStrategy::Manual(ports) => ports.clone(), PortStrategy::Serial(range) => range.generate(), PortStrategy::Random(range) => range.generate(), } }
nvidia/nemotron-3.5-lightning-30b-a3b
5fa79173c43add7b-0
5fa79173c43add7b
bee-san/RustScan
https://github.com/bee-san/RustScan
937903340aa6266abb26e93ea3241026b3fd8150
GPL-3.0-only
src/port_strategy/mod.rs
method
generate
impl RangeOrder for SerialRange
67
69
3
I need the `generate` method implemented for `SerialRange` that satisfies `RangeOrder`. It should take `&self` and return a `Vec<u16>` by iterating over the range serially using `RangeIterator::new_serial` and collecting the results.
fn generate(&self) -> Vec<u16> { RangeIterator::new_serial(&self.range).collect() }
nvidia/nemotron-3.5-lightning-30b-a3b
4f87ec8ce7698534-0
4f87ec8ce7698534
bee-san/RustScan
https://github.com/bee-san/RustScan
937903340aa6266abb26e93ea3241026b3fd8150
GPL-3.0-only
src/port_strategy/mod.rs
struct
RandomRange
72
77
6
I'm defining a Rust struct called `RandomRange` for a scanning utility. It should store a vector of `u16` pairs in a random order, where the randomness is achieved via an LCG algorithm. The struct needs a `range` field of type `Vec<(u16, u16)>`, a `Debug` derive, and a doc comment describing the LCG-based random orderi...
/// As the name implies RandomRange will always generate a vector with /// a random order. This vector is built following the LCG algorithm. #[derive(Debug)] pub struct RandomRange { range: Vec<(u16, u16)>, }
nvidia/nemotron-3.5-lightning-30b-a3b
81b78517d3d65a26-0
81b78517d3d65a26
bee-san/RustScan
https://github.com/bee-san/RustScan
937903340aa6266abb26e93ea3241026b3fd8150
GPL-3.0-only
src/main.rs
function
infer_batch_size
333
368
36
I need a Rust function named `infer_batch_size` that adjusts the scanning batch size based on the system's file descriptor limit, conditionally compiled only on Unix systems (`#[cfg(unix)]`). It should accept a reference to an `Opts` struct and a `ulimit` value (`usize`), and return an adjusted `usize` batch size. The ...
#[cfg(unix)] fn infer_batch_size(opts: &Opts, ulimit: usize) -> usize { let mut batch_size = opts.batch_size; // Adjust the batch size when the ulimit value is lower than the desired batch size if ulimit < batch_size { warning!("File limit is lower than default batch size. Consider upping with --ul...
nvidia/nemotron-3.5-lightning-30b-a3b
7befddc992dacbd8-0
7befddc992dacbd8
bee-san/RustScan
https://github.com/bee-san/RustScan
937903340aa6266abb26e93ea3241026b3fd8150
GPL-3.0-only
src/port_strategy/mod.rs
trait
RangeOrder
53
57
5
I need a Rust trait named `RangeOrder` that provides a method `generate` taking `&self` and returning `Vec<u16>`. This trait should represent a port strategy's ability to generate an ordered sequence of port numbers for scanning.
/// Trait associated with a port strategy. Each PortStrategy must be able /// to generate an order for future port scanning. trait RangeOrder { fn generate(&self) -> Vec<u16>; }
nvidia/nemotron-3.5-lightning-30b-a3b
dca8989e5e788f16-0
dca8989e5e788f16
bee-san/RustScan
https://github.com/bee-san/RustScan
937903340aa6266abb26e93ea3241026b3fd8150
GPL-3.0-only
src/port_strategy/mod.rs
method
pick
impl PortStrategy
20
42
23
I'm implementing a method `pick` on the `PortStrategy` type for a Rust network scanning tool. The method should accept a reference to `Option<PortRanges>`, an `Option<Vec<u16>>` of ports, and a `ScanOrder` enum value, and return `Self`. Based on the scan order and whether ports are explicitly provided, it should constr...
pub fn pick(range: &Option<PortRanges>, ports: Option<Vec<u16>>, order: ScanOrder) -> Self { match order { ScanOrder::Serial if ports.is_none() => { let port_ranges = range.as_ref().unwrap(); PortStrategy::Serial(SerialRange { range: port_ranges.0.clone(), ...
nvidia/nemotron-3.5-lightning-30b-a3b
3bdb33754c419b88-0
3bdb33754c419b88
bee-san/RustScan
https://github.com/bee-san/RustScan
937903340aa6266abb26e93ea3241026b3fd8150
GPL-3.0-only
src/port_strategy/range_iterator.rs
method
new_serial
impl RangeIterator
102
128
27
I need to implement a method `new_serial` for a type that implements `RangeIterator`. The method should accept `&[(u16, u16)]` and return `Self`, constructing a serial iterator that yields each port in the original input order while skipping duplicates on the fly using a seen table. The preconditions are that the input...
/// Construct a serial iterator that yields ports in original input order, /// skipping duplicates. The deduplication is done on the fly with a seen-table. /// /// Preconditions: /// - `input` must contain at least one `(u16,u16)` and each pair must satisfy `start <= end`. pub fn new_serial(input: &[(u16, u16)]) -> Sel...
nvidia/nemotron-3.5-lightning-30b-a3b
dbb85c21734193e6-0
dbb85c21734193e6
bee-san/RustScan
https://github.com/bee-san/RustScan
937903340aa6266abb26e93ea3241026b3fd8150
GPL-3.0-only
src/port_strategy/mod.rs
method
generate
impl RangeOrder for RandomRange
89
91
3
I need to implement a `generate` method for a struct `RandomRange` that implements the `RangeOrder` trait. The method should take `&self` and return a `Vec<u16>` by iterating over the internal range in random order and collecting the results into a vector. The implementation should use `RangeIterator::new_random` initi...
fn generate(&self) -> Vec<u16> { RangeIterator::new_random(&self.range).collect() }
nvidia/nemotron-3.5-lightning-30b-a3b
b86ac22f360fa787-0
b86ac22f360fa787
bee-san/RustScan
https://github.com/bee-san/RustScan
937903340aa6266abb26e93ea3241026b3fd8150
GPL-3.0-only
src/port_strategy/range_iterator.rs
method
new_random
impl RangeIterator
36
100
65
I'm implementing a `new_random` associated method for my `RangeIterator` type in Rust. This method should take a slice of `(u16, u16)` range pairs, normalize and merge them into contiguous `(start, length)` segments with `u32` values, build a prefix sum array over the merged lengths, then use a coprime step size and a ...
/// Construct a randomized iterator (LCG permutation). /// /// Preconditions: /// - `input` must contain at least one `(u16,u16)` /// and each pair must satisfy `start <= end`. pub fn new_random(input: &[(u16, u16)]) -> Self { // normalize & merge into (start, len) u32 pairs // Example: [(10,12),(11,15)] -> m...
nvidia/nemotron-3.5-lightning-30b-a3b
109ad5f8d59c740f-0
109ad5f8d59c740f
bee-san/RustScan
https://github.com/bee-san/RustScan
937903340aa6266abb26e93ea3241026b3fd8150
GPL-3.0-only
src/scanner/errors.rs
method
fmt
impl fmt::Display for ScanError
11
13
3
I need to implement `fmt::Display` for a `ScanError` struct that has an `error` field and an `ip` field. The display format should output the error message followed by a space and the IP address. Please provide the `fmt` method that formats the value as `error ip` and returns `fmt::Result`.
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{} {}", self.error, self.ip) }
nvidia/nemotron-3.5-lightning-30b-a3b
cbb3c946897aaa57-0
cbb3c946897aaa57
bee-san/RustScan
https://github.com/bee-san/RustScan
937903340aa6266abb26e93ea3241026b3fd8150
GPL-3.0-only
src/scanner/errors.rs
struct
ScanError
3
8
6
I need a struct that represents a scanning error by pairing an IP address with an underlying I/O error, keeping both intact for later diagnostic formatting. The struct should derive Debug and expose fields for the target IP (std::net::IpAddr) and the OS-level error (std::io::Error). I'm defining a custom error type for...
/// Keep the OS error and its target intact until diagnostics need formatting. #[derive(Debug)] struct ScanError { ip: IpAddr, error: io::Error, }
nvidia/nemotron-3.5-lightning-30b-a3b
eb67e0c0deb3271f-0
eb67e0c0deb3271f
bee-san/RustScan
https://github.com/bee-san/RustScan
937903340aa6266abb26e93ea3241026b3fd8150
GPL-3.0-only
src/port_strategy/range_iterator.rs
method
next
impl Iterator for RangeIterator
133
194
62
I need the `next` method implemented for `RangeIterator` as part of an `std::iter::Iterator` impl block. The method should advance the iterator by one port, supporting two paths: a serial mode that preserves input order and skips duplicate ports via a seen-bitset, and a randomized LCG-based mode that steps through norm...
/// Advance the iterator by one port. /// /// 1. Read the current normalized index `cur`. /// 2. Compute `next = (cur + step) % total` and update `normalized_pick`. /// 3. If `next == normalized_first_pick` mark `active = false` (we completed the cycle). /// 4. Map the returned index `cur` into the merged ranges via th...
nvidia/nemotron-3.5-lightning-30b-a3b
04adc843983fd506-0
04adc843983fd506
bee-san/RustScan
https://github.com/bee-san/RustScan
937903340aa6266abb26e93ea3241026b3fd8150
GPL-3.0-only
src/port_strategy/range_iterator.rs
struct
RangeIterator
5
33
29
I need a Rust struct called RangeIterator that yields u16 ports from a collection of potentially overlapping inclusive ranges. The struct should support two iteration modes: a randomized mode created via RangeIterator::new_random that uses an additive congruential generator with a full-length cycle where gcd(step, N) =...
/// Yields ports produced from a collection of (possibly overlapping) /// inclusive `u16` ranges in two modes: /// /// **Randomized** — created by `RangeIterator::new_random`: /// - The algorithm generates a permutation of indices `0..N-1` using the /// additive congruential step `x_{i+1} = (x_i + step) % N`. /...
nvidia/nemotron-3.5-lightning-30b-a3b
42c61eb7bbfa4bbf-0
42c61eb7bbfa4bbf
bee-san/RustScan
https://github.com/bee-san/RustScan
937903340aa6266abb26e93ea3241026b3fd8150
GPL-3.0-only
src/port_strategy/range_iterator.rs
function
pick_random_coprime
197
222
26
I need a function `pick_random_coprime` that takes a `u32` argument `end` and returns a `u32` coprime to `end`. The function should pick a random integer in the range `[end/4, end - end/4)` (excluding the edges near `start` and `end`) to avoid non‑ideal randomization. It should use a random number generator (e.g., `ran...
/// The probability that two random integers are coprime to one another /// works out to be around 61%, given that we can safely pick a random /// number and test it. Just in case we are having a bad day and we cannot /// pick a coprime number after 10 tries we just return "end - 1" which /// is guaranteed to be a copr...
nvidia/nemotron-3.5-lightning-30b-a3b
369a5ff09409be30-0
369a5ff09409be30
bee-san/RustScan
https://github.com/bee-san/RustScan
937903340aa6266abb26e93ea3241026b3fd8150
GPL-3.0-only
src/scanner/errors.rs
function
diagnostic_error
18
25
8
Write a `pub(super)` function named `diagnostic_error` that accepts an `io::Error`, an `std::net::IpAddr`, and a `bool` called `enabled`, and returns an `io::Error`. The function should preserve the normal I/O result layout: when `enabled` is true, wrap the given error and the target IP into a `ScanError` using `io::Er...
/// Preserve the normal I/O result layout; only diagnostics need target context. pub(super) fn diagnostic_error(error: io::Error, ip: IpAddr, enabled: bool) -> io::Error { if enabled { io::Error::other(ScanError { ip, error }) } else { error } }
nvidia/nemotron-3.5-lightning-30b-a3b
8a166277759ff54c-0
8a166277759ff54c
bee-san/RustScan
https://github.com/bee-san/RustScan
937903340aa6266abb26e93ea3241026b3fd8150
GPL-3.0-only
src/scanner/errors.rs
struct
ScanErrors
27
31
5
I need a Rust struct called `ScanErrors` that is module-private and tracks error state for a scanning process. It should have three fields: `enabled` (bool) to indicate if error collection is active, `limit` (usize) to set the maximum number of errors stored, and `messages` (HashSet<String>) to uniquely hold error desc...
pub(super) struct ScanErrors { enabled: bool, limit: usize, messages: HashSet<String>, }
nvidia/nemotron-3.5-lightning-30b-a3b
fe7158c8e0b8ec4d-0
fe7158c8e0b8ec4d
bee-san/RustScan
https://github.com/bee-san/RustScan
937903340aa6266abb26e93ea3241026b3fd8150
GPL-3.0-only
src/scanner/errors.rs
method
record
impl ScanErrors
42
46
5
I need a `record` method added to a type that implements `ScanErrors`. The method should accept an `std::io::Error` as its argument. It should only record the error into the type's internal message collection if a boolean `enabled` flag is true and the current number of stored messages is below a configured `limit`. Wh...
pub(super) fn record(&mut self, failure: io::Error) { if self.enabled && self.messages.len() < self.limit { self.messages.insert(failure.to_string()); } }
nvidia/nemotron-3.5-lightning-30b-a3b
93597fa7a3340a8e-0
93597fa7a3340a8e
bee-san/RustScan
https://github.com/bee-san/RustScan
937903340aa6266abb26e93ea3241026b3fd8150
GPL-3.0-only
src/scanner/errors.rs
function
is_descriptor_exhaustion
53
57
5
I need a Unix-specific helper function that checks whether an I/O error indicates descriptor exhaustion. The function should accept a reference to `std::io::Error`, examine its raw OS error code via `raw_os_error()`, and return `true` if the code matches `libc::EMFILE` or `libc::ENFILE`, indicating the process has hit ...
/// Detect descriptor exhaustion without allocating or interpreting OS messages. #[cfg(unix)] pub(super) fn is_descriptor_exhaustion(error: &io::Error) -> bool { matches!(error.raw_os_error(), Some(libc::EMFILE | libc::ENFILE)) }
nvidia/nemotron-3.5-lightning-30b-a3b
f811aab9a35e47d4-0
f811aab9a35e47d4
bee-san/RustScan
https://github.com/bee-san/RustScan
937903340aa6266abb26e93ea3241026b3fd8150
GPL-3.0-only
src/scanner/errors.rs
method
new
impl ScanErrors
34
40
7
I need to implement a `new` method for the `ScanErrors` type that constructs a new instance with an `enabled` boolean flag, a `limit` usize for rate limiting, and an empty `HashSet` for storing error messages. The method should accept `enabled: bool` and `limit: usize` as parameters and return the initialized `Self` ty...
pub(super) fn new(enabled: bool, limit: usize) -> Self { Self { enabled, limit, messages: HashSet::new(), } }
nvidia/nemotron-3.5-lightning-30b-a3b
cb56a89b44cc662a-0
cb56a89b44cc662a
bee-san/RustScan
https://github.com/bee-san/RustScan
937903340aa6266abb26e93ea3241026b3fd8150
GPL-3.0-only
src/scanner/errors.rs
method
messages
impl ScanErrors
48
50
3
I need to implement a `messages` method for `ScanErrors` that returns a reference to the internal set of error messages. The method should take `&self` and return `&HashSet<String>`, simply exposing the `messages` field.
pub(super) fn messages(&self) -> &HashSet<String> { &self.messages }
nvidia/nemotron-3.5-lightning-30b-a3b
718078bd63ad753b-0
718078bd63ad753b
bee-san/RustScan
https://github.com/bee-san/RustScan
937903340aa6266abb26e93ea3241026b3fd8150
GPL-3.0-only
src/scanner/errors.rs
function
is_descriptor_exhaustion
59
62
4
I need a Windows-specific function is_descriptor_exhaustion that checks whether a given &std::io::Error corresponds to the WSAEMFILE error code, which indicates the process has exhausted its file descriptors or socket handles. The function should examine error.raw_os_error() and return true if it equals Some(windows_sy...
#[cfg(windows)] pub(super) fn is_descriptor_exhaustion(error: &io::Error) -> bool { error.raw_os_error() == Some(windows_sys::Win32::Networking::WinSock::WSAEMFILE) }
nvidia/nemotron-3.5-lightning-30b-a3b
1f1cb175251ea34f-0
1f1cb175251ea34f
bee-san/RustScan
https://github.com/bee-san/RustScan
937903340aa6266abb26e93ea3241026b3fd8150
GPL-3.0-only
src/scanner/mod.rs
function
build_udp_payload_lookup
68
81
14
I need a function named `build_udp_payload_lookup` that takes a `&'static BTreeMap<Vec<u16>, Vec<u8>>` and returns a `UdpayloadLookup`. The function should iterate over each entry in the map, and for each u16 port in the key vector, insert the corresponding payload slice into the output map keyed by port. When the same...
#[doc(hidden)] pub fn build_udp_payload_lookup(udp_map: &'static BTreeMap<Vec<u16>, Vec<u8>>) -> UdpPayloadLookup { let mut lookup: UdpPayloadLookup = HashMap::new(); for (ports, payload_vec) in udp_map.iter() { let payload: &'static [u8] = payload_vec.as_slice(); for &port in ports.iter() { ...
nvidia/nemotron-3.5-lightning-30b-a3b
a8c127de069f0d68-0
a8c127de069f0d68
bee-san/RustScan
https://github.com/bee-san/RustScan
937903340aa6266abb26e93ea3241026b3fd8150
GPL-3.0-only
src/scanner/mod.rs
struct
Scanner
83
117
35
I'm developing a Rust port-scanning tool and need a struct called `Scanner` to manage scan configuration. It should include fields for a list of IP addresses (`Vec<IpAddr>`), a batch size (`usize`), a timeout duration (`std::time::Duration`), a retry count (`std::num::NonZeroU8`), a greppable output flag (`bool`), a po...
/// The class for the scanner /// IP is data type IpAddr and is the IP address /// start & end is where the port scan starts and ends /// batch_size is how many ports at a time should be scanned /// Timeout is the time RustScan should wait before declaring a port closed. As datatype Duration. /// greppable is whether o...
nvidia/nemotron-3.5-lightning-30b-a3b
0f2bb1cf41222e86-0
0f2bb1cf41222e86
bee-san/RustScan
https://github.com/bee-san/RustScan
937903340aa6266abb26e93ea3241026b3fd8150
GPL-3.0-only
src/scanner/mod.rs
method
with_open_port_output
impl Scanner
159
166
8
I need a fluent builder method on a `Scanner` type that enables incremental open-port output for the CLI. The method should take `mut self`, return `Self`, be annotated `#[must_use]`, and set a field `print_open_ports` to `true`. It should be documented as enabling the CLI's incremental open-port output, with the note ...
/// Enables the CLI's incremental open-port output. /// /// Library callers are quiet by default and can inspect the sockets returned by [`Self::run`]. #[must_use] pub fn with_open_port_output(mut self) -> Self { self.print_open_ports = true; self }
nvidia/nemotron-3.5-lightning-30b-a3b
1b57ec1b3fa3b241-0
1b57ec1b3fa3b241
bee-san/RustScan
https://github.com/bee-san/RustScan
937903340aa6266abb26e93ea3241026b3fd8150
GPL-3.0-only
src/scanner/mod.rs
enum
PortStatus
119
127
9
I need a Rust enum called `PortStatus` that represents the outcome of a port scan, returned by `Scanner::run_with_status`. It should have two variants: `Open(SocketAddr)` for open ports where the TCP connection succeeded or the UDP target answered, and `Closed(SocketAddr)` for actively refused connections, reported onl...
/// The outcome for a single socket, as returned by [`Scanner::run_with_status`]. #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum PortStatus { /// The TCP connection succeeded, or the UDP target answered. Open(SocketAddr), /// The target actively refused the TCP connection (for example with a /// ...
nvidia/nemotron-3.5-lightning-30b-a3b
974cb72606cd8bbb-0
974cb72606cd8bbb
bee-san/RustScan
https://github.com/bee-san/RustScan
937903340aa6266abb26e93ea3241026b3fd8150
GPL-3.0-only
src/scanner/mod.rs
method
new
impl Scanner
132
157
26
I need a `new` method implemented for a `Scanner` struct. The method should accept `ips: &[IpAddr]`, `batch_size: usize`, `timeout: Duration`, `tries: u8`, `greppable: bool`, `port_strategy: PortStrategy`, `accessible: bool`, `exclude_ports: Vec<u16>`, and `udp: bool`. It should return a `Scanner` instance where the `t...
pub fn new( ips: &[IpAddr], batch_size: usize, timeout: Duration, tries: u8, greppable: bool, port_strategy: PortStrategy, accessible: bool, exclude_ports: Vec<u16>, udp: bool, ) -> Self { Self { batch_size, timeout, tries: NonZeroU8::new(std::cmp::max(tri...
nvidia/nemotron-3.5-lightning-30b-a3b
3e1658ab321ca301-0
3e1658ab321ca301
bee-san/RustScan
https://github.com/bee-san/RustScan
937903340aa6266abb26e93ea3241026b3fd8150
GPL-3.0-only
src/scanner/mod.rs
function
filter_excluded_ports
40
59
20
Implement a free Rust function `filter_excluded_ports` that removes excluded port numbers from a given list. It accepts a mutable `Vec<u16>` of ports and a `&[u16]` slice of ports to exclude, returning `Vec<u16>`. The implementation must use an adaptive strategy: if the excluded slice is empty, return the ports unchang...
#[inline(never)] fn filter_excluded_ports(mut ports: Vec<u16>, excluded: &[u16]) -> Vec<u16> { if excluded.is_empty() { return ports; } // Bitmap setup costs more than membership checks on short port lists. if ports.len() < 64 { ports.retain(|port| !excluded.contains(port)); ret...
nvidia/nemotron-3.5-lightning-30b-a3b
daef0a2576e6d903-0
daef0a2576e6d903
bee-san/RustScan
https://github.com/bee-san/RustScan
937903340aa6266abb26e93ea3241026b3fd8150
GPL-3.0-only
src/scanner/mod.rs
method
run
impl Scanner
191
203
13
I need an asynchronous method named `run` implemented on a `Scanner` type. When executed, it should call an existing `run_with_status` method that returns port status results, then filter those results to collect only the open ports, returning their `SocketAddr` addresses as a `Vec<SocketAddr>`. The method should handl...
/// Runs scan_range with chunk sizes /// If you want to run RustScan normally, this is the entry point used /// Returns all open sockets. pub async fn run(&self) -> Vec<SocketAddr> { self.run_with_status() .await .into_iter() .filter_map(|status| match status { PortStatus::Open(s...
nvidia/nemotron-3.5-lightning-30b-a3b
81e500b613a1e76f-0
81e500b613a1e76f
bee-san/RustScan
https://github.com/bee-san/RustScan
937903340aa6266abb26e93ea3241026b3fd8150
GPL-3.0-only
src/scanner/mod.rs
method
scan_sockets
impl Scanner
262
319
58
Write an async method `scan_sockets` on the `Scanner` type that manages concurrent socket scanning with batching. It should accept a mutable `SocketIterator` yielding sockets to scan, an optional `&Arc<UdpPayloadLookup>` for UDP probe payloads, and mutable references to `Vec<PortStatus>` and `ScanErrors` for collecting...
/// Scans every socket yielded by `sockets`, keeping at most `batch_size` /// connection attempts in flight. /// /// Starts sockets and handles finished ones in rounds of at most /// [`WORK_PER_TURN`] of either, and lets the runtime poll for I/O and fire /// timers between rounds. One poll of the scan future otherwise ...
nvidia/nemotron-3.5-lightning-30b-a3b
eb9437b31d296d99-0
eb9437b31d296d99
bee-san/RustScan
https://github.com/bee-san/RustScan
937903340aa6266abb26e93ea3241026b3fd8150
GPL-3.0-only
src/scanner/mod.rs
method
with_closed_ports
impl Scanner
168
177
10
I'm working on a Rust scanning library and I have a `Scanner` struct that configures scan modes. I need a method called `with_closed_ports` that enables reporting of TCP ports that actively refuse connections as `PortStatus::Closed` from the scanner's `run_with_status` method. The method should set an internal `report_...
/// Also reports TCP ports that actively refuse the connection, as /// [`PortStatus::Closed`] from [`Self::run_with_status`]. /// /// Ports that time out are still treated as filtered and are not reported. /// UDP scans never report closed ports. #[must_use] pub fn with_closed_ports(mut self) -> Self { self.report_...
nvidia/nemotron-3.5-lightning-30b-a3b
3f94d8c2a1cbe0cf-0
3f94d8c2a1cbe0cf
bee-san/RustScan
https://github.com/bee-san/RustScan
937903340aa6266abb26e93ea3241026b3fd8150
GPL-3.0-only
src/scanner/mod.rs
method
record
impl Scanner
321
332
12
I'm implementing a method for the Scanner type in RustScan and need a function called `record` inside `impl Scanner` that processes a socket scan result. It should accept an `io::Result<PortStatus>`, a mutable reference to a `Vec<PortStatus>`, and a mutable reference to `ScanErrors`. The function matches on the result:...
/// Records the outcome of one socket. fn record( &self, result: io::Result<PortStatus>, found_sockets: &mut Vec<PortStatus>, errors: &mut ScanErrors, ) { match result { Ok(status) => found_sockets.push(status), Err(error) => errors.record(error), } }
nvidia/nemotron-3.5-lightning-30b-a3b
4f819821b23e92c2-0
4f819821b23e92c2
bee-san/RustScan
https://github.com/bee-san/RustScan
937903340aa6266abb26e93ea3241026b3fd8150
GPL-3.0-only
src/scanner/mod.rs
method
run_with_status
impl Scanner
205
216
12
I need an asynchronous method `run_with_status` implemented on the `Scanner` type that returns the status of every socket with a definitive answer—open sockets, plus closed sockets when `with_closed_ports` is enabled. The method should mirror `Self::run` but provide per-socket `PortStatus` information. Please provide t...
/// Like [`Self::run`], but returns the status of every socket that gave a /// definitive answer: open sockets, plus closed sockets when /// [`Self::with_closed_ports`] is enabled. pub async fn run_with_status(&self) -> Vec<PortStatus> { // Every in-flight socket is polled from this single future through a // `...
nvidia/nemotron-3.5-lightning-30b-a3b
0fdd0174c42e0794-0
0fdd0174c42e0794
bee-san/RustScan
https://github.com/bee-san/RustScan
937903340aa6266abb26e93ea3241026b3fd8150
GPL-3.0-only
src/scanner/mod.rs
method
scan
impl Scanner
218
260
43
I need an async `scan` method on a `Scanner` impl that scans a batch of target IP addresses across a port sequence, optionally filters out excluded ports, and builds a shared UDP payload lookup once if UDP mode is enabled, then returns a `Vec<PortStatus>`. The method should use a `SocketIterator` to manage connections ...
async fn scan(&self) -> Vec<PortStatus> { let ports = filter_excluded_ports(self.port_strategy.order(), &self.exclude_ports); let mut found_sockets: Vec<PortStatus> = Vec::new(); let mut errors = ScanErrors::new(log::log_enabled!(log::Level::Debug), self.ips.len() * 1000); // Build UDP payload ...
nvidia/nemotron-3.5-lightning-30b-a3b
a3abce41907681d1-0
a3abce41907681d1
bee-san/RustScan
https://github.com/bee-san/RustScan
937903340aa6266abb26e93ea3241026b3fd8150
GPL-3.0-only
src/scanner/mod.rs
method
scan_udp_socket
impl Scanner
393
415
23
I need an async method `scan_udp_socket` implemented for a `Scanner` type in Rust. The method should take `&self`, a `SocketAddr`, and an `Option<Arc<UdpPayloadLookup>>`. It must retrieve the UDP payload by looking up `socket.port()` in the payload map, defaulting to an empty byte slice if unavailable. The method shoul...
async fn scan_udp_socket( &self, socket: SocketAddr, udp_payloads: Option<Arc<UdpPayloadLookup>>, ) -> io::Result<PortStatus> { let payload: &[u8] = udp_payloads .as_ref() .and_then(|m| m.get(&socket.port()).copied()) .unwrap_or(b""); let tries = self.tries.get(); for _ ...
nvidia/nemotron-3.5-lightning-30b-a3b
d5a26806c52cdead-0
d5a26806c52cdead
bee-san/RustScan
https://github.com/bee-san/RustScan
937903340aa6266abb26e93ea3241026b3fd8150
GPL-3.0-only
src/scanner/mod.rs
method
udp_bind
impl Scanner
437
448
12
I need to implement a method `udp_bind` for the `Scanner` type that creates and returns a non-blocking UDP socket bound to the unspecified address corresponding to the address family of the given `SocketAddr`. The method should take a `SocketAddr` parameter and return `io::Result<std::net::UdpSocket>`, handling both IP...
/// Binds a non-blocking UDP socket on the unspecified address of the /// target's address family, so we can send and receive packets. fn udp_bind(socket: SocketAddr) -> io::Result<std::net::UdpSocket> { let local_addr = match socket { SocketAddr::V4(_) => SocketAddr::from((Ipv4Addr::UNSPECIFIED, 0)), ...
nvidia/nemotron-3.5-lightning-30b-a3b
3699f5576eeedbbc-0
3699f5576eeedbbc
bee-san/RustScan
https://github.com/bee-san/RustScan
937903340aa6266abb26e93ea3241026b3fd8150
GPL-3.0-only
src/scanner/mod.rs
method
fmt_closed_port
impl Scanner
538
547
10
I'm working on a Rust network scanner and need a method called `fmt_closed_port` implemented on a `Scanner` type. The method should accept a `SocketAddr` parameter and print a closed port indicator to the terminal, but only when `print_open_ports` is true and the mode is not greppable. If the scanner's `accessible` fie...
/// Prints a closed port (CLI output only, never in greppable mode). fn fmt_closed_port(&self, socket: SocketAddr) { if self.print_open_ports && !self.greppable { if self.accessible { println_safe(format_args!("Closed {socket}")); } else { println_safe(format_args!("Closed {}...
nvidia/nemotron-3.5-lightning-30b-a3b
0c1f6d268405afed-0
0c1f6d268405afed
bee-san/RustScan
https://github.com/bee-san/RustScan
937903340aa6266abb26e93ea3241026b3fd8150
GPL-3.0-only
src/scanner/mod.rs
method
fmt_ports
impl Scanner
527
536
10
I need a method called `fmt_ports` added to `impl Scanner` that formats and prints the status of an open port. It should accept a `SocketAddr` as input and check the instance fields `print_open_ports`, `greppable`, and `accessible`. If `print_open_ports` is true and `greppable` is false, the method prints the port info...
/// Formats and prints the port status fn fmt_ports(&self, socket: SocketAddr) { if self.print_open_ports && !self.greppable { if self.accessible { println_safe(format_args!("Open {socket}")); } else { println_safe(format_args!("Open {}", socket.to_string().purple())); ...
nvidia/nemotron-3.5-lightning-30b-a3b
16e99f7631268f50-0
16e99f7631268f50
bee-san/RustScan
https://github.com/bee-san/RustScan
937903340aa6266abb26e93ea3241026b3fd8150
GPL-3.0-only
src/scanner/mod.rs
method
udp_scan
impl Scanner
450
525
76
I need an async method `udp_scan` implemented for `impl Scanner` that performs a UDP scan on a given socket with a payload and wait duration. The method should bind a UDP socket via `Self::udp_bind`, connect it to the target socket, send the payload, and attempt an immediate receive. If the send or receive would block,...
/// Performs a UDP scan on the specified socket with a payload and wait duration /// # Example /// /// ```compile_fail /// # use std::net::{IpAddr, Ipv6Addr, SocketAddr}; /// # use std::time::Duration; /// let port: u16 = 123; /// // ip is an IpAddr type /// let ip = IpAddr::V6(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1)); /...
nvidia/nemotron-3.5-lightning-30b-a3b
c4aa7a3a526b8a24-0
c4aa7a3a526b8a24
bee-san/RustScan
https://github.com/bee-san/RustScan
937903340aa6266abb26e93ea3241026b3fd8150
GPL-3.0-only
src/scanner/mod.rs
method
connect
impl Scanner
417
435
19
I need an async connect method on my Scanner type that takes a SocketAddr and returns io::Result<TcpStream>, respecting a timeout field and calling timed_out() on timeout. Can you write that?
/// Performs the connection to the socket with timeout /// # Example /// /// ```compile_fail /// # use std::net::{IpAddr, Ipv6Addr, SocketAddr}; /// let port: u16 = 80; /// // ip is an IpAddr type /// let ip = IpAddr::V6(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1)); /// let socket = SocketAddr::new(ip, port); /// scanner.con...
nvidia/nemotron-3.5-lightning-30b-a3b
a52ab2e863101dc9-0
a52ab2e863101dc9
bee-san/RustScan
https://github.com/bee-san/RustScan
937903340aa6266abb26e93ea3241026b3fd8150
GPL-3.0-only
src/scanner/mod.rs
method
with_interval
impl Scanner
179
189
11
I need a method named `with_interval` added to the `Scanner` type that configures a delay between port scans for low-noise, rate-limited scanning. The method should take a `std::time::Duration` argument called `interval` and return `Self` for fluent chaining. When set to a non-zero duration, the scanner should pause fo...
/// Waits `interval` after scanning one port (on every address) before /// scanning the next port, for slow, low-noise scans. /// /// Within a port, up to `batch_size` addresses are still scanned /// concurrently. A zero interval (the default) scans all sockets in /// batches without any delay. #[must_use] pub fn with_...
nvidia/nemotron-3.5-lightning-30b-a3b
End of preview. Expand in Data Studio

Rust code instruction dataset

126 pairs of (question, real Rust code) built from 1 open-source GitHub repositories.

Each answer is original Rust source. Each question was written by nvidia/nemotron-3.5-lightning-30b-a3b from the code context; the model does not generate the answer.

Source repositories

repository commit license files chunks rows
bee-san/RustScan 937903340a GPL-3.0-only 14 127 126

Rows by kind

kind rows
function 51
method 48
struct 17
enum 5
macro 4
trait 1

Example

Question

I need a function called old_payload_for_port that retrieves a static byte slice payload associated with a given port from a predefined mapping. The mapping is a static BTreeMap where each key is a Vec<u16> representing valid ports, and each value is a Vec<u8> payload. The function should accept a &'static BTreeMap<Vec<u16>, Vec<u8>> and a u16 port, and return a &'static [u8]. It should iterate through the map entries and return the payload of the first entry whose port list contains the given port. If no entry matches, it should return an empty static byte slice.

Answer (bee-san/RustScan - benches/benchmark_helpers.rs)

fn old_payload_for_port(udp_map: &'static BTreeMap<Vec<u16>, Vec<u8>>, port: u16) -> &'static [u8] {
    let mut payload: &'static [u8] = b"";
    for (ports, value) in udp_map.iter() {
        if ports.contains(&port) {
            payload = value.as_slice();
        }
    }
    payload
}

Usage

from datasets import load_dataset

dataset = load_dataset("Shadow0482/rust", split="train")
print(dataset[0]["question"])
print(dataset[0]["answer"])

License and attribution

Code in answer remains under the license of the source repository shown in the license and repo_url columns. Follow that license when redistributing or training on the data. The questions are synthetic; follow the terms of the model provider used to create them.

Downloads last month
14