From 0578a1ca70f0ff6c151eef55d61505c7fa794366 Mon Sep 17 00:00:00 2001 From: Graham Clark Date: Sun, 10 Jul 2022 19:36:49 -0400 Subject: [PATCH] Change default suppress-errors boolean to true, not false 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: https://github.com/gcla/termshark/issues/133#issuecomment-985194719 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" --- ui/prochandlers.go | 6 +++--- ui/streamui.go | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ui/prochandlers.go b/ui/prochandlers.go index a0401de..5198697 100644 --- a/ui/prochandlers.go +++ b/ui/prochandlers.go @@ -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()) @@ -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) })) @@ -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) })) diff --git a/ui/streamui.go b/ui/streamui.go index ca4d8ef..eb43982 100644 --- a/ui/streamui.go +++ b/ui/streamui.go @@ -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())