Documentation
¶
Index ¶
- Variables
- func CanRestart(src IPacketSource) bool
- func HandleBegin(code HandlerCode, app gowid.IApp, cb interface{}) bool
- func HandleEnd(code HandlerCode, app gowid.IApp, cb interface{}) bool
- func HandleError(code HandlerCode, app gowid.IApp, err error, cb interface{}) bool
- func HandleUnpack(code HandlerCode, cb interface{}, handler unpackedHandlerFunc, app gowid.IApp) bool
- func MakeUsefulError(cmd IBasicCommand, err error) gowid.KeyValueError
- func SnappyMe(p interface{}, w io.Writer)
- func SourcesNames(srcs []IPacketSource) []string
- func SourcesString(srcs []IPacketSource) string
- func TempPcapFile(tokens ...string) string
- func UIName(src IPacketSource) string
- func UnsnappyMe(res interface{}, r io.Reader)
- type CacheEntry
- type Command
- func (c *Command) Close() error
- func (c *Command) Kill() error
- func (c *Command) Pid() int
- func (c *Command) PutInNewGroupOnUnix()
- func (c *Command) SetStdout(w io.Writer)
- func (c *Command) Start() error
- func (c *Command) StderrSummary() []string
- func (c *Command) StdoutReader() (io.ReadCloser, error)
- func (c *Command) String() string
- func (c *Command) Wait() error
- type Commands
- func (c Commands) Iface(ifaces []string, captureFilter string, tmpfile string) IBasicCommand
- func (c Commands) Pcap(pcap string, displayFilter string) IPcapCommand
- func (c Commands) Pdml(pcap string, displayFilter string) IPcapCommand
- func (c Commands) Psml(pcap interface{}, displayFilter string) IPcapCommand
- func (c Commands) Tail(tmpfile string) ITailCommand
- type FifoSource
- type FileSource
- type GzippedPdmlPacket
- type HandlerCode
- type HandlerList
- type IAfterEnd
- type IBasicCommand
- type IBeforeBegin
- type IClear
- type ILoaderCmds
- type IMainRunner
- type INewSource
- type IOnError
- type IPacketSource
- type IPcapCommand
- type IPdmlPacket
- type IPsmlHeader
- type ISourceRemover
- type ITailCommand
- type IUnpack
- type InterfaceLoader
- type InterfaceSource
- type LoadPcapSlice
- type LoaderState
- type Options
- type PacketColors
- type PacketLoader
- func (c *PacketLoader) ClearPcap(cb interface{})
- func (c *PacketLoader) LoadInterfaces(psrcs []IPacketSource, captureFilter string, displayFilter string, ...) error
- func (c *PacketLoader) LoadPcap(pcap string, displayFilter string, cb interface{}, app gowid.IApp)
- func (c *PacketLoader) Reload(filter string, cb interface{}, app gowid.IApp)
- func (c *PacketLoader) Renew()
- type ParentLoader
- func (p *ParentLoader) CaptureFilter() string
- func (c *ParentLoader) CloseMain()
- func (p *ParentLoader) Commands() ILoaderCmds
- func (p *ParentLoader) Context() context.Context
- func (p *ParentLoader) DisplayFilter() string
- func (c *ParentLoader) Empty() bool
- func (p *ParentLoader) InterfaceFile() string
- func (c *ParentLoader) Interfaces() []string
- func (p *ParentLoader) LoadWasCancelled() bool
- func (p *ParentLoader) LoadingAnything() bool
- func (p *ParentLoader) MainRun(fn gowid.RunFunction)
- func (p *ParentLoader) PacketSources() []IPacketSource
- func (c *ParentLoader) Pcap() string
- func (p *ParentLoader) PsmlStoppedDeliberately() bool
- func (c *ParentLoader) RenewIfaceLoader()
- func (c *ParentLoader) RenewPdmlLoader()
- func (c *ParentLoader) RenewPsmlLoader()
- func (c *ParentLoader) StopLoadPsmlAndIface(cb interface{})
- func (c *ParentLoader) String() string
- func (p *ParentLoader) TailStoppedDeliberately() bool
- func (p *ParentLoader) TurnOffPipe()
- type PdmlLoader
- type PdmlPacket
- type PipeSource
- type ProcessNotStarted
- type ProcessState
- type PsmlLoader
- func (c *PsmlLoader) CacheAt(row int) (CacheEntry, bool)
- func (c *PsmlLoader) DoWithPsmlData(fn func([][]string))
- func (c *PsmlLoader) IsLoading() bool
- func (p *PsmlLoader) LengthOfPcapCacheEntry(row int) (int, error)
- func (p *PsmlLoader) LengthOfPdmlCacheEntry(row int) (int, error)
- func (c *PsmlLoader) NumLoaded() int
- func (c *PsmlLoader) PacketCacheFn() *lru.Cache
- func (p *PsmlLoader) PacketsPerLoad() int
- func (p *PsmlLoader) PsmlAverageLengths() []gwutil.IntOption
- func (p *PsmlLoader) PsmlColors() []PacketColors
- func (p *PsmlLoader) PsmlData() [][]string
- func (p *PsmlLoader) PsmlHeaders() []string
- func (p *PsmlLoader) PsmlMaxLengths() []int
- func (c *PsmlLoader) ReadingFromFifo() bool
- func (c *PsmlLoader) StartStage2ChanFn() chan struct{}
- type RunFn
- type Runner
- type SnappiedPdmlPacket
- type TemporaryFileSource
Constants ¶
This section is empty.
Variables ¶
var Goroutinewg *sync.WaitGroup
var OpsChan chan gowid.RunFunction
Functions ¶
func CanRestart ¶
func CanRestart(src IPacketSource) bool
func HandleBegin ¶
func HandleBegin(code HandlerCode, app gowid.IApp, cb interface{}) bool
func HandleError ¶
func HandleError(code HandlerCode, app gowid.IApp, err error, cb interface{}) bool
func HandleUnpack ¶
func HandleUnpack(code HandlerCode, cb interface{}, handler unpackedHandlerFunc, app gowid.IApp) bool
func MakeUsefulError ¶
func MakeUsefulError(cmd IBasicCommand, err error) gowid.KeyValueError
func SourcesNames ¶
func SourcesNames(srcs []IPacketSource) []string
func SourcesString ¶
func SourcesString(srcs []IPacketSource) string
func TempPcapFile ¶
func UIName ¶
func UIName(src IPacketSource) string
func UnsnappyMe ¶
UnsnappyMe decompresses from reader r into res. Afterwards, res will be an interface whose type is a pointer to whatever was serialized in the first place.
Types ¶
type CacheEntry ¶
type CacheEntry struct { Pdml []IPdmlPacket Pcap [][]byte PdmlComplete bool PcapComplete bool }
func (CacheEntry) Complete ¶
func (c CacheEntry) Complete() bool
type Command ¶
func (*Command) Close ¶
If stdout supports Close(), call it. If stdout is a pipe, for example, this can be used to have EOF appear on the reading side (e.g. tshark -T psml)
func (*Command) PutInNewGroupOnUnix ¶
func (c *Command) PutInNewGroupOnUnix()
func (*Command) StderrSummary ¶
func (*Command) StdoutReader ¶
func (c *Command) StdoutReader() (io.ReadCloser, error)
type Commands ¶
type Commands struct { DecodeAs []string Args []string PdmlArgs []string PsmlArgs []string Color bool }
func MakeCommands ¶
func (Commands) Iface ¶
func (c Commands) Iface(ifaces []string, captureFilter string, tmpfile string) IBasicCommand
func (Commands) Psml ¶
func (c Commands) Psml(pcap interface{}, displayFilter string) IPcapCommand
func (Commands) Tail ¶
func (c Commands) Tail(tmpfile string) ITailCommand
type FifoSource ¶
type FifoSource struct {
Filename string
}
func (FifoSource) IsFifo ¶
func (p FifoSource) IsFifo() bool
func (FifoSource) IsFile ¶
func (p FifoSource) IsFile() bool
func (FifoSource) IsInterface ¶
func (p FifoSource) IsInterface() bool
func (FifoSource) IsPipe ¶
func (p FifoSource) IsPipe() bool
func (FifoSource) Name ¶
func (p FifoSource) Name() string
func (FifoSource) String ¶
func (p FifoSource) String() string
type FileSource ¶
type FileSource struct {
Filename string
}
func (FileSource) IsFifo ¶
func (p FileSource) IsFifo() bool
func (FileSource) IsFile ¶
func (p FileSource) IsFile() bool
func (FileSource) IsInterface ¶
func (p FileSource) IsInterface() bool
func (FileSource) IsPipe ¶
func (p FileSource) IsPipe() bool
func (FileSource) Name ¶
func (p FileSource) Name() string
func (FileSource) String ¶
func (p FileSource) String() string
type GzippedPdmlPacket ¶
func (GzippedPdmlPacket) Packet ¶
func (p GzippedPdmlPacket) Packet() PdmlPacket
func (GzippedPdmlPacket) Uncompress ¶
func (p GzippedPdmlPacket) Uncompress() PdmlPacket
type HandlerCode ¶
type HandlerCode int
const ( NoneCode HandlerCode = 1 << iota PdmlCode PsmlCode TailCode IfaceCode ConvCode StreamCode CapinfoCode )
type HandlerList ¶
type HandlerList []interface{}
func (HandlerList) Unpack ¶
func (h HandlerList) Unpack() []interface{}
type IAfterEnd ¶
type IAfterEnd interface {
AfterEnd(code HandlerCode, app gowid.IApp)
}
type IBasicCommand ¶
type IBeforeBegin ¶
type IBeforeBegin interface {
BeforeBegin(code HandlerCode, app gowid.IApp)
}
type IClear ¶
type IClear interface {
OnClear(code HandlerCode, app gowid.IApp)
}
type ILoaderCmds ¶
type ILoaderCmds interface { Iface(ifaces []string, captureFilter string, tmpfile string) IBasicCommand Tail(tmpfile string) ITailCommand Psml(pcap interface{}, displayFilter string) IPcapCommand Pcap(pcap string, displayFilter string) IPcapCommand Pdml(pcap string, displayFilter string) IPcapCommand }
var PcapCmds ILoaderCmds
type IMainRunner ¶
type IMainRunner interface {
Run(fn gowid.RunFunction)
}
IMainRunner is implemented by a type that runs a closure on termshark's main loop (via gowid's App.Run)
type INewSource ¶
type INewSource interface {
OnNewSource(code HandlerCode, app gowid.IApp)
}
type IPacketSource ¶
type IPacketSource interface { Name() string IsFile() bool IsInterface() bool IsFifo() bool IsPipe() bool }
func FileSystemSources ¶
func FileSystemSources(srcs []IPacketSource) []IPacketSource
type IPcapCommand ¶
type IPcapCommand interface { IBasicCommand StdoutReader() (io.ReadCloser, error) // termshark will .Read() from result }
type IPdmlPacket ¶
type IPdmlPacket interface {
Packet() PdmlPacket
}
func GzipPdmlPacket ¶
func GzipPdmlPacket(p PdmlPacket) IPdmlPacket
func SnappyPdmlPacket ¶
func SnappyPdmlPacket(p PdmlPacket) IPdmlPacket
type IPsmlHeader ¶
type IPsmlHeader interface {
OnPsmlHeader(code HandlerCode, app gowid.IApp)
}
type ISourceRemover ¶
type ISourceRemover interface {
Remove() error
}
type ITailCommand ¶
type ITailCommand interface { IBasicCommand SetStdout(io.Writer) // set to the write side of a fifo, for example - the command will .Write() here Close() error // closes stdout, which signals tshark -T psml }
type InterfaceLoader ¶
func (*InterfaceLoader) IsLoading ¶
func (c *InterfaceLoader) IsLoading() bool
type InterfaceSource ¶
type InterfaceSource struct {
Iface string
}
func (InterfaceSource) IsFifo ¶
func (p InterfaceSource) IsFifo() bool
func (InterfaceSource) IsFile ¶
func (p InterfaceSource) IsFile() bool
func (InterfaceSource) IsInterface ¶
func (p InterfaceSource) IsInterface() bool
func (InterfaceSource) IsPipe ¶
func (p InterfaceSource) IsPipe() bool
func (InterfaceSource) Name ¶
func (p InterfaceSource) Name() string
func (InterfaceSource) String ¶
func (p InterfaceSource) String() string
type LoadPcapSlice ¶
func ProcessPdmlRequests ¶
func ProcessPdmlRequests(requests []LoadPcapSlice, mloader *ParentLoader, loader *PdmlLoader, cb interface{}, app gowid.IApp) []LoadPcapSlice
func (LoadPcapSlice) String ¶
func (m LoadPcapSlice) String() string
type LoaderState ¶
type LoaderState bool
const ( NotLoading LoaderState = false Loading LoaderState = true )
func (LoaderState) String ¶
func (t LoaderState) String() string
type PacketLoader ¶
type PacketLoader struct {
*ParentLoader
}
PacketLoader supports swapping out loaders
func (*PacketLoader) ClearPcap ¶
func (c *PacketLoader) ClearPcap(cb interface{})
Intended to restart iface loader - since a clear will discard all data up to here.
func (*PacketLoader) LoadInterfaces ¶
func (c *PacketLoader) LoadInterfaces(psrcs []IPacketSource, captureFilter string, displayFilter string, tmpfile string, cb interface{}, app gowid.IApp) error
Always called from app goroutine context - so don't need to protect for race on cancelfn Assumes gstate is ready iface can be a number, or a fifo, or a pipe...
func (*PacketLoader) LoadPcap ¶
func (c *PacketLoader) LoadPcap(pcap string, displayFilter string, cb interface{}, app gowid.IApp)
func (*PacketLoader) Reload ¶
func (c *PacketLoader) Reload(filter string, cb interface{}, app gowid.IApp)
func (*PacketLoader) Renew ¶
func (c *PacketLoader) Renew()
Renew is called when a new pcap is loaded from an open termshark session i.e. termshark was started with one packet source, then a new one is selected. This ensures that all connected loaders that might still be doing work are cancelled.
type ParentLoader ¶
type ParentLoader struct { // Note that a nil InterfaceLoader implies this loader is not handling a "live" packet source *InterfaceLoader // these are only replaced from the main goroutine, so no lock needed *PsmlLoader *PdmlLoader // contains filtered or unexported fields }
func NewPcapLoader ¶
func NewPcapLoader(cmds ILoaderCmds, runner IMainRunner, opts ...Options) *ParentLoader
func (*ParentLoader) CaptureFilter ¶
func (p *ParentLoader) CaptureFilter() string
func (*ParentLoader) CloseMain ¶
func (c *ParentLoader) CloseMain()
CloseMain shuts down the whole loader, including progress monitoring goroutines. Use this only when about to load a new pcap (use a new loader)
func (*ParentLoader) Commands ¶
func (p *ParentLoader) Commands() ILoaderCmds
func (*ParentLoader) Context ¶
func (p *ParentLoader) Context() context.Context
func (*ParentLoader) DisplayFilter ¶
func (p *ParentLoader) DisplayFilter() string
func (*ParentLoader) Empty ¶
func (c *ParentLoader) Empty() bool
func (*ParentLoader) InterfaceFile ¶
func (p *ParentLoader) InterfaceFile() string
func (*ParentLoader) Interfaces ¶
func (c *ParentLoader) Interfaces() []string
func (*ParentLoader) LoadWasCancelled ¶
func (p *ParentLoader) LoadWasCancelled() bool
func (*ParentLoader) LoadingAnything ¶
func (p *ParentLoader) LoadingAnything() bool
func (*ParentLoader) MainRun ¶
func (p *ParentLoader) MainRun(fn gowid.RunFunction)
func (*ParentLoader) PacketSources ¶
func (p *ParentLoader) PacketSources() []IPacketSource
func (*ParentLoader) Pcap ¶
func (c *ParentLoader) Pcap() string
func (*ParentLoader) PsmlStoppedDeliberately ¶
func (p *ParentLoader) PsmlStoppedDeliberately() bool
func (*ParentLoader) RenewIfaceLoader ¶
func (c *ParentLoader) RenewIfaceLoader()
func (*ParentLoader) RenewPdmlLoader ¶
func (c *ParentLoader) RenewPdmlLoader()
func (*ParentLoader) RenewPsmlLoader ¶
func (c *ParentLoader) RenewPsmlLoader()
func (*ParentLoader) StopLoadPsmlAndIface ¶
func (c *ParentLoader) StopLoadPsmlAndIface(cb interface{})
func (*ParentLoader) String ¶
func (c *ParentLoader) String() string
func (*ParentLoader) TailStoppedDeliberately ¶
func (p *ParentLoader) TailStoppedDeliberately() bool
func (*ParentLoader) TurnOffPipe ¶
func (p *ParentLoader) TurnOffPipe()
type PdmlLoader ¶
type PdmlLoader struct { PcapPdml string // Pcap file source for the pdml reader - tmpfile if iface; pcap otherwise PcapPcap string // Pcap file source for the pcap reader - tmpfile if iface; pcap otherwise Stage2FinishedChan chan struct{} // closed when entire pdml+pcap load process is done PdmlPid int // 0 if process not started PcapPid int // 0 if process not started sync.Mutex KillAfterReadingThisMany int // A shortcut - tell pcap/pdml to read one - no lock worked out yet // contains filtered or unexported fields }
func (*PdmlLoader) IsLoading ¶
func (c *PdmlLoader) IsLoading() bool
func (*PdmlLoader) LoadIsVisible ¶
func (c *PdmlLoader) LoadIsVisible() bool
type PdmlPacket ¶
func (PdmlPacket) Packet ¶
func (p PdmlPacket) Packet() PdmlPacket
type PipeSource ¶
func (PipeSource) Close ¶
func (p PipeSource) Close() error
func (PipeSource) IsFifo ¶
func (p PipeSource) IsFifo() bool
func (PipeSource) IsFile ¶
func (p PipeSource) IsFile() bool
func (PipeSource) IsInterface ¶
func (p PipeSource) IsInterface() bool
func (PipeSource) IsPipe ¶
func (p PipeSource) IsPipe() bool
func (PipeSource) Name ¶
func (p PipeSource) Name() string
func (PipeSource) String ¶
func (p PipeSource) String() string
type ProcessNotStarted ¶
func (ProcessNotStarted) Error ¶
func (e ProcessNotStarted) Error() string
type ProcessState ¶
type ProcessState int
const ( NotStarted ProcessState = 0 Started ProcessState = 1 Terminated ProcessState = 2 )
func (ProcessState) String ¶
func (p ProcessState) String() string
type PsmlLoader ¶
type PsmlLoader struct { PcapPsml interface{} // Pcap file source for the psml reader - fifo if iface+!stopped; tmpfile if iface+stopped; pcap otherwise PsmlFinishedChan chan struct{} // closed when entire psml load process is done PsmlCmd IPcapCommand // gcla later todo - change to pid like PdmlPid sync.Mutex PacketNumberMap map[int]int // map from actual packet row <packet>12</packet> to pos in unsorted table // This would be affected by a display filter e.g. packet 12 might be the 1st packet in the table. // I need this so that if the user jumps to a mark stored as "packet 12", I can find the right table row. PacketNumberOrder map[int]int // e.g. {12->44, 44->71, 71->72,...} - the packet numbers, in order, affected by a filter. PacketCache *lru.Cache // i -> [pdml(i * 1000)..pdml(i+1*1000)] - accessed from any goroutine // contains filtered or unexported fields }
func (*PsmlLoader) CacheAt ¶
func (c *PsmlLoader) CacheAt(row int) (CacheEntry, bool)
func (*PsmlLoader) DoWithPsmlData ¶
func (c *PsmlLoader) DoWithPsmlData(fn func([][]string))
func (*PsmlLoader) IsLoading ¶
func (c *PsmlLoader) IsLoading() bool
func (*PsmlLoader) LengthOfPcapCacheEntry ¶
func (p *PsmlLoader) LengthOfPcapCacheEntry(row int) (int, error)
func (*PsmlLoader) LengthOfPdmlCacheEntry ¶
func (p *PsmlLoader) LengthOfPdmlCacheEntry(row int) (int, error)
func (*PsmlLoader) NumLoaded ¶
func (c *PsmlLoader) NumLoaded() int
func (*PsmlLoader) PacketCacheFn ¶
func (c *PsmlLoader) PacketCacheFn() *lru.Cache
func (*PsmlLoader) PacketsPerLoad ¶
func (p *PsmlLoader) PacketsPerLoad() int
func (*PsmlLoader) PsmlAverageLengths ¶
func (p *PsmlLoader) PsmlAverageLengths() []gwutil.IntOption
func (*PsmlLoader) PsmlColors ¶
func (p *PsmlLoader) PsmlColors() []PacketColors
func (*PsmlLoader) PsmlData ¶
func (p *PsmlLoader) PsmlData() [][]string
func (*PsmlLoader) PsmlHeaders ¶
func (p *PsmlLoader) PsmlHeaders() []string
func (*PsmlLoader) PsmlMaxLengths ¶
func (p *PsmlLoader) PsmlMaxLengths() []int
func (*PsmlLoader) ReadingFromFifo ¶
func (c *PsmlLoader) ReadingFromFifo() bool
func (*PsmlLoader) StartStage2ChanFn ¶
func (c *PsmlLoader) StartStage2ChanFn() chan struct{}
type SnappiedPdmlPacket ¶
func (SnappiedPdmlPacket) Packet ¶
func (p SnappiedPdmlPacket) Packet() PdmlPacket
func (SnappiedPdmlPacket) Uncompress ¶
func (p SnappiedPdmlPacket) Uncompress() PdmlPacket
type TemporaryFileSource ¶
type TemporaryFileSource struct {
FileSource
}
func (TemporaryFileSource) Remove ¶
func (p TemporaryFileSource) Remove() error
func (TemporaryFileSource) String ¶
func (p TemporaryFileSource) String() string