device

package
v2.4.0 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2025 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetAllIPv4Devices

func GetAllIPv4Devices() ([]string, map[string]net.IP)

获取所有IPv4网卡信息

func LookUpIP

func LookUpIP(fqdn, serverAddr string) (net.IP, error)

LookUpIP 使用指定DNS服务器查询域名并返回IP地址

func PcapInit

func PcapInit(devicename string) (*pcap.Handle, error)

PcapInit 初始化pcap句柄

func PrintDeviceInfo

func PrintDeviceInfo(ether *EtherTable)

打印设备信息

func ValidDNS

func ValidDNS(dns string) bool

Types

type EtherTable

type EtherTable struct {
	SrcIp  net.IP  `yaml:"src_ip"`  // 源IP地址
	Device string  `yaml:"device"`  // 网卡设备名称
	SrcMac SelfMac `yaml:"src_mac"` // 源MAC地址
	DstMac SelfMac `yaml:"dst_mac"` // 目标MAC地址(通常是网关)
}

EtherTable 存储网卡信息的数据结构

func AutoGetDevices

func AutoGetDevices(userDNS []string) (*EtherTable, error)

func AutoGetDevicesWithDNS

func AutoGetDevicesWithDNS(validDNS []string) *EtherTable

AutoGetDevicesWithDNS 使用指定DNS自动获取外网发包网卡 如果传入的DNS无效,则尝试使用系统DNS

func ReadConfig

func ReadConfig(filename string) (*EtherTable, error)

ReadConfig 从文件读取EtherTable配置

func (*EtherTable) SaveConfig

func (e *EtherTable) SaveConfig(filename string) error

SaveConfig 保存EtherTable配置到文件

type SelfMac

type SelfMac net.HardwareAddr

func (SelfMac) HardwareAddr

func (d SelfMac) HardwareAddr() net.HardwareAddr

func (SelfMac) MarshalYAML

func (d SelfMac) MarshalYAML() (interface{}, error)

func (SelfMac) String

func (d SelfMac) String() string

func (*SelfMac) UnmarshalYAML

func (d *SelfMac) UnmarshalYAML(value *yaml.Node) error

Jump to

Keyboard shortcuts

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