Documentation
¶
Overview ¶
Package pinger - 平台能力接口定义 定义了跨平台的权限检测和pinger创建接口
Package pinger 配置定义 ¶
Package pinger - Linux非特权模式实现 使用SOCK_DGRAM类型的ICMP套接字,仅适用于Linux系统
Package pinger 选项模式支持 ¶
Package pinger 实现了core.DataSource接口,提供ping功能 根据操作系统和用户权限自动选择最合适的底层实现
Package pinger - 特权模式实现 使用原始套接字,需要管理员/root权限,但支持所有操作系统
Index ¶
- func GetImplementationType() string
- func GetOSName() string
- func GetPrivilegeStatus() string
- func GetSystemInfo() (osName, privilegeStatus, implementationType string)
- func HasPrivilegedAccess() bool
- func NewPinger(targets []string, config *Config) (core.DataSource, error)
- func NewPingerWithOptions(targets []string, opts ...Option) (core.DataSource, error)
- type Config
- type Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetSystemInfo ¶
func GetSystemInfo() (osName, privilegeStatus, implementationType string)
GetSystemInfo 获取完整的系统信息 返回操作系统名称、权限状态和实现类型
func NewPinger ¶
func NewPinger(targets []string, config *Config) (core.DataSource, error)
NewPinger 创建新的Pinger实例
func NewPingerWithOptions ¶
func NewPingerWithOptions(targets []string, opts ...Option) (core.DataSource, error)
NewPingerWithOptions 使用选项模式创建Pinger
Types ¶
type Config ¶
type Config struct {
IPVersion int // IP版本,4或6
Interval time.Duration // ping间隔时间
Timeout time.Duration // ping超时时间
BufferSize int // 数据通道缓冲区大小
}
Config pinger组件的配置结构
func (*Config) GetIPProtocol ¶
GetIPProtocol 获取IP协议字符串,用于网络操作
func (*Config) ValidateTargets ¶
ValidateTargets 验证目标地址是否符合当前IP版本配置
Click to show internal directories.
Click to hide internal directories.