Skip to content

Commit

Permalink
A function to check if a tshark binary supports colorized packets.
Browse files Browse the repository at this point in the history
The --color switch was added to tshark in a version later than
termshark's stated support, meaning some users might be using tshark
binaries that don't support --color. If such a binary is run with the
--color flag, it will error out - not checking would result in empty
panes in termshark.
  • Loading branch information
gcla committed Nov 16, 2019
1 parent e1630e7 commit 8741f3f
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,12 @@ func TSharkVersion(tshark string) (semver.Version, error) {
return TSharkVersionFromOutput(string(output))
}

// Depends on empty.pcap being present
func TSharkSupportsColor(tshark string) (bool, error) {
exitCode, err := RunForExitCode(tshark, "-r", CacheFile("empty.pcap"), "-T", "psml", "-w", os.DevNull, "--color")
return exitCode == 0, err
}

// TSharkPath will return the full path of the tshark binary, if it's found in the path, otherwise an error
func TSharkPath() (string, *gowid.KeyValueError) {
tsharkBin := ConfString("main.tshark", "")
Expand Down

0 comments on commit 8741f3f

Please sign in to comment.