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 ¶ added in v1.6.0
func IsAllCommandsAvailable ¶ added in v1.6.0
func NewLocalChannel ¶
NewLocalChannel returns a local channel for invoking the host command
func NewMockLocalChannel ¶ added in v0.6.0
func NewNSExecChannel ¶ added in v1.6.0
Types ¶
type LocalChannel ¶
type LocalChannel struct { }
func (*LocalChannel) GetPidUser ¶ added in v0.6.0
func (l *LocalChannel) GetPidUser(pid string) (string, error)
func (*LocalChannel) GetPidsByLocalPort ¶ added in v0.6.0
func (*LocalChannel) GetPidsByLocalPorts ¶ added in v0.6.0
func (*LocalChannel) GetPidsByProcessCmdName ¶ added in v0.6.0
func (*LocalChannel) GetPidsByProcessName ¶ added in v0.6.0
func (*LocalChannel) GetPsArgs ¶ added in v0.6.0
func (l *LocalChannel) GetPsArgs(ctx context.Context) string
func (*LocalChannel) GetScriptPath ¶
func (l *LocalChannel) GetScriptPath() string
func (*LocalChannel) IsAllCommandsAvailable ¶ added in v1.2.0
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 ¶ added in v1.6.0
func (l *LocalChannel) IsAlpinePlatform(ctx context.Context) bool
func (*LocalChannel) IsCommandAvailable ¶ added in v0.6.0
func (l *LocalChannel) IsCommandAvailable(ctx context.Context, commandName string) bool
func (*LocalChannel) Name ¶ added in v1.6.0
func (l *LocalChannel) Name() string
func (*LocalChannel) ProcessExists ¶ added in v0.6.0
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 ¶ added in v0.6.0
func (mlc *MockLocalChannel) GetPidUser(pid string) (string, error)
func (*MockLocalChannel) GetPidsByLocalPort ¶ added in v0.6.0
func (*MockLocalChannel) GetPidsByLocalPorts ¶ added in v0.6.0
func (*MockLocalChannel) GetPidsByProcessCmdName ¶ added in v0.6.0
func (*MockLocalChannel) GetPidsByProcessName ¶ added in v0.6.0
func (*MockLocalChannel) GetPsArgs ¶ added in v0.6.0
func (mlc *MockLocalChannel) GetPsArgs(ctx context.Context) string
func (*MockLocalChannel) GetScriptPath ¶
func (mlc *MockLocalChannel) GetScriptPath() string
func (*MockLocalChannel) IsAllCommandsAvailable ¶ added in v1.2.0
func (*MockLocalChannel) IsAlpinePlatform ¶ added in v1.6.0
func (mlc *MockLocalChannel) IsAlpinePlatform(ctx context.Context) bool
func (*MockLocalChannel) IsCommandAvailable ¶ added in v0.6.0
func (mlc *MockLocalChannel) IsCommandAvailable(ctx context.Context, commandName string) bool
func (*MockLocalChannel) Name ¶ added in v1.6.0
func (l *MockLocalChannel) Name() string
func (*MockLocalChannel) ProcessExists ¶ added in v0.6.0
func (mlc *MockLocalChannel) ProcessExists(pid string) (bool, error)
type NSExecChannel ¶ added in v1.6.0
type NSExecChannel struct {
LocalChannel
}
func (*NSExecChannel) GetPidsByLocalPort ¶ added in v1.6.0
func (*NSExecChannel) GetPidsByProcessCmdName ¶ added in v1.6.0
func (*NSExecChannel) GetPidsByProcessName ¶ added in v1.6.0
func (*NSExecChannel) GetPsArgs ¶ added in v1.6.0
func (l *NSExecChannel) GetPsArgs(ctx context.Context) string
func (*NSExecChannel) IsAllCommandsAvailable ¶ added in v1.6.0
func (*NSExecChannel) IsAlpinePlatform ¶ added in v1.6.0
func (l *NSExecChannel) IsAlpinePlatform(ctx context.Context) bool
func (*NSExecChannel) IsCommandAvailable ¶ added in v1.6.0
func (l *NSExecChannel) IsCommandAvailable(ctx context.Context, commandName string) bool
func (*NSExecChannel) Name ¶ added in v1.6.0
func (l *NSExecChannel) Name() string
Click to show internal directories.
Click to hide internal directories.