Documentation
¶
Index ¶
- Constants
- Variables
- func FindProcessName(network string, srcIP netip.Addr, srcPort int) (uint32, string, error)
- func FindProcessNameByConn(conn net.Conn) (uint32, string, error)
- func IpToAddr(slice net.IP) netip.Addr
- type ConnectionsWatcher
- type NewRemoteIPCallback
- type OnProcessCreateFunc
- type OnProcessExitFunc
- type ProcessBasicInfo
- type ProcessInfo
- type ProcessesWatcher
- func (pw *ProcessesWatcher) DetectProcessConnections(pid int32, limit int) ([]net.ConnectionStat, error)
- func (pw *ProcessesWatcher) DetectPublicProcessConnections(pid int32, limit int) ([]net.ConnectionStat, error)
- func (pw *ProcessesWatcher) GetAllProcesses() ([]*process.Process, error)
- func (pw *ProcessesWatcher) Start(ctx context.Context, onProcessCreate OnProcessCreateFunc, ...)
- func (pw *ProcessesWatcher) Stop()
Constants ¶
View Source
const ( TCP = "tcp" UDP = "udp" )
View Source
const (
SOCK_DIAG_BY_FAMILY = 20
)
Variables ¶
Functions ¶
func FindProcessName ¶
Types ¶
type ConnectionsWatcher ¶
type ConnectionsWatcher struct {
Pid int32
Proc *process.Process
// contains filtered or unexported fields
}
ConnectionsWatcher 封装了针对单个进程的监控逻辑
func NewWatcher ¶
func NewWatcher(pid int32, cb NewRemoteIPCallback, interval time.Duration) (*ConnectionsWatcher, error)
NewWatcher 创建一个新的进程监控器实例
func (*ConnectionsWatcher) Start ¶
func (w *ConnectionsWatcher) Start(ctx context.Context)
Start 启动监控循环,直到 Context 被取消或进程退出
type NewRemoteIPCallback ¶
NewRemoteIPCallback 是发现新外联 IP 时的回调函数签名
type OnProcessCreateFunc ¶
type OnProcessCreateFunc func(ctx context.Context, p *ProcessBasicInfo)
type OnProcessExitFunc ¶
type OnProcessExitFunc func(ctx context.Context, p *ProcessBasicInfo)
OnProcessExitFunc 是进程退出时的回调函数类型
type ProcessBasicInfo ¶
func NewProcessBasicInfo ¶
func NewProcessBasicInfo(p *process.Process) (*ProcessBasicInfo, error)
type ProcessInfo ¶
func List ¶
func List() ([]*ProcessInfo, error)
func (*ProcessInfo) GetRemoteNonLocalIPAddresses ¶
func (p *ProcessInfo) GetRemoteNonLocalIPAddresses() ([]string, error)
type ProcessesWatcher ¶
type ProcessesWatcher struct {
// contains filtered or unexported fields
}
func NewProcessesWatcher ¶
func NewProcessesWatcher() *ProcessesWatcher
NewProcessesWatcher 创建并初始化一个新的进程监控器
func (*ProcessesWatcher) DetectProcessConnections ¶
func (pw *ProcessesWatcher) DetectProcessConnections(pid int32, limit int) ([]net.ConnectionStat, error)
func (*ProcessesWatcher) DetectPublicProcessConnections ¶
func (pw *ProcessesWatcher) DetectPublicProcessConnections(pid int32, limit int) ([]net.ConnectionStat, error)
func (*ProcessesWatcher) GetAllProcesses ¶
func (pw *ProcessesWatcher) GetAllProcesses() ([]*process.Process, error)
GetAllProcesses 获取当前系统所有进程的信息快照
func (*ProcessesWatcher) Start ¶
func (pw *ProcessesWatcher) Start(ctx context.Context, onProcessCreate OnProcessCreateFunc, onProcessExit OnProcessExitFunc, checkInterval time.Duration)
Start 启动进程监控. onProcessCreate: 匹配的进程出现时的回调. onProcessExit: 匹配的进程消失时的回调. checkInterval: 扫描进程列表的时间间隔.
Click to show internal directories.
Click to hide internal directories.