Documentation
¶
Overview ¶
Package extcap implements library to help create cli app for capture by Wireshark using extcap interface (https://www.wireshark.org/docs/wsdg_html_chunked/ChCaptureExtcap.html). For flags parsing, package urfave/cli is used (https://github.com/urfave/cli)
For minimal application should be implemented following functions:
GetInterfaces: GetDLT: StartCapture:
Full working example for Talos Linux can be found at https://github.com/lion7/talosdump
Index ¶
- Variables
- type App
- type CaptureInterface
- type ConfigBoolOpt
- type ConfigIntegerOpt
- func (c *ConfigIntegerOpt) Default(val int) *ConfigIntegerOpt
- func (c *ConfigIntegerOpt) Group(group string) *ConfigIntegerOpt
- func (c *ConfigIntegerOpt) Range(min, max int) *ConfigIntegerOpt
- func (c *ConfigIntegerOpt) Required(val bool) *ConfigIntegerOpt
- func (c *ConfigIntegerOpt) String() string
- func (c *ConfigIntegerOpt) Tooltip(tooltip string) *ConfigIntegerOpt
- type ConfigOption
- type ConfigStringOpt
- func (c *ConfigStringOpt) Default(val string) *ConfigStringOpt
- func (c *ConfigStringOpt) Placeholder(str string) *ConfigStringOpt
- func (c *ConfigStringOpt) Required(val bool) *ConfigStringOpt
- func (c *ConfigStringOpt) String() string
- func (c *ConfigStringOpt) Tooltip(tooltip string) *ConfigStringOpt
- func (c *ConfigStringOpt) Validation(str string) *ConfigStringOpt
- type DLT
- type VersionInfo
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNoInterfaceSpecified is returned when start capture is called without specifying an interface // also returned when querying configuration options or supported DLTs without specifying an interface ErrNoInterfaceSpecified = errors.New("no interface specified") // ErrNoPipeProvided is returned when start capture is called without providing the FIFO pipe to write to ErrNoPipeProvided = errors.New("no FIFO pipe provided") )
Functions ¶
This section is empty.
Types ¶
type App ¶
type App struct {
// Application brief description
Usage string
// Application help description
HelpPage string
// AdditionalHelp will be displayed in version output.
Version VersionInfo
// Usage examples to display in USAGE section of help output.
// Every string will be prepended with <application-name>
// By default, the following usage example is always added:
// --extcap-interfaces
//
// As an example, adding the following lines with application name 'ciscodump':
// --extcap-interface=ciscodump --extcap-dlts
// --extcap-interface=ciscodump --extcap-config
// --extcap-interface=ciscodump --remote-host myhost --remote-port 22222 --remote-username myuser --remote-interface gigabit0/0 --fifo=FILENAME --capture
// will produce the following output:
// ciscodump --extcap-interfaces
// ciscodump --extcap-interface=ciscodump --extcap-dlts
// ciscodump --extcap-interface=ciscodump --extcap-config
// ciscodump --extcap-interface=ciscodump --remote-host myhost --remote-port 22222 --remote-username myuser --remote-interface gigabit0/0 --fifo=FILENAME --capture
UsageExamples []string
// GetInterfaces returns list of interfaces. Should be implemented.
GetInterfaces func() ([]CaptureInterface, error)
// GetDLT returns DLT for given interface. Should be implemented.
GetDLT func(iface string) (DLT, error)
// GetConfigOptions returns configuration parameters for given interface. Optional.
GetConfigOptions func(iface string) ([]ConfigOption, error)
// GetAllConfigOptions returns all possible configuration options. Optional (interfaces do not have any configuration options).
GetAllConfigOptions func() []ConfigOption
// VerifyCaptureFilter verifies if the provided filter is valid. Optional.
VerifyCaptureFilter func(filter string) error
// StartCapture starts capture process. Should be implemented. Opts are the configuration options for capture on given interface.
StartCapture func(iface string, fifo io.WriteCloser, filter string, opts map[string]interface{}) error
// OpenPipe opens fifo pipe to write capture results. If it is not defined then default is used.
OpenPipe func(string) (io.WriteCloser, error)
}
App is the main structure of an extcap application.
type CaptureInterface ¶
CaptureInterface represents single network interface for capture
func (CaptureInterface) String ¶
func (iface CaptureInterface) String() string
Format to string in format interface {value=example1}{display=Example interface 1 for extcap}
type ConfigBoolOpt ¶
type ConfigBoolOpt struct {
// contains filtered or unexported fields
}
ConfigBoolOpt implements ConfigOption interface
func NewConfigBoolOpt ¶
func NewConfigBoolOpt(call, display string) *ConfigBoolOpt
NewConfigBoolOpt Create new BOOL option
func (*ConfigBoolOpt) Default ¶
func (c *ConfigBoolOpt) Default(val bool) *ConfigBoolOpt
Default sets default value option
func (*ConfigBoolOpt) Required ¶
func (c *ConfigBoolOpt) Required(val bool) *ConfigBoolOpt
Required sets option required
func (*ConfigBoolOpt) String ¶
func (c *ConfigBoolOpt) String() string
String implements string interface arg {number=2}{call=--verify}{display=Verify}{tooltip=Verify package content}{type=boolflag}
func (*ConfigBoolOpt) Tooltip ¶
func (c *ConfigBoolOpt) Tooltip(tooltip string) *ConfigBoolOpt
Tooltip sets option tooltip
type ConfigIntegerOpt ¶
type ConfigIntegerOpt struct {
// contains filtered or unexported fields
}
ConfigIntegerOpt Integer option
func NewConfigIntegerOpt ¶
func NewConfigIntegerOpt(call, display string) *ConfigIntegerOpt
NewConfigIntegerOpt Create new integer option
func (*ConfigIntegerOpt) Default ¶
func (c *ConfigIntegerOpt) Default(val int) *ConfigIntegerOpt
Default sets default value for INTEGER option
func (*ConfigIntegerOpt) Group ¶
func (c *ConfigIntegerOpt) Group(group string) *ConfigIntegerOpt
Group sets option's group
func (*ConfigIntegerOpt) Range ¶
func (c *ConfigIntegerOpt) Range(min, max int) *ConfigIntegerOpt
Range sets min and max value for option
func (*ConfigIntegerOpt) Required ¶
func (c *ConfigIntegerOpt) Required(val bool) *ConfigIntegerOpt
Required sets option required
func (*ConfigIntegerOpt) String ¶
func (c *ConfigIntegerOpt) String() string
String implements stringer interface Example output
arg {number=0}{call=--delay}{display=Time delay}{tooltip=Time delay between packages}{type=integer}{range=1,15}{required=true}
func (*ConfigIntegerOpt) Tooltip ¶
func (c *ConfigIntegerOpt) Tooltip(tooltip string) *ConfigIntegerOpt
Tooltip sets option tooltip
type ConfigOption ¶
type ConfigOption interface {
// contains filtered or unexported methods
}
ConfigOption represents config options which will be shown in Wireshark GUI Output examples arg {number=0}{call=--delay}{display=Time delay}{tooltip=Time delay between packages}{type=integer}{range=1,15}{required=true} arg {number=1}{call=--message}{display=Message}{tooltip=Package message content}{placeholder=Please enter a message here ...}{type=string} arg {number=2}{call=--verify}{display=Verify}{tooltip=Verify package content}{type=boolflag} arg {number=3}{call=--remote}{display=Remote Channel}{tooltip=Remote Channel Selector}{type=selector} arg {number=4}{call=--server}{display=IP address for log server}{type=string}{validation=\\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\b} value {arg=3}{value=if1}{display=Remote1}{default=true} value {arg=3}{value=if2}{display=Remote2}{default=false}
type ConfigStringOpt ¶
type ConfigStringOpt struct {
// contains filtered or unexported fields
}
ConfigStringOpt implements ConfigOption interface
func NewConfigStringOpt ¶
func NewConfigStringOpt(call, display string) *ConfigStringOpt
NewConfigStringOpt Create new STRING option
func (*ConfigStringOpt) Default ¶
func (c *ConfigStringOpt) Default(val string) *ConfigStringOpt
Default sets default value for STRING option
func (*ConfigStringOpt) Placeholder ¶
func (c *ConfigStringOpt) Placeholder(str string) *ConfigStringOpt
Placeholder sets option tooltip
func (*ConfigStringOpt) Required ¶
func (c *ConfigStringOpt) Required(val bool) *ConfigStringOpt
Required sets option required
func (*ConfigStringOpt) String ¶
func (c *ConfigStringOpt) String() string
String implements string interface arg {number=0}{call=--server}{display=IP address for log server}{type=string}{validation=\\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\b}
func (*ConfigStringOpt) Tooltip ¶
func (c *ConfigStringOpt) Tooltip(tooltip string) *ConfigStringOpt
Tooltip sets option tooltip
func (*ConfigStringOpt) Validation ¶
func (c *ConfigStringOpt) Validation(str string) *ConfigStringOpt
Validation sets option validation
type VersionInfo ¶
func (VersionInfo) String ¶
func (ver VersionInfo) String() string
Format to string in format extcap {version=0.1.0}{help=<some help or URL}