-
Notifications
You must be signed in to change notification settings - Fork 411
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
A simpler way to detect when a live packet source is ready
If you start termshark like this: $ termshark -i eth0 then the UI will not start until packets are seen. I thought this provided a better experience than launching the UI immediately and having it remain empty - there might be information on the terminal, so best not clear that away immediately to show no information and a moving spinner. The user will see this in the terminal: (The termshark UI will start when packets are detected...) When termshark starts in this mode, it runs a few processes; something like: (1) dumpcap -i eth0 -w <tmpfile> (2) tail -f tmpfile | ... (3) ... tshark -i - -T psml Prior to this change, I detected the presence of packets by watching for the creation of the file <tmpfile>. But this doesn't work very well because dumpcap often (not always??) creates an empty file with pcap headers very quickly, even though there are no packets in the file yet. And it's no ideal relying on this behavior. This change uses a different approach. Instead I have a callback from the PSML loader when PSML headers are received. I set that callback up to a close a channel used by the main loop in termshark.go. When the channel is closed, I start the UI. This also has the nice effect of further simplifying and reducing the size of termshark.go.
- Loading branch information
Showing
4 changed files
with
34 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters