netlib

package
v0.43.0 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ProtoInet  = "INET"
	ProtoInet6 = "INET6"
	ProtoIPv6  = "IPv6"
	ProtoIPv4  = "IPv4"

	ProtoUDP = "UDP"
	ProtoTCP = "TCP"

	SocketTCP  = "tcp"
	SocketUDP  = "udp"
	SocketUnix = "unix"
	SocketTLS  = "tcp+tls"
)
View Source
const (
	IPv6MinimumFragmentSize    = 1280
	IPv6MaximumSize            = 65535
	IPv6MaximumFragmentOffset  = 8189
	IPv6MaximumFragmentListLen = 52

	IPv4MinimumFragmentSize    = 8     // Minimum size of a single fragment
	IPv4MaximumSize            = 65535 // Maximum size of a fragment (2^16)
	IPv4MaximumFragmentOffset  = 8183  // Maximum offset of a fragment
	IPv4MaximumFragmentListLen = 8192  // Back out if we get more than this many fragments
)
View Source
const (
	IPv4ProtocolTCP      = layers.IPProtocolTCP
	IPv4ProtocolUDP      = layers.IPProtocolUDP
	IPv6ProtocolTCP      = layers.IPProtocolTCP
	IPv6ProtocolUDP      = layers.IPProtocolUDP
	IPv6ProtocolFragment = layers.IPProtocolIPv6Fragment
)

Variables

Functions

func Close added in v0.32.0

func Close(conn io.Closer, reset bool) error

thanks to https://stackoverflow.com/questions/28967701/golang-tcp-socket-cant-close-after-get-file, call conn.CloseRead() before calling conn.Close()

func GetPeerName added in v0.41.0

func GetPeerName(peerAddr string) string

GetPeerName returns the hostname associated with the given peer address. If the peer address cannot be split into IP and port or if the hostname lookup fails, it returns the peer address or IP itself.

func IPDefragger added in v0.39.0

func IPDefragger(ipInput chan gopacket.Packet, udpOutput chan gopacket.Packet, tcpOutput chan gopacket.Packet)

func SetSockRCVBUF added in v0.39.0

func SetSockRCVBUF(conn net.Conn, desired int, isTLS bool) (int, int, error)

Configure SO_RCVBUF, thanks to https://github.com/dmachard/go-dns-collector/issues/61#issuecomment-1201199895

func TCPAssembler added in v0.39.0

func TCPAssembler(tcpInput chan gopacket.Packet, dnsOutput chan DNSPacket, portFilter int)

func UDPProcessor added in v0.39.0

func UDPProcessor(udpInput chan gopacket.Packet, dnsOutput chan DNSPacket, portFilter int)

Types

type DNSPacket added in v0.39.0

type DNSPacket struct {
	// DNS payload
	Payload []byte
	// IP layer
	IPLayer gopacket.Flow
	// Transport layer
	TransportLayer gopacket.Flow
	// Timestamp
	Timestamp time.Time
	// IP Defragmented
	IPDefragmented bool
	// TCP reassembly
	TCPReassembled bool
}

DefragPacket is a struct that holds DNS data

type DNSStreamFactory added in v0.39.0

type DNSStreamFactory struct {
	// Channel to send reassembled DNS data
	Reassembled    chan DNSPacket
	IPDefragmented bool
}

func (*DNSStreamFactory) New added in v0.39.0

func (s *DNSStreamFactory) New(net, transport gopacket.Flow) tcpassembly.Stream

type IPDefragmenter added in v0.39.0

type IPDefragmenter struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewIPDefragmenter

func NewIPDefragmenter() *IPDefragmenter

func (*IPDefragmenter) DefragIP added in v0.39.0

func (d *IPDefragmenter) DefragIP(in gopacket.Packet) (gopacket.Packet, error)

func (*IPDefragmenter) DiscardOlderThan added in v0.39.0

func (d *IPDefragmenter) DiscardOlderThan(t time.Time) int

type NetDecoder

type NetDecoder struct{}

func (*NetDecoder) Decode

func (d *NetDecoder) Decode(data []byte, p gopacket.PacketBuilder) error

Jump to

Keyboard shortcuts

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