Skip to content

Commit

Permalink
Change default suppress-errors boolean to true, not false
Browse files Browse the repository at this point in the history
If this value is not set explicitly, a false value means that an error
from a termshark-initiated tshark process will result in an error dialog
in the termshark UI. I am seeing this more and more as I test with
various pcaps - it always comes from tshark serializing characters into
XML text that are invalid, according to the XML spec (val <= 31 and val
not in {tab, CR, LF}). Here is a merge request against Wireshark to try
to solve this problem at the source:
https://gitlab.com/wireshark/wireshark/-/merge_requests/7398

To see the problem, try this:

$ wget https://storage.googleapis.com/gcla3/xmlbug.pcapng
$ tshark -r xmlbug.pcapng -T pdml | xmllint --noout - || echo bad xml

Even if this Wireshark request is merged, it will presumably be a long
time before all termshark-used tsharks are updated. So I think the more
user-friendly option is to suppress these errors to avoid popups about
which the user can do very little anyway.

Here's a hack you can use if you want to see errors, in general, but are
not interested in this specific XML error:

#133 (comment)

Workaround:

- create the following file called e.g. /usr/local/bin/tshark-hack

if [[ " $* " =~ " pdml " ]]; then
    exec tshark "$@" | tr -cd '\11\12\15\40-\176'
else
    exec tshark "$@"
fi

- run:

$ sudo chmod +x /usr/local/bin/tshark-hack

- edit ~/.config/termshark/termshark.toml

[main]
  tshark = "/usr/local/bin/tshark-hack"
  • Loading branch information
gcla committed Jul 10, 2022
1 parent 5577dd6 commit 0578a1c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions ui/prochandlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ func (t updatePacketViews) OnError(code pcap.HandlerCode, app gowid.IApp, err er
fmt.Fprintf(os.Stderr, "%v\n", err)
RequestQuit()
} else {
if !profiles.ConfBool("main.suppress-tshark-errors", false) {
if !profiles.ConfBool("main.suppress-tshark-errors", true) {
var errstr string
if kverr, ok := err.(gowid.KeyValueError); ok {
errstr = fmt.Sprintf("%v\n\n", kverr.Cause())
Expand Down Expand Up @@ -160,7 +160,7 @@ func (t SimpleErrors) OnError(code pcap.HandlerCode, app gowid.IApp, err error)
log.Error(err)
// Hack to avoid picking up errors at other parts of the load
// cycle. There should be specific handlers for specific errors.
if !profiles.ConfBool("main.suppress-tshark-errors", false) {
if !profiles.ConfBool("main.suppress-tshark-errors", true) {
app.Run(gowid.RunFunction(func(app gowid.IApp) {
OpenError(fmt.Sprintf("%v", err), app)
}))
Expand Down Expand Up @@ -379,7 +379,7 @@ func (s SetStructWidgets) OnError(code pcap.HandlerCode, app gowid.IApp, err err
// Hack to avoid picking up errors at other parts of the load
// cycle. There should be specific handlers for specific errors.
if s.Ld.PdmlLoader.IsLoading() {
if !profiles.ConfBool("main.suppress-tshark-errors", false) {
if !profiles.ConfBool("main.suppress-tshark-errors", true) {
app.Run(gowid.RunFunction(func(app gowid.IApp) {
OpenLongError(fmt.Sprintf("%v", err), app)
}))
Expand Down
2 changes: 1 addition & 1 deletion ui/streamui.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ func (t *streamParseHandler) OnError(code pcap.HandlerCode, app gowid.IApp, err
if !Running {
fmt.Fprintf(os.Stderr, "%v\n", err)
RequestQuit()
} else if !profiles.ConfBool("main.suppress-tshark-errors", false) {
} else if !profiles.ConfBool("main.suppress-tshark-errors", true) {
var errstr string
if kverr, ok := err.(gowid.KeyValueError); ok {
errstr = fmt.Sprintf("%v\n\n", kverr.Cause())
Expand Down

0 comments on commit 0578a1c

Please sign in to comment.