Skip to content

Commit

Permalink
chore: merge release-v0.1.0 into main
Browse files Browse the repository at this point in the history
  • Loading branch information
mrjackwills committed May 18, 2023
2 parents 199d1f4 + c88f176 commit bb991a6
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 37 deletions.
6 changes: 6 additions & 0 deletions .github/release-body.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
### 2023-05-18

### Features
+ init commit

see <a href='https://github.com/mrjackwills/havn/blob/main/CHANGELOG.md'>CHANGELOG.md</a> for more details
Binary file modified .github/screen.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .github/screen.mp4
Binary file not shown.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
# <a href='https://github.com/mrjackwills/havn/releases/tag/v0.1.0'>v0.1.0</a>
### 2023-05-18

### Features
+ init commit
+ init commit
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
name = "havn"
version = "0.1.0"
edition = "2021"
description = "A fast configurable port scanner with sensible defaults"
authors = ["Jack Wills <[email protected]>"]
description = "A fast configurable port scanner with reasonable defaults"
repository = "https://github.com/mrjackwills/havn"
homepage = "https://github.com/mrjackwills/havn"
license = "MIT"
Expand Down
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023- Jack Wills

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ It is designed and built to be compatible with multiple platforms, including Doc
- [ ] monitor response times to automatically modify request settings
- [ ] configurable option to disable second-pass scan
- [ ] debug option to display more verbose output
- [ ] improve windows performance
- [ ] publish to npm

## Download & install
Expand Down
55 changes: 20 additions & 35 deletions src/terminal/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,32 +40,16 @@ pub mod print {
}

/// Generate information about the host/address/IP that will be scanned, to be shown on two lines along with the application name
fn get_host_ip(cli_args: &CliArgs, ip: &IpAddr) -> (String, String) {
fn get_host_ip(cli_args: &CliArgs, ip: &IpAddr) -> (String, String, String) {
let ports = if cli_args.ports.min == cli_args.ports.max {
format!("{}", cli_args.ports.min)
} else {
format!("{}-{}", cli_args.ports.min, cli_args.ports.max)
};
if cli_args.address == ip.to_string() {
(
format!(
"{t}:{y}{ports}{r}",
y = Color::Yellow,
r = Color::Reset,
t = cli_args.address,
),
String::new(),
)
(format!("{}:", cli_args.address), ports, String::new())
} else {
(
format!(
"{t}:{y}{ports}{r}",
y = Color::Yellow,
r = Color::Reset,
t = ip,
),
cli_args.address.to_string(),
)
(format!("{ip}:"), ports, cli_args.address.to_string())
}
}

Expand Down Expand Up @@ -122,13 +106,18 @@ pub mod print {

/// Print the name of the application, using a small figlet font
pub fn name_and_target(cli_args: &CliArgs, ip: &IpAddr) {
let (ip, address) = get_host_ip(cli_args, ip);
let bar = (0..=address.chars().count().max(ip.chars().count()) + 19)
let (ip, ports, address) = get_host_ip(cli_args, ip);
let bar = (0..=address
.chars()
.count()
.max(ip.chars().count() + ports.chars().count())
+ 19)
.map(|_| '═')
.collect::<String>();
println!(
"{m}{bar}\n|__| /\\ \\ / |\\ |{r} {ip}\n{m}| | /--\\ \\/ | \\|{r} {address}\n{m}{bar}{r}",
"{m}{bar}\n|__| /\\ \\ / |\\ |{r} {ip}{y}{ports}{r}\n{m}| | /--\\ \\/ | \\|{r} {address}\n{m}{bar}{r}",
m = Color::Magenta,
y = Color::Yellow,
r = Color::Reset,
);
}
Expand Down Expand Up @@ -211,27 +200,21 @@ pub mod print {
let ip = IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1));
assert_eq!(
get_host_ip(&cli_args, &ip),
("127.0.0.1:\u{1b}[33m1\u{1b}[0m".to_owned(), String::new())
("127.0.0.1:".into(), "1".into(), String::new())
);

let cli_args = parse_arg::CliArgs::test_new("1-10000".to_owned(), 512, None);
let ip = IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1));
assert_eq!(
get_host_ip(&cli_args, &ip),
(
"127.0.0.1:\u{1b}[33m1-10000\u{1b}[0m".to_owned(),
String::new()
)
("127.0.0.1:".into(), "1-10000".into(), String::new())
);

let cli_args = parse_arg::CliArgs::test_new("1-65535".to_owned(), 512, None);
let ip = IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1));
assert_eq!(
get_host_ip(&cli_args, &ip),
(
"127.0.0.1:\u{1b}[33m1-65535\u{1b}[0m".to_owned(),
String::new()
)
("127.0.0.1:".into(), "1-65535".into(), String::new())
);

let cli_args =
Expand All @@ -240,7 +223,8 @@ pub mod print {
assert_eq!(
get_host_ip(&cli_args, &ip),
(
"127.0.0.1:\u{1b}[33m1\u{1b}[0m".to_owned(),
"127.0.0.1:".into(),
"1".into(),
String::from("www.google.com")
)
);
Expand All @@ -251,7 +235,8 @@ pub mod print {
assert_eq!(
get_host_ip(&cli_args, &ip),
(
"127.0.0.1:\u{1b}[33m1-10000\u{1b}[0m".to_owned(),
"127.0.0.1:".into(),
"1-10000".into(),
String::from("www.google.com")
)
);
Expand All @@ -262,12 +247,12 @@ pub mod print {
assert_eq!(
get_host_ip(&cli_args, &ip),
(
"127.0.0.1:\u{1b}[33m1-65535\u{1b}[0m".to_owned(),
"127.0.0.1:".into(),
"1-65535".into(),
String::from("www.google.com")
)
);
}

#[test]
/// Generate extra ip function will either return None, or a String in format "Other IPs: xx"
fn test_terminal_table() {
Expand Down

0 comments on commit bb991a6

Please sign in to comment.