Documentation ¶
Index ¶
- Constants
- func GetPidsByLocalPort(ctx context.Context, channel spec.Channel, localPort string) ([]string, error)
- func IsAllCommandsAvailable(ctx context.Context, channel spec.Channel, commandNames []string) (*spec.Response, bool)
- func NewLocalChannel() spec.Channel
- func NewMockLocalChannel() spec.Channel
- func NewNSExecChannel() spec.Channel
- type LocalChannel
- func (l *LocalChannel) GetPidUser(pid string) (string, error)
- func (l *LocalChannel) GetPidsByLocalPort(ctx context.Context, localPort string) ([]string, error)
- func (l *LocalChannel) GetPidsByLocalPorts(ctx context.Context, localPorts []string) ([]string, error)
- func (l *LocalChannel) GetPidsByProcessCmdName(processName string, ctx context.Context) ([]string, error)
- func (l *LocalChannel) GetPidsByProcessName(processName string, ctx context.Context) ([]string, error)
- func (l *LocalChannel) GetPsArgs(ctx context.Context) string
- func (l *LocalChannel) GetScriptPath() string
- func (l *LocalChannel) IsAllCommandsAvailable(ctx context.Context, commandNames []string) (*spec.Response, bool)
- func (l *LocalChannel) IsAlpinePlatform(ctx context.Context) bool
- func (l *LocalChannel) IsCommandAvailable(ctx context.Context, commandName string) bool
- func (l *LocalChannel) Name() string
- func (l *LocalChannel) ProcessExists(pid string) (bool, error)
- func (l *LocalChannel) Run(ctx context.Context, script, args string) *spec.Response
- type MockLocalChannel
- func (mlc *MockLocalChannel) GetPidUser(pid string) (string, error)
- func (mlc *MockLocalChannel) GetPidsByLocalPort(ctx context.Context, localPort string) ([]string, error)
- func (mlc *MockLocalChannel) GetPidsByLocalPorts(ctx context.Context, localPorts []string) ([]string, error)
- func (mlc *MockLocalChannel) GetPidsByProcessCmdName(processName string, ctx context.Context) ([]string, error)
- func (mlc *MockLocalChannel) GetPidsByProcessName(processName string, ctx context.Context) ([]string, error)
- func (mlc *MockLocalChannel) GetPsArgs(ctx context.Context) string
- func (mlc *MockLocalChannel) GetScriptPath() string
- func (mlc *MockLocalChannel) IsAllCommandsAvailable(ctx context.Context, commandNames []string) (*spec.Response, bool)
- func (mlc *MockLocalChannel) IsAlpinePlatform(ctx context.Context) bool
- func (mlc *MockLocalChannel) IsCommandAvailable(ctx context.Context, commandName string) bool
- func (l *MockLocalChannel) Name() string
- func (mlc *MockLocalChannel) ProcessExists(pid string) (bool, error)
- func (mlc *MockLocalChannel) Run(ctx context.Context, script, args string) *spec.Response
- type NSExecChannel
- func (l *NSExecChannel) GetPidsByLocalPort(ctx context.Context, localPort string) ([]string, error)
- func (l *NSExecChannel) GetPidsByProcessCmdName(processName string, ctx context.Context) ([]string, error)
- func (l *NSExecChannel) GetPidsByProcessName(processName string, ctx context.Context) ([]string, error)
- func (l *NSExecChannel) GetPsArgs(ctx context.Context) string
- func (l *NSExecChannel) IsAllCommandsAvailable(ctx context.Context, commandNames []string) (*spec.Response, bool)
- func (l *NSExecChannel) IsAlpinePlatform(ctx context.Context) bool
- func (l *NSExecChannel) IsCommandAvailable(ctx context.Context, commandName string) bool
- func (l *NSExecChannel) Name() string
- func (l *NSExecChannel) Run(ctx context.Context, script, args string) *spec.Response
Constants ¶
View Source
const ( NSTargetFlagName = "ns_target" NSPidFlagName = "ns_pid" NSMntFlagName = "ns_mnt" NSNetFlagName = "ns_net" )
View Source
const ExcludeProcessKey = "excludeProcess"
View Source
const ProcessCommandKey = "processCommand"
View Source
const ProcessKey = "process"
grep ${key}
Variables ¶
This section is empty.
Functions ¶
func GetPidsByLocalPort ¶
func IsAllCommandsAvailable ¶
func NewLocalChannel ¶
NewLocalChannel returns a local channel for invoking the host command
func NewMockLocalChannel ¶
func NewNSExecChannel ¶
Types ¶
type LocalChannel ¶
type LocalChannel struct { }
func (*LocalChannel) GetPidUser ¶
func (l *LocalChannel) GetPidUser(pid string) (string, error)
func (*LocalChannel) GetPidsByLocalPort ¶
func (*LocalChannel) GetPidsByLocalPorts ¶
func (*LocalChannel) GetPidsByProcessCmdName ¶
func (*LocalChannel) GetPidsByProcessName ¶
func (*LocalChannel) GetScriptPath ¶
func (l *LocalChannel) GetScriptPath() string
func (*LocalChannel) IsAllCommandsAvailable ¶
func (l *LocalChannel) IsAllCommandsAvailable(ctx context.Context, commandNames []string) (*spec.Response, bool)
check command is available or not now, all commands are: ["rm", "dd" ,"touch", "mkdir", "echo", "kill", ,"mv","mount", "umount","tc", "head" "grep", "cat", "iptables", "sed", "awk", "tar"]
func (*LocalChannel) IsAlpinePlatform ¶
func (l *LocalChannel) IsAlpinePlatform(ctx context.Context) bool
func (*LocalChannel) IsCommandAvailable ¶
func (l *LocalChannel) IsCommandAvailable(ctx context.Context, commandName string) bool
func (*LocalChannel) Name ¶
func (l *LocalChannel) Name() string
func (*LocalChannel) ProcessExists ¶
func (l *LocalChannel) ProcessExists(pid string) (bool, error)
type MockLocalChannel ¶
type MockLocalChannel struct { ScriptPath string // mock function RunFunc func(ctx context.Context, script, args string) *spec.Response GetPidsByProcessCmdNameFunc func(processName string, ctx context.Context) ([]string, error) GetPidsByProcessNameFunc func(processName string, ctx context.Context) ([]string, error) GetPsArgsFunc func(ctx context.Context) string IsCommandAvailableFunc func(ctx context.Context, commandName string) bool ProcessExistsFunc func(pid string) (bool, error) GetPidUserFunc func(pid string) (string, error) GetPidsByLocalPortsFunc func(ctx context.Context, localPorts []string) ([]string, error) GetPidsByLocalPortFunc func(ctx context.Context, localPort string) ([]string, error) }
MockLocalChannel for testing
func (*MockLocalChannel) GetPidUser ¶
func (mlc *MockLocalChannel) GetPidUser(pid string) (string, error)
func (*MockLocalChannel) GetPidsByLocalPort ¶
func (*MockLocalChannel) GetPidsByLocalPorts ¶
func (*MockLocalChannel) GetPidsByProcessCmdName ¶
func (*MockLocalChannel) GetPidsByProcessName ¶
func (*MockLocalChannel) GetPsArgs ¶
func (mlc *MockLocalChannel) GetPsArgs(ctx context.Context) string
func (*MockLocalChannel) GetScriptPath ¶
func (mlc *MockLocalChannel) GetScriptPath() string
func (*MockLocalChannel) IsAllCommandsAvailable ¶
func (*MockLocalChannel) IsAlpinePlatform ¶
func (mlc *MockLocalChannel) IsAlpinePlatform(ctx context.Context) bool
func (*MockLocalChannel) IsCommandAvailable ¶
func (mlc *MockLocalChannel) IsCommandAvailable(ctx context.Context, commandName string) bool
func (*MockLocalChannel) Name ¶
func (l *MockLocalChannel) Name() string
func (*MockLocalChannel) ProcessExists ¶
func (mlc *MockLocalChannel) ProcessExists(pid string) (bool, error)
type NSExecChannel ¶
type NSExecChannel struct {
LocalChannel
}
func (*NSExecChannel) GetPidsByLocalPort ¶
func (*NSExecChannel) GetPidsByProcessCmdName ¶
func (*NSExecChannel) GetPidsByProcessName ¶
func (*NSExecChannel) IsAllCommandsAvailable ¶
func (*NSExecChannel) IsAlpinePlatform ¶
func (l *NSExecChannel) IsAlpinePlatform(ctx context.Context) bool
func (*NSExecChannel) IsCommandAvailable ¶
func (l *NSExecChannel) IsCommandAvailable(ctx context.Context, commandName string) bool
func (*NSExecChannel) Name ¶
func (l *NSExecChannel) Name() string
Click to show internal directories.
Click to hide internal directories.