Documentation ¶
Index ¶
- Constants
- Variables
- func Parse(packetData []byte, packet *Base) error
- type Base
- func (pkt *Base) Ctx() context.Context
- func (pkt *Base) FmtPacket() string
- func (pkt *Base) FmtProtocol() string
- func (pkt *Base) FmtRemoteAddress() string
- func (pkt *Base) FmtRemoteIP() string
- func (pkt *Base) FmtRemotePort() string
- func (pkt *Base) GetLinkID() string
- func (pkt *Base) GetPayload() ([]byte, error)
- func (pkt *Base) HasPorts() bool
- func (pkt *Base) Info() *Info
- func (pkt *Base) IsInbound() bool
- func (pkt *Base) IsOutbound() bool
- func (pkt *Base) MatchesAddress(remote bool, protocol IPProtocol, network *net.IPNet, port uint16) bool
- func (pkt *Base) MatchesIP(endpoint bool, network *net.IPNet) bool
- func (pkt *Base) SetCtx(ctx context.Context)
- func (pkt *Base) SetInbound()
- func (pkt *Base) SetOutbound()
- func (pkt *Base) SetPacketInfo(packetInfo Info)
- func (pkt *Base) String() string
- type Endpoint
- type IPProtocol
- type IPVersion
- type Info
- type Packet
- type Verdict
Constants ¶
const ( IPv4 = IPVersion(4) IPv6 = IPVersion(6) InBound = true OutBound = false Local = true Remote = false // convenience IGMP = IPProtocol(2) RAW = IPProtocol(255) TCP = IPProtocol(6) UDP = IPProtocol(17) ICMP = IPProtocol(1) ICMPv6 = IPProtocol(58) )
Variables ¶
var (
ErrFailedToLoadPayload = errors.New("could not load packet payload")
)
Functions ¶
Types ¶
type Base ¶ added in v0.2.5
type Base struct { Payload []byte // contains filtered or unexported fields }
Base is a base structure for satisfying the Packet interface.
func (*Base) FmtPacket ¶ added in v0.2.5
FmtPacket returns the most important information about the packet as a string
func (*Base) FmtProtocol ¶ added in v0.2.5
FmtProtocol returns the protocol as a string
func (*Base) FmtRemoteAddress ¶ added in v0.2.5
FmtRemoteAddress returns the full remote address (protocol, IP, port) as a string
func (*Base) FmtRemoteIP ¶ added in v0.2.5
FmtRemoteIP returns the remote IP address as a string
func (*Base) FmtRemotePort ¶ added in v0.2.5
FmtRemotePort returns the remote port as a string
func (*Base) GetPayload ¶ added in v0.2.5
GetPayload returns the packet payload. In some cases, this will fetch the payload from the os integration system.
func (*Base) HasPorts ¶ added in v0.2.5
HasPorts checks if the packet has a protocol that uses ports.
func (*Base) IsOutbound ¶ added in v0.2.5
IsOutbound checks if the packet is outbound.
func (*Base) MatchesAddress ¶ added in v0.2.5
func (pkt *Base) MatchesAddress(remote bool, protocol IPProtocol, network *net.IPNet, port uint16) bool
MatchesAddress checks if a the packet matches a given endpoint (remote or local) in protocol, network and port.
Comparison matrix:
IN OUT
Local Dst Src Remote Src Dst
func (*Base) MatchesIP ¶ added in v0.2.5
MatchesIP checks if a the packet matches a given endpoint (remote or local) IP.
Comparison matrix:
IN OUT
Local Dst Src Remote Src Dst
func (*Base) SetInbound ¶ added in v0.2.5
func (pkt *Base) SetInbound()
SetInbound sets a the packet direction to inbound. This must only used when initializing the packet structure.
func (*Base) SetOutbound ¶ added in v0.2.5
func (pkt *Base) SetOutbound()
SetOutbound sets a the packet direction to outbound. This must only used when initializing the packet structure.
func (*Base) SetPacketInfo ¶ added in v0.2.5
SetPacketInfo sets a new packet Info. This must only used when initializing the packet structure.
type IPProtocol ¶
type IPProtocol uint8
func (IPProtocol) String ¶
func (p IPProtocol) String() string
type IPVersion ¶
type IPVersion uint8
type Info ¶ added in v0.2.5
type Info struct { Direction bool InTunnel bool Version IPVersion Src, Dst net.IP Protocol IPProtocol SrcPort, DstPort uint16 }
Info holds IP and TCP/UDP header information
func (*Info) RemotePort ¶ added in v0.2.5
RemotePort returns the remote port of the packet.
type Packet ¶
type Packet interface { // VERDICTS Accept() error Block() error Drop() error PermanentAccept() error PermanentBlock() error PermanentDrop() error RerouteToNameserver() error RerouteToTunnel() error // INFO SetCtx(context.Context) Ctx() context.Context Info() *Info SetPacketInfo(Info) IsInbound() bool IsOutbound() bool SetInbound() SetOutbound() HasPorts() bool GetPayload() ([]byte, error) GetLinkID() string // MATCHING MatchesAddress(bool, IPProtocol, *net.IPNet, uint16) bool MatchesIP(bool, *net.IPNet) bool // FORMATTING String() string FmtPacket() string FmtProtocol() string FmtRemoteIP() string FmtRemotePort() string FmtRemoteAddress() string }
Packet is an interface to a network packet to provide object behaviour the same across all systems