channel

package
v1.7.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 15, 2023 License: Apache-2.0 Imports: 13 Imported by: 56

Documentation

Index

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 GetPidsByLocalPort(ctx context.Context, channel spec.Channel, localPort string) ([]string, error)

func IsAllCommandsAvailable added in v1.6.0

func IsAllCommandsAvailable(ctx context.Context, channel spec.Channel, commandNames []string) (*spec.Response, bool)

func NewLocalChannel

func NewLocalChannel() spec.Channel

NewLocalChannel returns a local channel for invoking the host command

func NewMockLocalChannel added in v0.6.0

func NewMockLocalChannel() spec.Channel

func NewNSExecChannel added in v1.6.0

func NewNSExecChannel() spec.Channel

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 (l *LocalChannel) GetPidsByLocalPort(ctx context.Context, localPort string) ([]string, error)

func (*LocalChannel) GetPidsByLocalPorts added in v0.6.0

func (l *LocalChannel) GetPidsByLocalPorts(ctx context.Context, localPorts []string) ([]string, error)

func (*LocalChannel) GetPidsByProcessCmdName added in v0.6.0

func (l *LocalChannel) GetPidsByProcessCmdName(processName string, ctx context.Context) ([]string, error)

func (*LocalChannel) GetPidsByProcessName added in v0.6.0

func (l *LocalChannel) GetPidsByProcessName(processName string, ctx context.Context) ([]string, error)

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)

func (*LocalChannel) Run

func (l *LocalChannel) Run(ctx context.Context, script, args string) *spec.Response

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 (mlc *MockLocalChannel) GetPidsByLocalPort(ctx context.Context, localPort string) ([]string, error)

func (*MockLocalChannel) GetPidsByLocalPorts added in v0.6.0

func (mlc *MockLocalChannel) GetPidsByLocalPorts(ctx context.Context, localPorts []string) ([]string, error)

func (*MockLocalChannel) GetPidsByProcessCmdName added in v0.6.0

func (mlc *MockLocalChannel) GetPidsByProcessCmdName(processName string, ctx context.Context) ([]string, error)

func (*MockLocalChannel) GetPidsByProcessName added in v0.6.0

func (mlc *MockLocalChannel) GetPidsByProcessName(processName string, ctx context.Context) ([]string, error)

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 (mlc *MockLocalChannel) IsAllCommandsAvailable(ctx context.Context, commandNames []string) (*spec.Response, bool)

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)

func (*MockLocalChannel) Run

func (mlc *MockLocalChannel) Run(ctx context.Context, script, args string) *spec.Response

type NSExecChannel added in v1.6.0

type NSExecChannel struct {
	LocalChannel
}

func (*NSExecChannel) GetPidsByLocalPort added in v1.6.0

func (l *NSExecChannel) GetPidsByLocalPort(ctx context.Context, localPort string) ([]string, error)

func (*NSExecChannel) GetPidsByProcessCmdName added in v1.6.0

func (l *NSExecChannel) GetPidsByProcessCmdName(processName string, ctx context.Context) ([]string, error)

func (*NSExecChannel) GetPidsByProcessName added in v1.6.0

func (l *NSExecChannel) GetPidsByProcessName(processName string, ctx context.Context) ([]string, error)

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 (l *NSExecChannel) IsAllCommandsAvailable(ctx context.Context, commandNames []string) (*spec.Response, bool)

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

func (*NSExecChannel) Run added in v1.6.0

func (l *NSExecChannel) Run(ctx context.Context, script, args string) *spec.Response

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL