els0r / goProbe

High-performance IP packet metadata aggregation and efficient storage and querying of flows
GNU General Public License v2.0
12 stars 4 forks source link

Rework / update bash autocompletion #214

Open fako1024 opened 1 year ago

fako1024 commented 1 year ago

After the v4 release it is highly likely that there are a few things missing from the bash autocompletion we have / had in place (untested, but likely). In addition there is an OSAG-specific piece of code in pkg/util regarding network tunnels (which seems to be solely used for bash autocompletion) that uses an OSAG build tag (and by default does nothing). IMHO we should get rid of all non-public code in this repo (or write it in a way that it can work everywhere / for everyone).

DoD

fako1024 commented 1 year ago

@els0r What are your thoughts on this one? I do fully understand that you might want the tunnel interface completion for OSAG, but maybe that's something that others are interested in, too. Can that be generalized maybe?

els0r commented 1 year ago

@els0r What are your thoughts on this one? I do fully understand that you might want the tunnel interface completion for OSAG, but maybe that's something that others are interested in, too. Can that be generalized maybe?

Heya. I've raised this internally as well. And had a brief look at auto-completion. Depending on how you want to see it, the completion half works (or is half working).

We could have third parties register actions upon interface resolution: meaning by default, only the name will be completed. If an action is compiled into the binary with a build tag, additional actions can be triggered (such as hostname resolution for tunnel interfaces).

fako1024 commented 1 year ago

Sounds good, although I don't think we'll need build tags for that. I suggest to do as you say (support autocomplete on names (you might be able to use the existing facilities to get all interfaces from slimcap, which is a lot faster that net.GetInterfaces()) and allow everyone to register additional callbacks using e.g. a global function like RegisterAutocompleteCallback(fn func(...) error) that can act upon the instance and that can be used to add whatever functionality is needed (similar to what prometheus does).

els0r commented 1 year ago

Thanks for the suggestions. I'm on board with the proposal. Maybe @silvanbitterli can have a look.