Skip to content
Merged
Show file tree
Hide file tree
Changes from 70 commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
e203503
Implement deserializing hex colors to iced::Color.
joshuamegnauth54 Jun 8, 2023
3e348cb
Merge branch 'main' of github.com:joshuamegnauth54/sniffnet into add_…
joshuamegnauth54 Jun 11, 2023
267f852
Merge branch 'main' of github.com:joshuamegnauth54/sniffnet into add_…
joshuamegnauth54 Jun 12, 2023
b7ced9b
Implement `CustomStyle` and test marshalling.
joshuamegnauth54 Jun 15, 2023
e7fa2f8
Clean up ser/de implementations for `Color`.
joshuamegnauth54 Jun 16, 2023
263205a
Support multilingual custom theme descriptions.
joshuamegnauth54 Jun 18, 2023
64efb61
Implement Hash for custom style types.
joshuamegnauth54 Jun 19, 2023
9540971
Replace `StyleType` with `Arc<StyleType>`.
joshuamegnauth54 Jun 22, 2023
3daee4d
Add a `TextInput` to load custom themes.
joshuamegnauth54 Jun 26, 2023
9399976
Update README.md with custom style info.
joshuamegnauth54 Jun 26, 2023
40274f7
Merge branch 'main' of github.com:joshuamegnauth54/sniffnet into add_…
joshuamegnauth54 Jun 26, 2023
1ec0c6e
Clean up: use iced::color!
joshuamegnauth54 Jun 27, 2023
5ad2626
Clean up: Simplify PartialEq impl for Color.
joshuamegnauth54 Jun 27, 2023
d35c578
Clean up: Derive PartialEq instead of implementing
joshuamegnauth54 Jun 28, 2023
cc1db3e
Fix serializing `StyleType::Custom`.
joshuamegnauth54 Jun 30, 2023
94fea30
Handle `CustomStyle` translations better.
joshuamegnauth54 Jul 3, 2023
7f5550b
Merge branch 'main' into add_themes
joshuamegnauth54 Jul 5, 2023
56c7f70
Impl `get_custom_styles` to load styles from a dir
joshuamegnauth54 Jul 9, 2023
ec863ea
Make the settings style page scrollable.
joshuamegnauth54 Jul 10, 2023
04b790a
Add and update Catppuccin styles.
joshuamegnauth54 Jul 11, 2023
773de55
Add unit test for `load_custom_styles`
joshuamegnauth54 Jul 11, 2023
0a66c57
Merge branch 'main' of github.com:joshuamegnauth54/sniffnet into add_…
joshuamegnauth54 Jul 11, 2023
e3d0d11
Make themes look a bit nicer.
joshuamegnauth54 Jul 27, 2023
e426574
Merge remote-tracking branch 'upstream/main' into add_themes
joshuamegnauth54 Jul 28, 2023
47020e6
feat: started advanced settings
GyulyVGC Aug 22, 2023
5af05ac
feat: created ConfigAdvancedSettings
GyulyVGC Aug 22, 2023
e43bdcf
feat: restore default advanced settings
GyulyVGC Aug 23, 2023
4926b06
fix: decrease minimum allowed window size
GyulyVGC Aug 23, 2023
4f47bcc
Merge branch 'main' into advanced-settings
GyulyVGC Aug 25, 2023
8e0dea2
feat: added config to persist window size and position
GyulyVGC Aug 25, 2023
479c87c
refactor: configurations load
GyulyVGC Aug 25, 2023
dd2eb94
feat: custom country MMDB
GyulyVGC Aug 26, 2023
3069f90
store configurations only when application exits
GyulyVGC Sep 2, 2023
3161921
feat: custom ASN MMDB
GyulyVGC Sep 3, 2023
1ef136b
Merge branch 'main' into advanced-settings
GyulyVGC Sep 3, 2023
9709f68
feat: custom report path
GyulyVGC Sep 4, 2023
78e2c54
replaced MMDB readers tuple with MmdbReader enum
GyulyVGC Sep 9, 2023
3b36289
MMDB readers are now part of Sniffer struct
GyulyVGC Sep 10, 2023
fedcda5
Merge 'upstream/advanced-settings' into add_themes
joshuamegnauth54 Sep 25, 2023
eb4c1ce
Clean up old custom style implementation.
joshuamegnauth54 Sep 26, 2023
e9e097f
Add `CustomToml` to `ExtraStyles`.
joshuamegnauth54 Sep 28, 2023
475856b
Add an element for loading custom styles
joshuamegnauth54 Sep 29, 2023
86e4efa
Implement Message::LoadStyle.
joshuamegnauth54 Sep 30, 2023
f32aa7c
Improve custom theme loading in GUI
joshuamegnauth54 Oct 1, 2023
6f320a8
Update readme to use the latest theme spec
joshuamegnauth54 Oct 1, 2023
30e1a01
Clean up tests and code.
joshuamegnauth54 Oct 2, 2023
09a9942
fix README
GyulyVGC Nov 10, 2023
46885a7
fix warnings and clippy lints
GyulyVGC Nov 10, 2023
8f62204
fix wrong nightly parameter for light themes
GyulyVGC Nov 10, 2023
ebb0252
undo derive Ord and PartialOrd for Language
GyulyVGC Nov 10, 2023
93ead04
fix: consistency in loading/storing styles
GyulyVGC Nov 12, 2023
06ae195
Merge pull request #286 from joshuamegnauth54/add_themes
GyulyVGC Nov 13, 2023
10323eb
fix: ASN MMDB fault
GyulyVGC Nov 14, 2023
23ba5ca
merged main
GyulyVGC Nov 29, 2023
05f60e0
fix and update deps
GyulyVGC Nov 29, 2023
80b30a5
remove reporoster stargazer pic from README
GyulyVGC Nov 29, 2023
3673f53
fixed text_input style
GyulyVGC Nov 29, 2023
0fd3a28
refactored MMDB related items
GyulyVGC Nov 30, 2023
9ec48f8
made custom style text input lazy
GyulyVGC Dec 1, 2023
3179aa0
removed status_pair
GyulyVGC Dec 1, 2023
ab4090e
changed capture id handling
GyulyVGC Dec 1, 2023
eef16f2
removed mutex map from Sniffer::new and updated tests
GyulyVGC Dec 1, 2023
f26e7d7
use HashMap over IndexMap and remove addresses_last_interval
GyulyVGC Dec 2, 2023
0441c28
use Display instead of print_gui for inspect table entries
GyulyVGC Dec 2, 2023
0bf99f7
removed file write_report_file.rs
GyulyVGC Dec 2, 2023
7786097
handle custom report path (WIP)
GyulyVGC Dec 6, 2023
696ae44
minor fixes
GyulyVGC Dec 8, 2023
ab79201
minor fixes
GyulyVGC Dec 8, 2023
c334c9c
moved custom style path selection to settings style tab
GyulyVGC Dec 9, 2023
bcaa594
improved scale factor appearance in settings
GyulyVGC Dec 9, 2023
7c9e90e
updated CHANGELOG
GyulyVGC Dec 9, 2023
59a3eb7
added visual palette of custom TOML theme in settings
GyulyVGC Dec 9, 2023
7459cb1
improved Catppuccin theme in the provided sample TOML file
GyulyVGC Dec 9, 2023
c0b8c77
updated method is_newer_release_available to always retry multiple times
GyulyVGC Dec 9, 2023
4a80c88
language is now part of general settings
GyulyVGC Dec 10, 2023
9045132
fixed tests
GyulyVGC Dec 10, 2023
45e6732
ConfigAdvancedSettings has been removed and included into ConfigSettings
GyulyVGC Dec 10, 2023
9554eca
fixed tests
GyulyVGC Dec 10, 2023
0c652b0
minor fixes
GyulyVGC Dec 10, 2023
a9216c2
updated CHANGELOG
GyulyVGC Dec 10, 2023
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
626 changes: 393 additions & 233 deletions Cargo.lock

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ strip = true
pcap = "1.1.0"
etherparse = "0.13.0"
chrono = { version = "0.4.31", default_features = false, features = ["clock"] }
indexmap = "2.1.0"
plotters = { version = "0.3.5", default_features = false, features = ["area_series"] }
iced = { version = "0.10.0", features = ["tokio", "svg", "advanced", "lazy"] }
plotters-iced = "0.9.0"
Expand All @@ -45,6 +44,7 @@ confy = "0.5.1"
serde = { version = "1.0.193", default_features = false, features = ["derive"] }
rodio = { version = "0.17.3", default_features = false, features = ["mp3"] }
dns-lookup = "2.0.4"
toml = "0.8.8"

[target.'cfg(not(target_arch = "powerpc64"))'.dependencies]
reqwest = { version = "0.11.22", default-features = false, features = ["json", "blocking", "rustls-tls"] }
Expand All @@ -55,6 +55,7 @@ reqwest = { version = "0.11.22", features = ["json", "blocking"] }
#───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

[dev-dependencies]
serde_test = "1.0.176"
rstest = "0.18.2"

#───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Expand Down
64 changes: 47 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<p align="center"><a href="https://www.sniffnet.net"><img alt="" src="https://github.com/GyulyVGC/sniffnet/blob/main/resources/repository/header_repository.png?raw=true" width="100%"/></a></p>

<p align="center">
<p align="center">
<a href="https://github.com/GyulyVGC/sniffnet/blob/main/LICENSE-APACHE"><img alt="" src="https://img.shields.io/crates/l/sniffnet?&color=orange"/></a>
&nbsp;
<a href="https://crates.io/crates/sniffnet"><img alt="" src="https://img.shields.io/crates/v/sniffnet?&logo=rust&color=blue"/></a> <br>
</p>

<p align="center">
<p align="center">
Application to comfortably monitor your Internet traffic <br>
Multithreaded, cross-platform, reliable <br>
🌐 <a href="https://www.sniffnet.net">www.sniffnet.net</a>
Expand Down Expand Up @@ -80,17 +80,17 @@ You can install Sniffnet in one of the following ways:
[32-bit](https://github.com/GyulyVGC/sniffnet/releases/latest/download/Sniffnet_Windows_32-bit.msi)

### macOS

- [Intel](https://github.com/GyulyVGC/sniffnet/releases/latest/download/Sniffnet_macOS_Intel.dmg) |
[Apple silicon](https://github.com/GyulyVGC/sniffnet/releases/latest/download/Sniffnet_macOS_AppleSilicon.dmg)

### Linux

- deb: [amd64](https://github.com/GyulyVGC/sniffnet/releases/latest/download/Sniffnet_LinuxDEB_amd64.deb) |
[arm64](https://github.com/GyulyVGC/sniffnet/releases/latest/download/Sniffnet_LinuxDEB_arm64.deb) |
[arm64](https://github.com/GyulyVGC/sniffnet/releases/latest/download/Sniffnet_LinuxDEB_arm64.deb) |
[i386](https://github.com/GyulyVGC/sniffnet/releases/latest/download/Sniffnet_LinuxDEB_i386.deb) |
[armhf](https://github.com/GyulyVGC/sniffnet/releases/latest/download/Sniffnet_LinuxDEB_armhf.deb)

- rpm: [x86_64](https://github.com/GyulyVGC/sniffnet/releases/latest/download/Sniffnet_LinuxRPM_x86_64.rpm) |
[aarch64](https://github.com/GyulyVGC/sniffnet/releases/latest/download/Sniffnet_LinuxRPM_aarch64.rpm)

Expand Down Expand Up @@ -273,7 +273,7 @@ sudo sniffnet
- 🌍 get information about the country of the remote hosts (IP geolocation)
- ⭐ save your favorite network hosts
- 🔉 set custom notifications to inform you when defined network events occur
- 🎨 choose the style that fits you the most from 4 different available themes
- 🎨 choose the style that fits you the most from 12 different available themes, plus custom theme support
- 🕵️ inspect each of your network connections in real time
- 📁 save complete textual reports with detailed information for each network connection:
* source and destination IP addresses
Expand All @@ -295,13 +295,13 @@ sudo sniffnet
Geolocation and network providers (ASN) refer to the remote IP address of each connection. They are retrieved performing lookups against [MMDB files](https://maxmind.github.io/MaxMind-DB/):

> **Note**
>
>
> The MMDB (MaxMind database) format has been developed especially for IP lookup.<br>
> It is optimized to perform lookups on data indexed by IP network ranges quickly and efficiently.<br>
> It permits the best performance on IP lookups, and it's suitable for use in a production environment.
>
>
> This product includes GeoLite2 data created by MaxMind, available from <a href="https://www.maxmind.com">https://www.maxmind.com </a>

This file format potentially allows Sniffnet to execute hundreds of different IP lookups in a matter of a few milliseconds.

</details>
Expand All @@ -312,23 +312,23 @@ sudo sniffnet
<details>

<summary>See details</summary>

<br>

Application layer protocols are inferred from the transport port numbers,
following the convention maintained by [IANA](https://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xhtml).

Please, remember that this is just a convention:

> **Warning**
>
>
> The Internet Assigned Numbers Authority (IANA) is responsible for maintaining
> the official assignments of port numbers for specific uses. <br>
> However, many unofficial uses of well-known port numbers occur in practice.

The following table reports the port-to-service mappings used by Sniffnet,
chosen from the most common assignments by IANA.

<div align="center">

|Port number(s)|Application protocol | Description |
Expand Down Expand Up @@ -400,6 +400,38 @@ The currently usable hotkeys are reported in the following.

</details>

## Custom themes
<details>

<summary>See details</summary>

Custom themes are specified as a TOML file.

The TOML must follow this format:
```toml
# Colors are in RGB/RGBA hexadecimal.
primary = "#1e1e2e" # Background
secondary = "#89b4fa" # Headers / incoming connections
buttons = "#313244" # Buttons
outgoing = "#f5c2e7" # Outgoing connections
text_headers = "#11111b" # Text headers
text_body = "#cdd6f4" # Text body
starred = "#f9e2afaa" # Favorites

# The following parameters are in the range [0.0, 1.0].
round_borders_alpha = 0.3 # Borders opacity
round_containers_alpha = 0.15 # Containers opacity
chart_badge_alpha = 0.2 # Chart opacity

# Set to true if the theme is dark, false if it's light.
nightly = true
```

The example theme above uses colors from [Catppuccin Mocha](https://github.com/catppuccin/catppuccin).

To use a custom theme for your instance of Sniffnet, specify the path of your TOML file in the application's
settings (at the bottom of the style tab).
</details>

## Troubleshooting

Expand All @@ -416,9 +448,9 @@ Check the [required dependencies](#required-dependencies) section for instructio
### Rendering problems

In some circumstances, especially if you are running on an old architecture or your graphical drivers are not up-to-date,
the `wgpu` default renderer used by [iced](https://github.com/iced-rs/iced)
the `wgpu` default renderer used by [iced](https://github.com/iced-rs/iced)
may cause problems (country icons are completely black, or the interface glitches). <br>
In these cases you can download an alternative version of the application,
In these cases you can download an alternative version of the application,
which is based on `tiny-skia`, a CPU-only software renderer that should work properly on every environment: <br>
[Windows](https://github.com/GyulyVGC/sniffnet/suites/18338999542/artifacts/1061225849) |
[macOS](https://github.com/GyulyVGC/sniffnet/suites/18338999542/artifacts/1061225848) |
Expand All @@ -439,5 +471,3 @@ which is based on `tiny-skia`, a CPU-only software renderer that should work pro
<p align="center"><a href="https://github.com/iced-rs/iced"><img alt="" src="https://user-images.githubusercontent.com/100347457/219339409-0a44722b-416d-410b-93a4-8b0e84c0031d.svg" width="50%"/></a></p>

- Last but not least, thanks to [every single stargazer](https://github.com/GyulyVGC/sniffnet/stargazers): all forms of support made it possible to keep improving Sniffnet!

<p align="center"><a href="https://github.com/GyulyVGC/sniffnet/stargazers"><img alt="" src="https://reporoster.com/stars/dark/GyulyVGC/sniffnet"/></a></p>
Binary file modified resources/fonts/subset/icons.ttf
Binary file not shown.
16 changes: 16 additions & 0 deletions resources/themes/catppuccin_mocha.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Colors are in RGB/RGBA hexadecimal.
primary = "#1e1e2e" # Background
secondary = "#89b4fa" # Headers / incoming connections
buttons = "#313244" # Buttons
outgoing = "#f5c2e7" # Outgoing connections
text_headers = "#11111b" # Text headers
text_body = "#cdd6f4" # Text body
starred = "#f9e2afaa" # Favorites

# The following parameters are in the range [0.0, 1.0].
round_borders_alpha = 0.3 # Borders opacity
round_containers_alpha = 0.15 # Containers opacity
chart_badge_alpha = 0.2 # Chart opacity

# Set to true if the theme is dark, false if it's light.
nightly = true
48 changes: 48 additions & 0 deletions src/configs/types/config_advanced_settings.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
//! Module defining the `ConfigAdvancedSettings` struct, which allows to save and reload
//! the application advanced settings.

use crate::utils::formatted_strings::get_default_report_file_path;
use serde::{Deserialize, Serialize};

#[derive(Serialize, Deserialize, Clone, PartialEq)]
pub struct ConfigAdvancedSettings {
pub scale_factor: f64,
pub mmdb_country: String,
pub mmdb_asn: String,
pub style_path: String,
pub output_path: String,
}

impl ConfigAdvancedSettings {
pub fn load() -> Self {
if let Ok(advanced_settings) =
confy::load::<ConfigAdvancedSettings>("sniffnet", "advanced_settings")
{
advanced_settings
} else {
confy::store(
"sniffnet",
"advanced_settings",
ConfigAdvancedSettings::default(),
)
.unwrap_or(());
ConfigAdvancedSettings::default()
}
}

pub fn store(self) {
confy::store("sniffnet", "advanced_settings", self).unwrap_or(());
}
}

impl Default for ConfigAdvancedSettings {
fn default() -> Self {
ConfigAdvancedSettings {
scale_factor: 1.0,
mmdb_country: String::new(),
mmdb_asn: String::new(),
style_path: String::new(),
output_path: get_default_report_file_path(),
}
}
}
13 changes: 13 additions & 0 deletions src/configs/types/config_device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,19 @@ impl Default for ConfigDevice {
}

impl ConfigDevice {
pub fn load() -> Self {
if let Ok(device) = confy::load::<ConfigDevice>("sniffnet", "device") {
device
} else {
confy::store("sniffnet", "device", ConfigDevice::default()).unwrap_or(());
ConfigDevice::default()
}
}

pub fn store(self) {
confy::store("sniffnet", "device", self).unwrap_or(());
}

pub fn to_my_device(&self) -> MyDevice {
for device in Device::list().unwrap() {
if device.name.eq(&self.device_name) {
Expand Down
15 changes: 15 additions & 0 deletions src/configs/types/config_settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,18 @@ pub struct ConfigSettings {
// StyleType should be last in order to deserialize as a table properly
pub style: StyleType,
}

impl ConfigSettings {
pub fn load() -> Self {
if let Ok(settings) = confy::load::<ConfigSettings>("sniffnet", "settings") {
settings
} else {
confy::store("sniffnet", "settings", ConfigSettings::default()).unwrap_or(());
ConfigSettings::default()
}
}

pub fn store(self) {
confy::store("sniffnet", "settings", self).unwrap_or(());
}
}
42 changes: 42 additions & 0 deletions src/configs/types/config_window.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
use iced::window::Position;
use serde::{Deserialize, Serialize};

#[derive(Serialize, Deserialize, Copy, Clone)]
pub struct ConfigWindow {
pub position: (i32, i32),
pub size: (u32, u32),
}

impl ConfigWindow {
pub fn load() -> Self {
if let Ok(window) = confy::load::<ConfigWindow>("sniffnet", "window") {
window
} else {
confy::store("sniffnet", "window", ConfigWindow::default()).unwrap_or(());
ConfigWindow::default()
}
}

pub fn store(self) {
confy::store("sniffnet", "window", self).unwrap_or(());
}
}

impl Default for ConfigWindow {
fn default() -> Self {
Self {
position: (0, 0),
size: (1190, 670),
}
}
}

pub trait ToPosition {
fn to_position(self) -> Position;
}

impl ToPosition for (i32, i32) {
fn to_position(self) -> Position {
Position::Specific(self.0, self.1)
}
}
27 changes: 27 additions & 0 deletions src/configs/types/configs.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
use crate::{ConfigAdvancedSettings, ConfigDevice, ConfigSettings, ConfigWindow};

#[derive(Default)]
pub struct Configs {
pub settings: ConfigSettings,
pub device: ConfigDevice,
pub advanced_settings: ConfigAdvancedSettings,
pub window: ConfigWindow,
}

impl Configs {
pub fn load() -> Self {
Configs {
settings: ConfigSettings::load(),
device: ConfigDevice::load(),
advanced_settings: ConfigAdvancedSettings::load(),
window: ConfigWindow::load(),
}
}

pub fn store(self) {
self.settings.store();
self.device.store();
self.advanced_settings.store();
self.window.store();
}
}
3 changes: 3 additions & 0 deletions src/configs/types/mod.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
pub mod config_advanced_settings;
pub mod config_device;
pub mod config_settings;
pub mod config_window;
pub mod configs;
16 changes: 0 additions & 16 deletions src/countries/country_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use iced::widget::tooltip::Position;
use iced::widget::Svg;
use iced::widget::Tooltip;
use iced::{Font, Length, Renderer};
use maxminddb::{geoip2, MaxMindDBError, Reader};

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,
Expand All @@ -27,21 +26,6 @@ use crate::translations::translations_2::{
};
use crate::{Language, StyleType};

pub const COUNTRY_MMDB: &[u8] = include_bytes!("../../resources/DB/GeoLite2-Country.mmdb");

pub fn get_country(address_to_lookup: &str, country_db_reader: &Reader<&[u8]>) -> Country {
let country_result: Result<geoip2::Country, MaxMindDBError> =
country_db_reader.lookup(address_to_lookup.parse().unwrap());
if let Ok(res1) = country_result {
if let Some(res2) = res1.country {
if let Some(res3) = res2.iso_code {
return Country::from_str(res3);
}
}
}
Country::ZZ // unknown
}

fn get_flag_from_country(
country: Country,
width: f32,
Expand Down
Loading