Documentation
¶
Overview ¶
Package executor provides the CommandExecutor interface and implementations for running Wireshark CLI tools (tshark, capinfos, editcap, mergecap). RealExecutor calls actual binaries; MockExecutor enables testing without Wireshark installed.
Index ¶
Constants ¶
const DefaultTimeout = 60 * time.Second
DefaultTimeout is the maximum execution time for any single command.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CommandExecutor ¶
type CommandExecutor interface {
// Execute runs a CLI command and returns stdout, stderr, and any error.
Execute(ctx context.Context, binary string, args []string) (stdout []byte, stderr []byte, err error)
// BinaryPath resolves the full path to a Wireshark CLI tool.
// Supports: tshark, capinfos, editcap, mergecap, dumpcap.
BinaryPath(name string) (string, error)
}
CommandExecutor is the primary port for executing Wireshark CLI tools. All tool handlers depend on this interface, enabling testing without real tshark binaries installed.
type MockExecutor ¶
type MockExecutor struct {
// Responses maps "binary args..." to a mock response.
Responses map[string]MockResponse
// Calls records all executed commands for assertions.
Calls []MockCall
// DefaultResponse is returned when no matching response is found.
DefaultResponse *MockResponse
}
MockExecutor is a test double for CommandExecutor. Set the response fields before calling Execute.
func NewMockExecutor ¶
func NewMockExecutor() *MockExecutor
NewMockExecutor creates a mock executor with an empty response map.
func (*MockExecutor) BinaryPath ¶
func (m *MockExecutor) BinaryPath(name string) (string, error)
type MockResponse ¶
MockResponse holds canned output for a mocked command.
type RealExecutor ¶
type RealExecutor struct {
// contains filtered or unexported fields
}
RealExecutor executes commands against real Wireshark CLI binaries.
func NewRealExecutor ¶
func NewRealExecutor(logger *slog.Logger, wiresharkDir string) *RealExecutor
NewRealExecutor creates a new executor that runs real CLI commands.
func (*RealExecutor) BinaryPath ¶
func (e *RealExecutor) BinaryPath(name string) (string, error)