Skip to content

Commit

Permalink
Better control of a display filter error message
Browse files Browse the repository at this point in the history
The pcap loader's NewFilter entrypoint is called in several places
e.g. by the stream reassembly UI. But the fact that the filter being
applied is the same as the current one is an error/warning only if the
user applies it from the filter widget. So I don't want these errors
displayed in other circumstances.
  • Loading branch information
gcla committed Jan 3, 2021
1 parent ff872c7 commit 4d16242
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
8 changes: 0 additions & 8 deletions pcap/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -432,14 +432,6 @@ func (c *PacketLoader) NewFilter(newfilt string, cb interface{}, app gowid.IApp)

if c.DisplayFilter() == newfilt {
log.Infof("No operation - same filter applied ('%s').", newfilt)
// This is a hack to avoid displaying an error in the following situation. The user loads
// a pcap and applies a filter. Then they hit clear-packets. The filter is still shown.
// Then they run clear-filter. That will attempt to apply a new filter, but the loader's
// record of the filter is cleared, and the new filter to apply is also clear, so they
// are the same, so this error is shown.
if newfilt != "" {
HandleError(NoneCode, app, fmt.Errorf("Same filter - nothing to do."), cb)
}
} else {
c.stopTail()
c.stopLoadPsml()
Expand Down
6 changes: 5 additions & 1 deletion ui/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -2933,7 +2933,11 @@ func Build() (*gowid.App, error) {
})

validFilterCb := gowid.MakeWidgetCallback("cb", func(app gowid.IApp, w gowid.IWidget) {
RequestNewFilter(FilterWidget.Value(), app)
if Loader.DisplayFilter() == FilterWidget.Value() {
OpenError("Same filter - nothing to do", app)
} else {
RequestNewFilter(FilterWidget.Value(), app)
}
})

// Will only be enabled to click if filter is valid
Expand Down

0 comments on commit 4d16242

Please sign in to comment.