Documentation
¶
Index ¶
- func ListenPacket(network string, laddr string) (net.PacketConn, error)
- type ICMPSpec
- type PacketListener
- type ReceivedMessage
- type TCPSpec
- func (s *TCPSpec) Close()
- func (s *TCPSpec) InitICMP()
- func (s *TCPSpec) InitTCP()
- func (s *TCPSpec) ListenICMP(ctx context.Context, ready chan struct{}, ...)
- func (s *TCPSpec) ListenTCP(ctx context.Context, ready chan struct{}, ...)
- func (s *TCPSpec) SendTCP(ctx context.Context, ipHdr gopacket.NetworkLayer, tcpHdr *layers.TCP, ...) (time.Time, error)
- type UDPSpec
- func (s *UDPSpec) Close()
- func (s *UDPSpec) InitICMP()
- func (s *UDPSpec) InitUDP()
- func (s *UDPSpec) ListenICMP(ctx context.Context, ready chan struct{}, ...)
- func (s *UDPSpec) ListenOut(_ context.Context, _ chan struct{}, ...)
- func (s *UDPSpec) SendUDP(ctx context.Context, ipHdr ipLayer, udpHdr *layers.UDP, payload []byte) (time.Time, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ListenPacket ¶ added in v1.5.0
func ListenPacket(network string, laddr string) (net.PacketConn, error)
Types ¶
type ICMPSpec ¶ added in v1.5.0
type ICMPSpec struct {
IPVersion int
ICMPMode int
EchoID int
SrcIP net.IP
DstIP net.IP
SourceDevice string
// contains filtered or unexported fields
}
func NewICMPSpec ¶ added in v1.5.0
func (*ICMPSpec) ListenICMP ¶ added in v1.5.0
type PacketListener ¶ added in v1.5.0
type PacketListener struct {
Conn net.PacketConn
Messages <-chan ReceivedMessage
// contains filtered or unexported fields
}
PacketListener 负责监听网络数据包并通过通道传递接收到的消息 对外暴露只读的 Messages,避免外部代码误写
func NewPacketListener ¶ added in v1.5.0
func NewPacketListener(conn net.PacketConn) *PacketListener
NewPacketListener 创建一个新的数据包监听器 conn: 用于接收数据包的连接 返回初始化好的 PacketListener 实例
func (*PacketListener) Start ¶ added in v1.5.0
func (l *PacketListener) Start(ctx context.Context)
type ReceivedMessage ¶ added in v1.5.0
type TCPSpec ¶ added in v1.5.0
type TCPSpec struct {
IPVersion int
ICMPMode int
SrcIP net.IP
DstIP net.IP
DstPort int
PktSize int
SourceDevice string
// contains filtered or unexported fields
}
func NewTCPSpec ¶ added in v1.5.0
func (*TCPSpec) ListenICMP ¶ added in v1.5.0
type UDPSpec ¶ added in v1.5.0
type UDPSpec struct {
IPVersion int
ICMPMode int
SrcIP net.IP
DstIP net.IP
DstPort int
SourceDevice string
// contains filtered or unexported fields
}
func NewUDPSpec ¶ added in v1.5.0
func (*UDPSpec) ListenICMP ¶ added in v1.5.0
Click to show internal directories.
Click to hide internal directories.