Commit Graph

270 Commits

Author SHA1 Message Date
cyqsimon
e1e37b8564 WIP 2024-10-09 12:57:47 +08:00
cyqsimon
58fb01a69d Rename Utilization::update to Utilization::ingest 2024-10-09 12:35:47 +08:00
cyqsimon
2193cf93db Rename ui_offset -> table_cycle_offset 2024-10-09 12:35:47 +08:00
cyqsimon
dfd9d93ec9 Move show_dns into UIState
- Plus some variable naming cleanup
2024-10-09 12:35:47 +08:00
cyqsimon
5c6419c85c Make write_to_stdout take a &str instead of a String 2024-10-09 12:35:47 +08:00
cyqsimon
75122fa663 Fix clippy::needless_lifetimes warnings on nightly
The warnings in `derivative`'s derived code are not something we can fix.
2024-10-08 14:48:45 +08:00
cyqsimon
b313cd1ea6 Fix breaking changes of sysinfo crate 2024-10-08 14:36:02 +08:00
cyqsimon
78d3984ede Fix breaking changes of ratatui 0.28.0
See https://github.com/ratatui/ratatui/blob/main/BREAKING-CHANGES.md#v0280
2024-10-08 13:48:05 +08:00
Nbiba Bedis
3f160aaa9e chore: exit gracefully when there is a broken pipe error 2024-10-07 19:34:14 +01:00
cyqsimon
894ea31983 Update sysinfo API calls (#421)
- Fixes #420
2024-08-13 10:14:04 +08:00
cyqsimon
d9fa0894a3 Temporarily disable UI tests (#406)
* Temporarily disable UI tests

- Too many sporadic errors occlude actual problems; see #400
- These tests will be re-enabled once the big refactor is complete

* Write changelog
2024-04-16 10:36:32 +08:00
cyqsimon
2ac352d490 Fix Windows FP discrepancy issue in test (#400)
* Fix Windows FP discrepancy issue in test

* Write changelog
2024-04-15 16:32:44 +08:00
Felix Obenhuber
9354683481 Enable Android build (#384)
* Support build for target_os android

The target_os `android` is quite similar to `linux` but must be
mentioned in the guards explicitly. Tested for target
`aarch64-linux-android`.

* Add target aarch64-linux-android to ci

Use `cross` for building target `aarch64-linux-android`. In the `ci`
workflow the matrix branch of `os` `ubuntu-latest` is used because the
matrix organization is host os centric instead of target.

Releases are build with `cross` for target `aarch64-linux-android`.

Install `cross` if needed for a run. At the time of writing the latest
release of `cross` can't build binaries for target
`aarch64-linux-android` and it's common sense that the latest git tag or
`master` shall be used [1].

[1] https://github.com/cross-rs/cross/issues/1222

* Add android related readme section
2024-04-02 17:39:24 +08:00
cyqsimon
7dbd3719e7 Fix IPv6 socket detect logic (#383)
* Fix IPv6 socket detect logic

* Write changelog
2024-03-25 20:30:13 +08:00
cyqsimon
451daea0ac Apply suggestions from new clippy lint clippy::assigning_clones (#382)
* fix: clippy warnings

* Additional fix

* Write changelog

---------

Co-authored-by: Krithic Kumar <krithickumarub@protonmail.com>
2024-03-25 13:42:17 +08:00
cyqsimon
32506e7f24 Remove unnecessary logging synchronisation (#381)
* Revert 89e1140

- simplelog is already thread safe
- see https://github.com/Drakulix/simplelog.rs/issues/146

* Write changelog

* Fix import for MacOS
2024-03-25 13:20:12 +08:00
Krithic Kumar
1997bce393 feat: add PID column to Process table (#379)
* feat: add `PID` column to `Process` table

* fix(tests): populate fake data with the correct `ProcessInfo` type

* test: update snapshots

* refactor: use more idiomatic rust

* refactor: rename function from `get_proc_name` to `get_proc_info`

* refactor: only display PID when width available is highest

ref: https://github.com/imsnif/bandwhich/pull/165#issuecomment-620852892

* tests: update snapshots

* chore: update CHANGELOG

* fix: clippy warnings

* Revert "fix: clippy warnings"

This reverts commit e5f06cba19.
We will do this separately for the sake of keeping a clean history

* refactor: use `u32` for PID

* refactor: more idiomatic rust

---------

Co-authored-by: cyqsimon <28627918+cyqsimon@users.noreply.github.com>
2024-03-18 13:29:47 +08:00
dependabot[bot]
23d187986e chore(deps): bump ratatui from 0.25.0 to 0.26.1 (#368)
* chore(deps): bump ratatui from 0.25.0 to 0.26.1

Bumps [ratatui](https://github.com/ratatui-org/ratatui) from 0.25.0 to 0.26.1.
- [Release notes](https://github.com/ratatui-org/ratatui/releases)
- [Changelog](https://github.com/ratatui-org/ratatui/blob/main/CHANGELOG.md)
- [Commits](https://github.com/ratatui-org/ratatui/compare/v0.25.0...v0.26.1)

---
updated-dependencies:
- dependency-name: ratatui
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* Use legacy layout (for now)

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: cyqsimon <28627918+cyqsimon@users.noreply.github.com>
2024-03-03 00:40:23 +08:00
cyqsimon
862ede716c Remove redundant imports (#377)
* Remove redundant imports

- Now linted by clippy in 1.78
- See https://github.com/rust-lang/rust/pull/117772

* Write changelog

* Remove Windows-only redundant imports in build script
2024-03-01 10:55:38 +08:00
cyqsimon
dc0468c8e7 Generate completion & manpage (#357)
* Generate completion & manpage

* Write changelog
2024-01-28 04:21:06 +08:00
cyqsimon
67711e7f71 Hot-fix: Windows compile issue (#356) 2024-01-28 02:31:17 +08:00
dependabot[bot]
9e0dc2b612 chore(deps): bump ratatui from 0.24.0 to 0.25.0 (#348)
* chore(deps): bump ratatui from 0.24.0 to 0.25.0

Bumps [ratatui](https://github.com/ratatui-org/ratatui) from 0.24.0 to 0.25.0.
- [Release notes](https://github.com/ratatui-org/ratatui/releases)
- [Changelog](https://github.com/ratatui-org/ratatui/blob/main/CHANGELOG.md)
- [Commits](https://github.com/ratatui-org/ratatui/compare/v0.24.0...v0.25.0)

---
updated-dependencies:
- dependency-name: ratatui
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* Update API changes

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: cyqsimon <28627918+cyqsimon@users.noreply.github.com>
2024-01-28 00:22:01 +08:00
ilyes-ced
5648be6f11 Show interface names (#340)
* added interface names

* some fixes

* Set interface name in UI only once

* Code style

* Add changelog entry

---------

Co-authored-by: cyqsimon <28627918+cyqsimon@users.noreply.github.com>
2023-12-08 16:33:10 +08:00
cyqsimon
16a6f9eec6 Display bandwidth in different unit families (#328)
* Allow selecting unit families

- Supported units are {binary,SI}-{bytes,bits}

* Fix typo

* Better error msg in the unreachable case

* - I can't believe I did this. Frankly, terrible.

* Add unit test

* Add peta&pebi units to be absolutely future-proof

* Minor code style improvement
2023-11-02 14:00:58 +08:00
cyqsimon
022eade156 Bump ratatui to 0.24.0 (#327) 2023-11-01 12:00:58 +08:00
cyqsimon
aef30c9bee Log unresolved processes in more detail + general refactor (#318)
* Refactor & reorganisation of `get_proc_name`

* Log both src & dst when we fail to resolve connection to process

- Per recommendation in https://github.com/imsnif/bandwhich/issues/196#issuecomment-1763278674
2023-11-01 01:44:27 +08:00
cyqsimon
62c0fbf128 Fix vague CLI option documentation; closes #314 (#316) 2023-10-29 21:25:49 +08:00
cyqsimon
2c49b0fc12 Use once_cell::sync::Lazy to make regex usage more ergonomic (#313) 2023-10-26 14:59:42 +08:00
cyqsimon
34713f699b Minor code style improvements (#312)
- Build regex only once using `once_cell::sync::Lazy`
- Reduce code duplication
2023-10-26 11:52:35 +08:00
cyqsimon
de791a1f62 Reset clippy levels
- Also denies `enum_glob_use`
2023-10-21 22:35:04 +08:00
cyqsimon
6fa77d2991 Refactor OsInputOutput (combine interfaces & frames into single Vec) (#310)
* Refactor `OsInputOutput` (combine interfaces & frames into single Vec)

* Add note on handling a separate failure case

* Reduce code duplication
2023-10-21 22:14:46 +08:00
cyqsimon
89e1140bea Make logging race-free using a global lock & macro (#309)
* Make logging race-free using a global lock & macro

* Fix clippy complaint

* Fix import for MacOS

* Make `mt_log` expand to an expression
2023-10-20 19:25:27 +08:00
cyqsimon
0c4987aa86 Table formatting logic overhaul (#305)
* Table formatting logic overhaul

- Columns now auto-expand and auto-shrink proportionally
- Data column selection logic is now set per-table
- Necessary boilerplate added to allow tables with more (or fewer) columns in the future

* Better naming: `TableLayout` -> `DisplayLayout`

* Fix clippy complaints

* Optimise layout cutoff widths

- These values are pretty much arbitrary. I'm open to further optimising them in the future.

* Updated test snapshots to match new layout settings

* Remove unnecessary logging

* Correct `debug_fn` impl for `column_selector`

* Further optimise bandwidth column display

* Update test snapshots

* Layout width preset minor adjustment
2023-10-19 16:55:04 +08:00
cyqsimon
d9cc84b373 Partially fix flaky tests (#308)
* Minor code style changes

* Disable rendering of timestamps in tests

* Update test snapshots

* Test everything with insta macros (no more `assert(_eq)?`)

- This has the benefit of creating snapshots for everything, allowing for later diffing

* Don't use `assert_debug_snapshot` for large string outputs

- This makes snapshots more human-inspectable

* Code style improvement on two tests

- `pause_by_space`
- `rearranged_by_tab`

* Minor code style improvements
2023-10-17 16:29:47 +08:00
cyqsimon
b82383dc58 Set known orphan connections max size 2023-10-12 20:43:14 +08:00
cyqsimon
76956cfade Handle IPv4-mapped IPv6 addresses when resolving connection owner 2023-10-12 19:40:23 +08:00
cyqsimon
ea3e0d675f Reduce logging noise by omitting known orphan connections 2023-10-12 19:03:52 +08:00
cyqsimon
b1726fc1cc Forgot to allow write access to log file 2023-10-12 17:46:19 +08:00
cyqsimon
a9c199f812 Add logging when the process name fails to resolve 2023-10-12 17:35:43 +08:00
cyqsimon
1c996c38f4 Ignore connections that fail parsing instead of panicking on BSD (#288)
* Ignore connections that fail parsing instead of panicking on BSD

- Tentative fix for #217

* Log when a connection fails parsing

- I actually love unreadable code

* Fix clippy complaint
2023-10-11 19:45:48 +08:00
cyqsimon
3703c676f2 Fix clippy complaints 2023-10-11 19:12:37 +08:00
cyqsimon
94ada5db8a Add logging infrastructure (#302)
* Add logging dependencies

* Initialise logging
2023-10-11 18:16:56 +08:00
cyqsimon
5cb09cca19 Reduce repitition using default Opts 2023-10-11 17:42:06 +08:00
cyqsimon
5884c7322f Never use &Option in function signature 2023-10-11 17:20:14 +08:00
cyqsimon
b353c51ae8 Minor refactor of main.rs (#301)
* Move CLI structs to their own file

* `main` returns `Result` directly

* Slightly reduced nesting
2023-10-11 17:02:41 +08:00
cyqsimon
96cbe63a97 Explicitly name layout-* tests as so 2023-10-08 01:02:28 +08:00
cyqsimon
471aa62a95 Migrate all tests to using cargo-insta 2023-10-08 00:54:40 +08:00
cyqsimon
72b04c82ae Compact tests using rstest 2023-10-07 22:35:35 +08:00
cyqsimon
f1b49254c2 Rm old, unused test snapshots 2023-10-07 21:56:17 +08:00
Marcin Puc
067b7988a6 Add missing version flag to CLI (#290) 2023-09-20 18:40:33 +08:00