Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide details about unassigned IPs (bogons) #678

Merged
merged 8 commits into from
Jan 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

All Sniffnet releases with the relative changes are documented in this file.

## [UNRELEASED]
- Identify and tag unassigned/reserved "bogon" IP addresses ([#678](https://github.com/GyulyVGC/sniffnet/pull/678) — fixes [#209](https://github.com/GyulyVGC/sniffnet/issues/209))

## [1.3.2] - 2025-01-06
- Dropdown menus for network host filters ([#659](https://github.com/GyulyVGC/sniffnet/pull/659) — fixes [#354](https://github.com/GyulyVGC/sniffnet/issues/354))
- Added CLI argument `--adapter [<NAME>]` to allow immediately starting the capture from a given network interface ([#643](https://github.com/GyulyVGC/sniffnet/pull/643) — fixes [#636](https://github.com/GyulyVGC/sniffnet/issues/636))
Expand Down
28 changes: 28 additions & 0 deletions resources/countries_flags/4x3/zz-bogon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
71 changes: 41 additions & 30 deletions src/countries/country_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ use iced::Font;

use crate::countries::flags_pictures::{
AD, AE, AF, AG, AI, AL, AM, AO, AQ, AR, AS, AT, AU, AW, AX, AZ, BA, BB, BD, BE, BF, BG, BH, BI,
BJ, BM, BN, BO, BR, BROADCAST, BS, BT, BV, BW, BY, BZ, CA, CC, CD, CF, CG, CH, CI, CK, CL, CM,
CN, CO, COMPUTER, CR, CU, CV, CW, CX, CY, CZ, DE, DJ, DK, DM, DO, DZ, EC, EE, EG, EH, ER, ES,
ET, FI, FJ, FK, FLAGS_WIDTH_BIG, FLAGS_WIDTH_SMALL, FM, FO, FR, GA, GB, GD, GE, GG, GH, GI, GL,
GM, GN, GQ, GR, GS, GT, GU, GW, GY, HK, HN, HOME, HR, HT, HU, ID, IE, IL, IM, IN, IO, IQ, IR,
IS, IT, JE, JM, JO, JP, KE, KG, KH, KI, KM, KN, KP, KR, KW, KY, KZ, LA, LB, LC, LI, LK, LR, LS,
LT, LU, LV, LY, MA, MC, MD, ME, MG, MH, MK, ML, MM, MN, MO, MP, MR, MS, MT, MU, MULTICAST, MV,
MW, MX, MY, MZ, NA, NC, NE, NF, NG, NI, NL, NO, NP, NR, NU, NZ, OM, PA, PE, PF, PG, PH, PK, PL,
PN, PR, PS, PT, PW, PY, QA, RO, RS, RU, RW, SA, SB, SC, SD, SE, SG, SH, SI, SK, SL, SM, SN, SO,
SR, SS, ST, SV, SX, SY, SZ, TC, TD, TF, TG, TH, TJ, TK, TL, TM, TN, TO, TR, TT, TV, TW, TZ, UA,
UG, UNKNOWN, US, UY, UZ, VA, VC, VE, VG, VI, VN, VU, WS, YE, ZA, ZM, ZW,
BJ, BM, BN, BO, BOGON, BR, BROADCAST, BS, BT, BV, BW, BY, BZ, CA, CC, CD, CF, CG, CH, CI, CK,
CL, CM, CN, CO, COMPUTER, CR, CU, CV, CW, CX, CY, CZ, DE, DJ, DK, DM, DO, DZ, EC, EE, EG, EH,
ER, ES, ET, FI, FJ, FK, FLAGS_WIDTH_BIG, FLAGS_WIDTH_SMALL, FM, FO, FR, GA, GB, GD, GE, GG, GH,
GI, GL, GM, GN, GQ, GR, GS, GT, GU, GW, GY, HK, HN, HOME, HR, HT, HU, ID, IE, IL, IM, IN, IO,
IQ, IR, IS, IT, JE, JM, JO, JP, KE, KG, KH, KI, KM, KN, KP, KR, KW, KY, KZ, LA, LB, LC, LI, LK,
LR, LS, LT, LU, LV, LY, MA, MC, MD, ME, MG, MH, MK, ML, MM, MN, MO, MP, MR, MS, MT, MU,
MULTICAST, MV, MW, MX, MY, MZ, NA, NC, NE, NF, NG, NI, NL, NO, NP, NR, NU, NZ, OM, PA, PE, PF,
PG, PH, PK, PL, PN, PR, PS, PT, PW, PY, QA, RO, RS, RU, RW, SA, SB, SC, SD, SE, SG, SH, SI, SK,
SL, SM, SN, SO, SR, SS, ST, SV, SX, SY, SZ, TC, TD, TF, TG, TH, TJ, TK, TL, TM, TN, TO, TR, TT,
TV, TW, TZ, UA, UG, UNKNOWN, US, UY, UZ, VA, VC, VE, VG, VI, VN, VU, WS, YE, ZA, ZM, ZW,
};
use crate::countries::types::country::Country;
use crate::gui::styles::container::ContainerType;
Expand All @@ -26,13 +26,15 @@ use crate::networking::types::traffic_type::TrafficType;
use crate::translations::translations_2::{
local_translation, unknown_translation, your_network_adapter_translation,
};
use crate::translations::translations_4::reserved_address_translation;
use crate::{Language, StyleType};

fn get_flag_from_country<'a>(
country: Country,
width: f32,
is_local: bool,
is_loopback: bool,
is_bogon: Option<&str>,
traffic_type: TrafficType,
language: Language,
) -> (Svg<'a, StyleType>, String) {
Expand Down Expand Up @@ -287,19 +289,24 @@ fn get_flag_from_country<'a>(
Country::ZW => ZW,
Country::ZZ => {
let (flag, new_tooltip) = if is_loopback {
(COMPUTER, your_network_adapter_translation(language))
(
COMPUTER,
your_network_adapter_translation(language).to_string(),
)
} else if traffic_type.eq(&TrafficType::Multicast) {
(MULTICAST, "Multicast")
(MULTICAST, "Multicast".to_string())
} else if traffic_type.eq(&TrafficType::Broadcast) {
(BROADCAST, "Broadcast")
(BROADCAST, "Broadcast".to_string())
} else if is_local {
(HOME, local_translation(language))
(HOME, local_translation(language).to_string())
} else if let Some(bogon) = is_bogon {
(BOGON, reserved_address_translation(language, bogon))
} else {
(UNKNOWN, unknown_translation(language))
(UNKNOWN, unknown_translation(language).to_string())
};

svg_style = SvgType::AdaptColor;
tooltip = new_tooltip.to_string();
tooltip = new_tooltip;
flag
}
})))
Expand All @@ -324,12 +331,14 @@ pub fn get_flag_tooltip<'a>(
};
let is_local = host_info.is_local;
let is_loopback = host_info.is_loopback;
let is_bogon = host_info.is_bogon;
let traffic_type = host_info.traffic_type;
let (content, tooltip) = get_flag_from_country(
country,
width,
is_local,
is_loopback,
is_bogon,
traffic_type,
language,
);
Expand Down Expand Up @@ -358,31 +367,33 @@ pub fn get_flag_tooltip<'a>(
pub fn get_computer_tooltip<'a>(
is_my_address: bool,
is_local: bool,
is_bogon: Option<&str>,
traffic_type: TrafficType,
language: Language,
font: Font,
) -> Tooltip<'a, Message, StyleType> {
let content = Svg::new(Handle::from_memory(Vec::from(
match (is_my_address, is_local, traffic_type) {
(true, _, _) => COMPUTER,
(false, _, TrafficType::Multicast) => MULTICAST,
(false, _, TrafficType::Broadcast) => BROADCAST,
(false, true, _) => HOME,
(false, false, TrafficType::Unicast) => UNKNOWN,
match (is_my_address, is_local, is_bogon, traffic_type) {
(true, _, _, _) => COMPUTER,
(false, _, _, TrafficType::Multicast) => MULTICAST,
(false, _, _, TrafficType::Broadcast) => BROADCAST,
(false, true, _, _) => HOME,
(false, false, Some(_), _) => BOGON,
(false, false, None, TrafficType::Unicast) => UNKNOWN,
},
)))
.class(SvgType::AdaptColor)
.width(FLAGS_WIDTH_BIG)
.height(FLAGS_WIDTH_BIG * 0.75);

let tooltip = match (is_my_address, is_local, traffic_type) {
(true, _, _) => your_network_adapter_translation(language),
(false, _, TrafficType::Multicast) => "Multicast",
(false, _, TrafficType::Broadcast) => "Broadcast",
(false, true, _) => local_translation(language),
(false, false, TrafficType::Unicast) => unknown_translation(language),
}
.to_string();
let tooltip = match (is_my_address, is_local, is_bogon, traffic_type) {
(true, _, _, _) => your_network_adapter_translation(language).to_string(),
(false, _, _, TrafficType::Multicast) => "Multicast".to_string(),
(false, _, _, TrafficType::Broadcast) => "Broadcast".to_string(),
(false, true, _, _) => local_translation(language).to_string(),
(false, false, Some(t), _) => reserved_address_translation(language, t),
(false, false, None, TrafficType::Unicast) => unknown_translation(language).to_string(),
};

Tooltip::new(
content,
Expand Down
1 change: 1 addition & 0 deletions src/countries/flags_pictures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,3 +255,4 @@ pub const MULTICAST: &[u8] = include_bytes!("../../resources/countries_flags/4x3
pub const BROADCAST: &[u8] = include_bytes!("../../resources/countries_flags/4x3/zz-broadcast.svg");
pub const UNKNOWN: &[u8] = include_bytes!("../../resources/countries_flags/4x3/zz-unknown.svg");
pub const COMPUTER: &[u8] = include_bytes!("../../resources/countries_flags/4x3/zz-computer.svg");
pub const BOGON: &[u8] = include_bytes!("../../resources/countries_flags/4x3/zz-bogon.svg");
2 changes: 2 additions & 0 deletions src/gui/pages/connection_details_page.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use crate::networking::manage_packets::{
get_address_to_lookup, get_traffic_type, is_local_connection, is_my_address,
};
use crate::networking::types::address_port_pair::AddressPortPair;
use crate::networking::types::bogon::is_bogon;
use crate::networking::types::host::Host;
use crate::networking::types::icmp_type::IcmpType;
use crate::networking::types::info_address_port_pair::InfoAddressPortPair;
Expand Down Expand Up @@ -304,6 +305,7 @@ fn get_local_tooltip<'a>(
get_computer_tooltip(
is_my_address(local_address, my_interface_addresses),
is_local_connection(local_address, my_interface_addresses),
is_bogon(local_address),
get_traffic_type(
if address_to_lookup.eq(&key.address1) {
&key.address2
Expand Down
3 changes: 3 additions & 0 deletions src/networking/manage_packets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use crate::mmdb::asn::get_asn;
use crate::mmdb::country::get_country;
use crate::mmdb::types::mmdb_reader::MmdbReaders;
use crate::networking::types::address_port_pair::AddressPortPair;
use crate::networking::types::bogon::is_bogon;
use crate::networking::types::data_info_host::DataInfoHost;
use crate::networking::types::host::Host;
use crate::networking::types::host_data_states::HostData;
Expand Down Expand Up @@ -320,6 +321,7 @@ pub fn reverse_dns_lookup(
);
let is_loopback = is_loopback(&address_to_lookup);
let is_local = is_local_connection(&address_to_lookup, &my_interface_addresses);
let is_bogon = is_bogon(&address_to_lookup);
let country = get_country(&address_to_lookup, &mmdb_readers.country);
let asn = get_asn(&address_to_lookup, &mmdb_readers.asn);
let r_dns = if let Ok(result) = lookup_result {
Expand Down Expand Up @@ -358,6 +360,7 @@ pub fn reverse_dns_lookup(
is_favorite: false,
is_loopback,
is_local,
is_bogon,
traffic_type,
});

Expand Down
Loading
Loading