Documentation
¶
Index ¶
- Constants
- type Endpoint
- type IPHeader
- type IPProtocol
- type IPVersion
- type Packet
- type PacketBase
- func (pkt *PacketBase) FmtPacket() string
- func (pkt *PacketBase) FmtProtocol() string
- func (pkt *PacketBase) FmtRemoteAddress() string
- func (pkt *PacketBase) FmtRemoteIP() string
- func (pkt *PacketBase) FmtRemotePort() string
- func (pkt *PacketBase) GetIPHeader() *IPHeader
- func (pkt *PacketBase) GetLinkID() string
- func (pkt *PacketBase) GetPayload() []byte
- func (pkt *PacketBase) GetTCPUDPHeader() *TCPUDPHeader
- func (pkt *PacketBase) IPVersion() IPVersion
- func (pkt *PacketBase) IsInbound() bool
- func (pkt *PacketBase) IsOutbound() bool
- func (pkt *PacketBase) MatchesAddress(endpoint bool, protocol IPProtocol, network *net.IPNet, port uint16) bool
- func (pkt *PacketBase) MatchesIP(endpoint bool, network *net.IPNet) bool
- func (pkt *PacketBase) SetInbound()
- func (pkt *PacketBase) SetOutbound()
- func (pkt *PacketBase) String() string
- type TCPUDPHeader
- 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 ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type IPHeader ¶
type IPHeader struct {
Version IPVersion
Tos, TTL uint8
Protocol IPProtocol
Src, Dst net.IP
}
type IPProtocol ¶
type IPProtocol uint8
func (IPProtocol) String ¶
func (p IPProtocol) String() string
type IPVersion ¶
type IPVersion uint8
type Packet ¶
type Packet interface {
// VERDICTS
Accept() error
Block() error
Drop() error
PermanentAccept() error
PermanentBlock() error
PermanentDrop() error
RerouteToNameserver() error
RerouteToTunnel() error
// INFO
GetIPHeader() *IPHeader
GetTCPUDPHeader() *TCPUDPHeader
GetPayload() []byte
IsInbound() bool
IsOutbound() bool
SetInbound()
SetOutbound()
GetLinkID() string
IPVersion() IPVersion
// 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
type PacketBase ¶
type PacketBase struct {
Direction bool
InTunnel bool
Payload []byte
*IPHeader
*TCPUDPHeader
// contains filtered or unexported fields
}
func (*PacketBase) FmtPacket ¶
func (pkt *PacketBase) FmtPacket() string
FmtPacket returns the most important information about the packet as a string
func (*PacketBase) FmtProtocol ¶
func (pkt *PacketBase) FmtProtocol() string
FmtProtocol returns the protocol as a string
func (*PacketBase) FmtRemoteAddress ¶
func (pkt *PacketBase) FmtRemoteAddress() string
FmtRemoteAddress returns the full remote address (protocol, IP, port) as a string
func (*PacketBase) FmtRemoteIP ¶
func (pkt *PacketBase) FmtRemoteIP() string
FmtRemoteIP returns the remote IP address as a string
func (*PacketBase) FmtRemotePort ¶
func (pkt *PacketBase) FmtRemotePort() string
FmtRemotePort returns the remote port as a string
func (*PacketBase) GetIPHeader ¶
func (pkt *PacketBase) GetIPHeader() *IPHeader
func (*PacketBase) GetLinkID ¶
func (pkt *PacketBase) GetLinkID() string
func (*PacketBase) GetPayload ¶
func (pkt *PacketBase) GetPayload() []byte
func (*PacketBase) GetTCPUDPHeader ¶
func (pkt *PacketBase) GetTCPUDPHeader() *TCPUDPHeader
func (*PacketBase) IPVersion ¶
func (pkt *PacketBase) IPVersion() IPVersion
func (*PacketBase) IsInbound ¶
func (pkt *PacketBase) IsInbound() bool
func (*PacketBase) IsOutbound ¶
func (pkt *PacketBase) IsOutbound() bool
func (*PacketBase) MatchesAddress ¶
func (pkt *PacketBase) MatchesAddress(endpoint bool, protocol IPProtocol, network *net.IPNet, port uint16) bool
Matches checks if a the packet matches a given endpoint (remote or local) in protocol, network and port.
IN OUT
Local Dst Src Remote Src Dst
func (*PacketBase) MatchesIP ¶
func (pkt *PacketBase) MatchesIP(endpoint bool, network *net.IPNet) bool
func (*PacketBase) SetInbound ¶
func (pkt *PacketBase) SetInbound()
func (*PacketBase) SetOutbound ¶
func (pkt *PacketBase) SetOutbound()
func (*PacketBase) String ¶
func (pkt *PacketBase) String() string