hooks

package
v0.9.1-alpha Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2023 License: Apache-2.0 Imports: 36 Imported by: 0

README

Hooks Package Documentation

The hooks package contains the user-space Go code responsible for loading eBPF hooks and eBPF maps, which are used to instrument the user API. This package is utilized by the CLI commands. Additionally, it launches proxies on a range of local ports to capture egress calls.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Emoji = "\U0001F430" + " Keploy:"
View Source
var PerfEventReaders []*perf.Reader
View Source
var RingEventReaders []*ringbuf.Reader

Functions

func LaunchPerfBufferConsumers

func LaunchPerfBufferConsumers(objs bpfObjects, connectionFactory *connection.Factory, stopper chan os.Signal, logger *zap.Logger)

LaunchPerfBufferConsumers launches socket events

func LogAny

func LogAny(value string) error

LogAny appends input of any type to a logs.txt file in the current directory

Types

type Hook

type Hook struct {
	platform.TestCaseDB
	// contains filtered or unexported fields
}

func NewHook

func NewHook(path string, db platform.TestCaseDB, logger *zap.Logger) *Hook

func (*Hook) AppendMocks

func (h *Hook) AppendMocks(m *models.Mock) error

func (*Hook) CleanProxyEntry

func (h *Hook) CleanProxyEntry(srcPort uint16)

func (*Hook) FetchDep

func (h *Hook) FetchDep(indx int) *models.Mock

func (*Hook) GetConfigMocks

func (h *Hook) GetConfigMocks() []*models.Mock

func (*Hook) GetDepsSize

func (h *Hook) GetDepsSize() int

func (*Hook) GetDestinationInfo

func (h *Hook) GetDestinationInfo(srcPort uint16) (*structs.DestInfo, error)

func (*Hook) GetResp

func (h *Hook) GetResp() *models.HttpResp

func (*Hook) GetTcsMocks

func (h *Hook) GetTcsMocks() []*models.Mock

func (*Hook) GetUserIP

func (h *Hook) GetUserIP() string

to access the IP address of the hook

func (*Hook) IsDockerRelatedCmd

func (h *Hook) IsDockerRelatedCmd(cmd string) (bool, string)

It checks if the cmd is related to docker or not, it also returns if its a docker compose file

func (*Hook) LaunchUserApplication

func (h *Hook) LaunchUserApplication(appCmd, appContainer, appNetwork string, Delay uint64) error

func (*Hook) LoadHooks

func (h *Hook) LoadHooks(appCmd, appContainer string) error

LoadHooks is used to attach the eBPF hooks into the linux kernel. Hooks are attached for outgoing and incoming network requests.

proxyPorts is used for redirecting outgoing network calls to the unoccupied proxy server.

$BPF_CLANG and $BPF_CFLAGS are set by the Makefile.

func (*Hook) PopFront

func (h *Hook) PopFront()

func (*Hook) PrintRedirectProxyMap

func (h *Hook) PrintRedirectProxyMap()

// printing the whole map

func (*Hook) PutResp

func (h *Hook) PutResp(resp *models.HttpResp) error

func (*Hook) ResetDeps

func (h *Hook) ResetDeps() int

func (*Hook) SendKeployPid

func (h *Hook) SendKeployPid(kPid uint32) error

func (*Hook) SendNameSpaceId

func (h *Hook) SendNameSpaceId(key uint32, inode uint64) error

This function is helpful when user application in running inside a docker container.

func (*Hook) SendProxyInfo

func (h *Hook) SendProxyInfo(ip4, port uint32, ip6 [4]uint32) error

This function sends the IP and Port of the running proxy in the eBPF program.

func (*Hook) SetConfigMocks

func (h *Hook) SetConfigMocks(m []*models.Mock)

func (*Hook) SetKeployModeInKernel

func (h *Hook) SetKeployModeInKernel(mode uint32)

func (*Hook) SetTcsMocks

func (h *Hook) SetTcsMocks(m []*models.Mock)

func (*Hook) Stop

func (h *Hook) Stop(forceStop bool)

func (*Hook) StopUserApplication

func (h *Hook) StopUserApplication()

StopUserApplication stops the user application

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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