Add latency check to connection details - #1194
Conversation
|
Hey @ethical-buddy this would be a nice addition to the app, thanks! The foundations look solid but:
|
Refactor the ping execution path behind a small executor so tests can exercise the command launch, output handling, and error branches without touching the network. This keeps the current platform-specific ping behavior unchanged while adding coverage for the actual flow requested in review.
|
Thanks for the review! I pushed a follow-up commit that expands the latency coverage beyond just parsing ping output. The latency code now has a small executor boundary, so the tests cover the actual command-to-result flow without touching the network: platform-specific ping args, successful stdout parsing, missing latency output, stderr from failed ping, and launch failures. I also checked the Rust ping crate direction briefly. Crates like surge-ping / ping-rs look useful, but since they rely on ICMP sockets they can introduce extra platform and permission trade-offs. I kept the system ping approach for this follow-up so the runtime behavior stays unchanged while the test coverage is stronger. Does this direction look good to you, or would you prefer I dig deeper into a native ICMP crate despite those permission trade-offs? |
|
Right now I don't have enough knowledge to make a decision about this. Concerning the test, what's the issue are you trying to avoid with the executor? |
Drop the test-only executor and keep the production latency path direct. The new loopback test runs the actual ping command end to end, while still allowing local non-CI sandboxes without ping socket permissions to run the suite.
|
That makes sense, thanks for clarifying. I pushed another follow-up that removes the executor abstraction and keeps the production path direct again. The latency test now calls the real measurement function against loopback, so it runs the actual ping command end to end instead of mocking the execution layer. The only small caveat I kept is a non-CI guard for local environments where ping cannot open sockets. I hit that in my local sandbox with Does this match the structure you had in mind, or would you prefer removing even that local-only permission guard? |
|
Thanks it's fine for the moment. Still I'm not sure the final version of this will spawn a ping command directly, but for now let's wait until I find what to do. Thanks for your time! |
|
Hey @ethical-buddy after some research I would definitely prefer using
At first sight, I think you should use Most importantly, as you said there's the platform permission thing to verify, but this shouldn't be a problem on macOS (already running with sudo) and Linux (running with |
|
Thanks for checking this. That direction makes sense to me. I’ll switch the implementation to surge-ping and remove the output parsing path. I’ll also look specifically at whether keeping a reusable surge-ping::Client in the app state is better than creating one per measurement, since that affects how much state we need to thread through the iced task. The main thing I’ll verify is the Windows behavior without elevated privileges. If surge-ping needs raw socket permissions there too, I’ll report back with what I find before adding a fallback, since I don’t want to keep the old command path unless you’re okay with that trade-off. |
Switch latency measurement away from spawning ping and parsing platform-specific output. The new path keeps reusable IPv4 and IPv6 surge-ping clients, uses unique sequences for measurements, and keeps the loopback coverage end to end.
|
I pushed the surge-ping version now. The latency path no longer spawns the system ping command or parses command output. It uses reusable surge-ping clients instead: one for IPv4 and one for IPv6, selected by the target address. I also added a shared sequence counter so concurrent measurements do not reuse the same ping sequence. I kept the tests end to end against loopback and updated them for the async path. Locally I verified:
The only full-suite failure without the skip is the existing GitHub latest-release network test, unrelated to this change. Does this look like the structure you had in mind for reusing |
|
Did you verify how it behaves on Windows without admin privileges? |
|
I currently dont have any windows setup with me to test , I am still getting it arranged , |
|
Oh yeah I have a Windows VM so I can try when I have some time |
|
That would be great . |
|
Hello, I was browsing github on windows, so if i can help... i've tested on this setup : It works fine ! |
|
Tested on macOS, Linux, and Windows and I confirm it works. |
|
@all-contributors please add @ethical-buddy for code. |
|
I've put up a pull request to add @ethical-buddy! 🎉 |
Closes #845.
This adds a latency row to the connection details modal. The measurement only runs when the user clicks the latency button for the selected remote address, so Sniffnet does not add extra traffic for every captured connection.
The result is cached per remote IP while the app is running and is shown as measuring, measured, or unavailable depending on the ping result.
Checks run locally: