Documentation
¶
Index ¶
- func ResolveGatewayMAC(ctx context.Context, iface *net.Interface, localIP, gwIP net.IP) (net.HardwareAddr, error)
- type BPFInstruction
- type Handle
- type LinuxHandle
- func (h *LinuxHandle) ClearBPF() error
- func (h *LinuxHandle) Close()
- func (h *LinuxHandle) LinkType() layers.LinkType
- func (h *LinuxHandle) ReadPacketData() ([]byte, gopacket.CaptureInfo, error)
- func (h *LinuxHandle) SetBPFRawInstructionFilter(raw []BPFInstruction) error
- func (h *LinuxHandle) WritePacketData(data []byte) error
- type Sniffer
- type TCPSniffer
- type TCPWriter
- type UDPSniffer
- type UDPWriter
- type Writer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Handle ¶
type Handle interface {
// ReadPacketData reads the next packet from the wire.
ReadPacketData() (data []byte, ci gopacket.CaptureInfo, err error)
// WritePacketData sends a raw packet.
WritePacketData(data []byte) error
SetBPFRawInstructionFilter(filters []BPFInstruction) error
ClearBPF() error
LinkType() layers.LinkType
// Close closes the handle.
Close()
}
Handle is a common interface for both afpacket (Linux) and pcap (Others)
type LinuxHandle ¶
type LinuxHandle struct {
// contains filtered or unexported fields
}
LinuxHandle uses standard syscalls (via x/sys/unix) to capture/inject packets. This ensures compatibility across all Linux architectures (including 386/MIPS).
func (*LinuxHandle) Close ¶
func (h *LinuxHandle) Close()
func (*LinuxHandle) LinkType ¶
func (h *LinuxHandle) LinkType() layers.LinkType
func (*LinuxHandle) ReadPacketData ¶
func (h *LinuxHandle) ReadPacketData() ([]byte, gopacket.CaptureInfo, error)
ReadPacketData reads using unix.Recvfrom
func (*LinuxHandle) SetBPFRawInstructionFilter ¶
func (h *LinuxHandle) SetBPFRawInstructionFilter(raw []BPFInstruction) error
SetBPFRawInstructionFilter attaches BPF using unix helper
func (*LinuxHandle) WritePacketData ¶
func (h *LinuxHandle) WritePacketData(data []byte) error
WritePacketData injects packet using unix.Sendto
type TCPSniffer ¶
type TCPSniffer struct {
// contains filtered or unexported fields
}
func NewTCPSniffer ¶
func (*TCPSniffer) GetOptimalTTL ¶
func (ts *TCPSniffer) GetOptimalTTL(key netutil.IPKey) uint8
GetOptimalTTL retrieves the estimated hop count for a given key from the cache.
func (*TCPSniffer) Register ¶ added in v1.5.2
func (ts *TCPSniffer) Register(addrs []net.IP)
Register registers new IP addresses for hop-count learning. Addresses that are already being tracked are ignored.
func (*TCPSniffer) StartCapturing ¶
func (ts *TCPSniffer) StartCapturing()
StartCapturing begins monitoring for SYN/ACK packets in a background goroutine.
type TCPWriter ¶
type TCPWriter struct {
// contains filtered or unexported fields
}
func NewTCPWriter ¶
type UDPSniffer ¶
type UDPSniffer struct {
// contains filtered or unexported fields
}
func NewUDPSniffer ¶
func (*UDPSniffer) GetOptimalTTL ¶
func (us *UDPSniffer) GetOptimalTTL(key netutil.IPKey) uint8
GetOptimalTTL retrieves the estimated hop count for a given key from the cache.
func (*UDPSniffer) Register ¶ added in v1.5.2
func (us *UDPSniffer) Register(addrs []net.IP)
Register registers new IP addresses for hop-count learning. Addresses that are already being tracked are ignored.
func (*UDPSniffer) StartCapturing ¶
func (us *UDPSniffer) StartCapturing()
StartCapturing begins monitoring for UDP packets in a background goroutine.
type UDPWriter ¶
type UDPWriter struct {
// contains filtered or unexported fields
}