diff --git a/src/countries/country_utils.rs b/src/countries/country_utils.rs index 39ac6ee8..6b14d7f7 100644 --- a/src/countries/country_utils.rs +++ b/src/countries/country_utils.rs @@ -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; @@ -26,6 +26,7 @@ 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>( @@ -358,31 +359,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, diff --git a/src/gui/pages/connection_details_page.rs b/src/gui/pages/connection_details_page.rs index d293bb5b..840011dd 100644 --- a/src/gui/pages/connection_details_page.rs +++ b/src/gui/pages/connection_details_page.rs @@ -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; @@ -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 diff --git a/src/translations/mod.rs b/src/translations/mod.rs index 342693ce..b55b4908 100644 --- a/src/translations/mod.rs +++ b/src/translations/mod.rs @@ -2,4 +2,5 @@ pub mod translations; pub mod translations_2; pub mod translations_3; +pub mod translations_4; pub mod types; diff --git a/src/translations/translations_4.rs b/src/translations/translations_4.rs new file mode 100644 index 00000000..8a1e7ac4 --- /dev/null +++ b/src/translations/translations_4.rs @@ -0,0 +1,11 @@ +#![allow(clippy::match_same_arms)] + +use crate::translations::types::language::Language; + +pub fn reserved_address_translation(language: Language, info: &str) -> String { + match language { + Language::EN => format!("Reserved address ({info})"), + Language::IT => format!("Indirizzo riservato ({info})"), + _ => format!("Reserved address ({info})"), + } +}