|
1 |
| -use scanner::{host_info, AllPortStatus}; |
2 |
| -use terminal::{print, spinner::Spinner}; |
3 |
| - |
4 |
| -mod parse_arg; |
5 |
| -mod port_descriptions; |
6 |
| -mod scanner; |
7 |
| -mod terminal; |
8 |
| - |
9 |
| -fn exit(code: i32) { |
10 |
| - Spinner::show_cursor(); |
11 |
| - std::process::exit(code); |
12 |
| -} |
13 |
| - |
14 |
| -fn tokio_signal() { |
15 |
| - tokio::spawn(async move { |
16 |
| - tokio::signal::ctrl_c().await.ok(); |
17 |
| - exit(1); |
18 |
| - }); |
19 |
| -} |
20 |
| - |
21 |
| -#[tokio::main] |
22 |
| -async fn main() { |
23 |
| - let cli_args = parse_arg::CliArgs::new(); |
24 |
| - terminal::text_color(&cli_args); |
25 |
| - let exit_error = || print::address_error(&cli_args); |
26 |
| - |
27 |
| - tokio_signal(); |
28 |
| - |
29 |
| - let Ok(host_info) = host_info::HostInfo::try_from(&cli_args.address).await else { |
30 |
| - return exit_error(); |
31 |
| - }; |
32 |
| - let Some(ip) = host_info.get_ip(&cli_args) else { |
33 |
| - return exit_error(); |
34 |
| - }; |
35 |
| - |
36 |
| - print::name_and_target(&cli_args, ip); |
37 |
| - print::extra_ips(&host_info, ip); |
38 |
| - |
39 |
| - let spinner = Spinner::new(); |
40 |
| - spinner.start(); |
41 |
| - let now = std::time::Instant::now(); |
42 |
| - let scan_output = AllPortStatus::scan_ports(&cli_args, ip).await; |
43 |
| - spinner.stop(); |
44 |
| - let done = now.elapsed(); |
45 |
| - |
46 |
| - print::scan_time(&scan_output, done); |
47 |
| - print::result_table(&scan_output); |
48 |
| -} |
| 1 | +use scanner::{host_info, AllPortStatus}; |
| 2 | +use terminal::{print, spinner::Spinner}; |
| 3 | + |
| 4 | +mod parse_arg; |
| 5 | +mod port_descriptions; |
| 6 | +mod scanner; |
| 7 | +mod terminal; |
| 8 | + |
| 9 | +fn exit(code: i32) { |
| 10 | + Spinner::show_cursor(); |
| 11 | + std::process::exit(code); |
| 12 | +} |
| 13 | + |
| 14 | +fn tokio_signal() { |
| 15 | + tokio::spawn(async move { |
| 16 | + tokio::signal::ctrl_c().await.ok(); |
| 17 | + exit(1); |
| 18 | + }); |
| 19 | +} |
| 20 | + |
| 21 | +#[tokio::main] |
| 22 | +async fn main() { |
| 23 | + let cli_args = parse_arg::CliArgs::new(); |
| 24 | + terminal::text_color(&cli_args); |
| 25 | + let exit_error = || print::address_error(&cli_args); |
| 26 | + |
| 27 | + tokio_signal(); |
| 28 | + |
| 29 | + let Ok(host_info) = host_info::HostInfo::try_from(&cli_args.address).await else { |
| 30 | + return exit_error(); |
| 31 | + }; |
| 32 | + let Some(ip) = host_info.get_ip(&cli_args) else { |
| 33 | + return exit_error(); |
| 34 | + }; |
| 35 | + |
| 36 | + print::name_and_target(&cli_args, ip); |
| 37 | + print::extra_ips(&host_info, ip); |
| 38 | + |
| 39 | + let spinner = Spinner::new(); |
| 40 | + spinner.start(); |
| 41 | + let now = std::time::Instant::now(); |
| 42 | + let scan_output = AllPortStatus::scan_ports(&cli_args, ip).await; |
| 43 | + spinner.stop(); |
| 44 | + let done = now.elapsed(); |
| 45 | + |
| 46 | + print::scan_time(&scan_output, done); |
| 47 | + print::result_table(&scan_output); |
| 48 | +} |
0 commit comments