mirror of
https://github.com/GyulyVGC/sniffnet.git
synced 2026-04-19 05:39:09 -04:00
added CI/CD for npcap (Windows)
This commit is contained in:
55
.github/workflows/rust.yml
vendored
55
.github/workflows/rust.yml
vendored
@@ -7,6 +7,10 @@ on:
|
||||
pull_request:
|
||||
branches:
|
||||
- '*'
|
||||
workflow_call:
|
||||
secrets:
|
||||
NPCAP_OEM_URL:
|
||||
required: true
|
||||
|
||||
env:
|
||||
CARGO_TERM_COLOR: always
|
||||
@@ -15,7 +19,7 @@ env:
|
||||
jobs:
|
||||
fmt:
|
||||
name: Rustfmt
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: macos-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions-rs/toolchain@v1
|
||||
@@ -31,7 +35,7 @@ jobs:
|
||||
|
||||
clippy:
|
||||
name: Clippy
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: macos-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions-rs/toolchain@v1
|
||||
@@ -48,20 +52,47 @@ jobs:
|
||||
name: Mac Tests
|
||||
runs-on: macos-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Build
|
||||
run: cargo build --verbose
|
||||
- name: Run tests
|
||||
run: cargo test --verbose
|
||||
- uses: actions/checkout@v3
|
||||
- name: Build
|
||||
run: cargo build --verbose
|
||||
- name: Run tests
|
||||
run: cargo test --verbose
|
||||
|
||||
Linux:
|
||||
Linux:
|
||||
name: Linux Tests
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Install libpcap
|
||||
run: sudo apt-get install libpcap-dev
|
||||
- name: Install dependency for alsa-sys
|
||||
run: sudo apt-get install libasound2-dev
|
||||
- name: Build
|
||||
run: cargo build --verbose
|
||||
- name: Run tests
|
||||
run: cargo test --verbose
|
||||
|
||||
Windows:
|
||||
name: Windows Tests
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Install libpcap
|
||||
run: sudo apt-get install libpcap-dev
|
||||
- name: Build
|
||||
- name: Install npcap sdk
|
||||
run: |
|
||||
Invoke-WebRequest -Uri "https://npcap.com/dist/npcap-sdk-1.13.zip" -OutFile "C:/npcap-sdk.zip"
|
||||
Expand-Archive -LiteralPath C:/npcap-sdk.zip -DestinationPath C:/npcap-sdk
|
||||
echo "LIB=C:/npcap-sdk/Lib/x64" >> $env:GITHUB_ENV
|
||||
- name: Install npcap dll
|
||||
# Secrets are not passed to workflows that are triggered by a pull request from a fork.
|
||||
# https://docs.github.com/actions/automating-your-workflow-with-github-actions/creating-and-using-encrypted-secrets
|
||||
if: github.event_name != 'pull_request'
|
||||
run: |
|
||||
$OEM_URL = ConvertTo-SecureString "${{ secrets.NPCAP_OEM_URL }}" -AsPlainText -Force
|
||||
Invoke-WebRequest -Uri $OEM_URL -OutFile C:/npcap-oem.exe
|
||||
C:/npcap-oem.exe /S
|
||||
- name: Build
|
||||
if: github.event_name != 'pull_request'
|
||||
run: cargo build --verbose
|
||||
- name: Run tests
|
||||
- name: Run tests
|
||||
if: github.event_name != 'pull_request'
|
||||
run: cargo test --verbose
|
||||
|
||||
7
.gitignore
vendored
7
.gitignore
vendored
@@ -217,11 +217,10 @@ $RECYCLE.BIN/
|
||||
|
||||
#####################################################################
|
||||
|
||||
# report file generated by the application
|
||||
# report file generated by the application and country database
|
||||
*.txt
|
||||
|
||||
#folder with gif and images
|
||||
/img
|
||||
*.csv
|
||||
/country_db
|
||||
|
||||
#folder with reports
|
||||
/sniffnet_*
|
||||
|
||||
@@ -113,7 +113,7 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
if self.eq(&AppProtocol::Other) {
|
||||
write!(f, "All protocols")
|
||||
} else {
|
||||
write!(f, "{:?}", self)
|
||||
write!(f, "{self:?}")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,6 @@ pub enum IpVersion {
|
||||
|
||||
impl fmt::Display for IpVersion {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "{:?}", self)
|
||||
write!(f, "{self:?}")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,6 @@ pub enum TransProtocol {
|
||||
|
||||
impl fmt::Display for TransProtocol {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "{:?}", self)
|
||||
write!(f, "{self:?}")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@ pub fn initial_page(sniffer: &mut Sniffer) -> Column<Message> {
|
||||
}
|
||||
Some(description) => {
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
dev_str.push_str(&format!("{}\n", name));
|
||||
dev_str.push_str(&format!("{name}\n"));
|
||||
dev_str.push_str(&description);
|
||||
}
|
||||
}
|
||||
@@ -122,7 +122,7 @@ pub fn initial_page(sniffer: &mut Sniffer) -> Column<Message> {
|
||||
|
||||
for addr in dev.addresses {
|
||||
let address_string = addr.addr.to_string();
|
||||
dev_str.push_str(&format!("\n {}", address_string));
|
||||
dev_str.push_str(&format!("\n {address_string}"));
|
||||
}
|
||||
dev_str.push_str("\n ");
|
||||
dev_str_list.push((name, dev_str));
|
||||
@@ -329,7 +329,7 @@ pub fn initial_page(sniffer: &mut Sniffer) -> Column<Message> {
|
||||
let footer_row = Row::new()
|
||||
.align_items(Alignment::Center)
|
||||
.push(
|
||||
Text::new(format!("Sniffnet {} - by Giuliano Bellini ", APP_VERSION))
|
||||
Text::new(format!("Sniffnet {APP_VERSION} - by Giuliano Bellini "))
|
||||
.size(FONT_SIZE_FOOTER)
|
||||
.font(font_footer),
|
||||
)
|
||||
|
||||
@@ -145,13 +145,13 @@ pub fn run_page(sniffer: &mut Sniffer) -> Column<Message> {
|
||||
{
|
||||
(Text::new(sniffer.waiting.len().to_string()).font(ICONS).size(60),
|
||||
Text::new(format!("No traffic has been observed yet. Waiting for network packets...\n\n\
|
||||
Network adapter: {}\n\n\
|
||||
Are you sure you are connected to the internet and you have selected the right adapter?", adapter_name)).font(font))
|
||||
Network adapter: {adapter_name}\n\n\
|
||||
Are you sure you are connected to the internet and you have selected the right adapter?")).font(font))
|
||||
} else {
|
||||
(Text::new('T'.to_string()).font(ICONS).size(60),
|
||||
Text::new(format!("No traffic can be observed because the adapter you selected has no active addresses...\n\n\
|
||||
Network adapter: {}\n\n\
|
||||
If you are sure you are connected to the internet, try choosing a different adapter.", adapter_name)).font(font))
|
||||
Network adapter: {adapter_name}\n\n\
|
||||
If you are sure you are connected to the internet, try choosing a different adapter.")).font(font))
|
||||
};
|
||||
body = body
|
||||
.push(Row::new().height(Length::FillPortion(1)))
|
||||
@@ -410,8 +410,7 @@ pub fn run_page(sniffer: &mut Sniffer) -> Column<Message> {
|
||||
|
||||
let error_text = Text::new(format!(
|
||||
"An error occurred! \n\n\
|
||||
{}",
|
||||
err_string
|
||||
{err_string}",
|
||||
))
|
||||
.font(font);
|
||||
|
||||
@@ -438,7 +437,7 @@ pub fn run_page(sniffer: &mut Sniffer) -> Column<Message> {
|
||||
let footer_row = Row::new()
|
||||
.align_items(Alignment::Center)
|
||||
.push(
|
||||
Text::new(format!("Sniffnet {} - by Giuliano Bellini ", APP_VERSION))
|
||||
Text::new(format!("Sniffnet {APP_VERSION} - by Giuliano Bellini "))
|
||||
.size(FONT_SIZE_FOOTER)
|
||||
.font(font_footer),
|
||||
)
|
||||
|
||||
@@ -89,7 +89,7 @@ fn build_chart<DB: DrawingBackend>(&self, mut chart: ChartBuilder<DB>) {
|
||||
.label_style(("notosans", 15).into_font().color(&self.font_color))
|
||||
.y_label_formatter(&|bytes| match bytes {
|
||||
0..=999 | -999..=-1 => {
|
||||
format!("{}", bytes)
|
||||
format!("{bytes}")
|
||||
}
|
||||
1000..=999_999 | -999_999..=-1000 => {
|
||||
format!("{:.1} {}", *bytes as f64 / 1_000_f64, "k")
|
||||
|
||||
@@ -129,8 +129,7 @@ pub fn get_app_count_string(app_count: HashMap<AppProtocol, u128>, tot_packets:
|
||||
let spaces_string_2 = " ".to_string().repeat(10 - percentage_string.len());
|
||||
|
||||
ret_val.push_str(&format!(
|
||||
" {}:{}{}{}{} \n",
|
||||
app_proto_string, spaces_string_1, num_string, spaces_string_2, percentage_string
|
||||
" {app_proto_string}:{spaces_string_1}{num_string}{spaces_string_2}{percentage_string} \n",
|
||||
));
|
||||
}
|
||||
ret_val
|
||||
@@ -163,9 +162,9 @@ pub fn get_formatted_bytes_string(bytes: u128) -> String {
|
||||
|
||||
if !multiple_transmitted.is_empty() {
|
||||
// with multiple
|
||||
format!("{:.1} {}B", n, multiple_transmitted)
|
||||
format!("{n:.1} {multiple_transmitted}B")
|
||||
} else {
|
||||
// no multiple
|
||||
format!("{} B", n)
|
||||
format!("{n} B")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user