diff --git a/ui/lastline.go b/ui/lastline.go index 9d4e5ba..d35a26d 100644 --- a/ui/lastline.go +++ b/ui/lastline.go @@ -114,6 +114,7 @@ func newSetArg(sub string) substrArg { "packet-colors", "pager", "nopager", + "suppress-tshark-errors", "term", "noterm", }, @@ -347,6 +348,15 @@ func (d setCommand) Run(app gowid.IApp, args ...string) error { termshark.SetConf("main.packet-colors", PacketColors) OpenMessage(fmt.Sprintf("Packet colors are now %s", gwutil.If(b, "on", "off").(string)), appView, app) } + case "suppress-tshark-errors": + if b, err = parseOnOff(args[2]); err == nil { + termshark.SetConf("main.suppress-tshark-errors", b) + if b { + OpenMessage("tshark errors will be suppressed.", appView, app) + } else { + OpenMessage("tshark errors will be displayed.", appView, app) + } + } case "term": if err = termshark.ValidateTerm(args[2]); err == nil { termshark.SetConf("main.term", args[2]) @@ -387,7 +397,7 @@ func (d setCommand) Arguments(toks []string, app gowid.IApp) []minibuffer.IArg { res = append(res, newSetArg(toks[0])) if len(toks) > 0 { - onOffCmds := []string{"auto-scroll", "dark-mode", "packet-colors"} + onOffCmds := []string{"auto-scroll", "dark-mode", "packet-colors", "suppress-tshark-errors"} boolCmds := []string{"disable-shark-fin"} intCmds := []string{"disk-cache-size-mb", "copy-command-timeout"} diff --git a/ui/messages.go b/ui/messages.go index 0d1cc3d..bbf3d19 100644 --- a/ui/messages.go +++ b/ui/messages.go @@ -134,15 +134,16 @@ Use the cmdline set command to change configuration. Type :set and hit tab for options. -auto-scroll________ - scroll during live captures -copy-timeout_______ - wait this long before failing a copy -dark-mode__________ - enable or disable dark-mode -disable-shark-fin__ - switch off the secret shark fin -packet-colors______ - use colors in the packet list view -pager______________ - pager (used for termshark's log file) -nopager____________ - disable the pager (use PAGER instead) -term_______________ - make termshark assume this terminal type -noterm_____________ - disable the terminal type (use TERM){{end}} +auto-scroll___________ - scroll during live captures +copy-timeout__________ - wait this long before failing a copy +dark-mode_____________ - enable or disable dark-mode +disable-shark-fin_____ - switch off the secret shark fin +packet-colors_________ - use colors in the packet list view +pager_________________ - pager (used for termshark's log file) +nopager_______________ - disable the pager (use PAGER instead) +suppress-tshark-errors - don't show tshark errors in the UI +term__________________ - make termshark assume this terminal type +noterm________________ - disable the terminal type (use TERM){{end}} {{define "MapHelp"}}{{template "NameVer" .}} diff --git a/ui/prochandlers.go b/ui/prochandlers.go index 6cba334..32972c2 100644 --- a/ui/prochandlers.go +++ b/ui/prochandlers.go @@ -117,20 +117,21 @@ func (t updatePacketViews) OnError(code pcap.HandlerCode, app gowid.IApp, err er fmt.Fprintf(os.Stderr, "%v\n", err) RequestQuit() } else { - - var errstr string - if kverr, ok := err.(gowid.KeyValueError); ok { - errstr = fmt.Sprintf("%v\n\n", kverr.Cause()) - kvs := make([]string, 0, len(kverr.KeyVals)) - for k, v := range kverr.KeyVals { - kvs = append(kvs, fmt.Sprintf("%v: %v", k, v)) + if !termshark.ConfBool("main.suppress-tshark-errors", false) { + var errstr string + if kverr, ok := err.(gowid.KeyValueError); ok { + errstr = fmt.Sprintf("%v\n\n", kverr.Cause()) + kvs := make([]string, 0, len(kverr.KeyVals)) + for k, v := range kverr.KeyVals { + kvs = append(kvs, fmt.Sprintf("%v: %v", k, v)) + } + errstr = errstr + strings.Join(kvs, "\n") + } else { + errstr = fmt.Sprintf("%v", err) } - errstr = errstr + strings.Join(kvs, "\n") - } else { - errstr = fmt.Sprintf("%v", err) - } - OpenLongError(errstr, app) + OpenLongError(errstr, app) + } StopEmptyStructViewTimer() StopEmptyHexViewTimer() } @@ -149,9 +150,11 @@ 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. - app.Run(gowid.RunFunction(func(app gowid.IApp) { - OpenError(fmt.Sprintf("%v", err), app) - })) + if !termshark.ConfBool("main.suppress-tshark-errors", false) { + app.Run(gowid.RunFunction(func(app gowid.IApp) { + OpenError(fmt.Sprintf("%v", err), app) + })) + } } //====================================================================== @@ -344,9 +347,11 @@ 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() { - app.Run(gowid.RunFunction(func(app gowid.IApp) { - OpenLongError(fmt.Sprintf("%v", err), app) - })) + if !termshark.ConfBool("main.suppress-tshark-errors", false) { + 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 2b1cee7..6e299fa 100644 --- a/ui/streamui.go +++ b/ui/streamui.go @@ -339,8 +339,7 @@ func (t *streamParseHandler) OnError(code pcap.HandlerCode, app gowid.IApp, err if !Running { fmt.Fprintf(os.Stderr, "%v\n", err) RequestQuit() - } else { - + } else if !termshark.ConfBool("main.suppress-tshark-errors", false) { var errstr string if kverr, ok := err.(gowid.KeyValueError); ok { errstr = fmt.Sprintf("%v\n\n", kverr.Cause())