routerhandler

package
v0.11.1 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("process not found")

ErrNotFound is returned when no process can be found for a connection.

Functions

This section is empty.

Types

type CachedSearcher

type CachedSearcher struct {
	// contains filtered or unexported fields
}

CachedSearcher wraps a Searcher with an LRU cache for connection lookups.

func NewCachedSearcher

func NewCachedSearcher(inner Searcher, size int, ttl time.Duration) *CachedSearcher

NewCachedSearcher creates a CachedSearcher with the given capacity and TTL.

func (*CachedSearcher) Close

func (c *CachedSearcher) Close() error

func (*CachedSearcher) FindProcessInfo

func (c *CachedSearcher) FindProcessInfo(ctx context.Context, network string, source, dest netip.AddrPort) (*ConnectionOwner, error)

type Config

type Config struct {
	Logger func(format string, args ...interface{})
}

Config holds optional settings for creating a Searcher.

type ConnectionOwner

type ConnectionOwner struct {
	ProcessID           uint32
	UserId              int32
	UserName            string
	ProcessPath         string
	AndroidPackageNames []string
}

ConnectionOwner represents the process that owns a network connection.

func FindProcessInfo

func FindProcessInfo(s Searcher, ctx context.Context, network string, source, dest netip.AddrPort) (*ConnectionOwner, error)

FindProcessInfo is a convenience wrapper that looks up the connection owner and fills in the UserName field from the OS if it's empty but UserId is set.

type ProcessNameMatcher

type ProcessNameMatcher struct {
	// contains filtered or unexported fields
}

ProcessNameMatcher matches if the ConnectionOwner's process basename is in the given list.

func NewProcessNameMatcher

func NewProcessNameMatcher(names []string) *ProcessNameMatcher

func (*ProcessNameMatcher) Match

func (m *ProcessNameMatcher) Match(owner *ConnectionOwner) bool

type ProcessPathMatcher

type ProcessPathMatcher struct {
	// contains filtered or unexported fields
}

ProcessPathMatcher matches if the ConnectionOwner's full process path is in the given list.

func NewProcessPathMatcher

func NewProcessPathMatcher(paths []string) *ProcessPathMatcher

func (*ProcessPathMatcher) Match

func (m *ProcessPathMatcher) Match(owner *ConnectionOwner) bool

type Searcher

type Searcher interface {
	FindProcessInfo(ctx context.Context, network string, source netip.AddrPort, dest netip.AddrPort) (*ConnectionOwner, error)
	Close() error
}

Searcher is the interface for finding which process owns a network connection.

func NewSearcher

func NewSearcher(config Config) (Searcher, error)

type UserIdMatcher

type UserIdMatcher struct {
	// contains filtered or unexported fields
}

UserIdMatcher matches if the ConnectionOwner's user ID is in the given list.

func NewUserIdMatcher

func NewUserIdMatcher(ids []int32) *UserIdMatcher

func (*UserIdMatcher) Match

func (m *UserIdMatcher) Match(owner *ConnectionOwner) bool

type UserMatcher

type UserMatcher struct {
	// contains filtered or unexported fields
}

UserMatcher matches if the ConnectionOwner's user name is in the given list.

func NewUserMatcher

func NewUserMatcher(users []string) *UserMatcher

func (*UserMatcher) Match

func (m *UserMatcher) Match(owner *ConnectionOwner) bool

Jump to

Keyboard shortcuts

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