dispatch

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2018 License: GPL-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package dispatch provides dispatching of network/kernel events to various subscribers It provides an API for plugins to subscribe to for 3 types of network events 1) NFqueue (netfilter queue) packets 2) Conntrack events (New, Update, Destroy) 3) Netlogger events (from NFLOG target) The dispatch will register global callbacks with the kernel package and then dispatch events to subscribers accordingly

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AttachNfqueueSubscriptions

func AttachNfqueueSubscriptions(session *SessionEntry)

AttachNfqueueSubscriptions attaches active nfqueue subscriptions to the argumented SessionEntry

func GetSessionAttachment

func GetSessionAttachment(entry *SessionEntry, name string) interface{}

GetSessionAttachment is used to safely get an attachment from a session object

func InsertConntrackSubscription

func InsertConntrackSubscription(owner string, priority int, function ConntrackHandlerFunction)

InsertConntrackSubscription adds a subscription for receiving conntrack messages

func InsertNetloggerSubscription

func InsertNetloggerSubscription(owner string, priority int, function NetloggerHandlerFunction)

InsertNetloggerSubscription adds a subscription for receiving netlogger messages

func InsertNfqueueSubscription

func InsertNfqueueSubscription(owner string, priority int, function NfqueueHandlerFunction)

InsertNfqueueSubscription adds a subscription for receiving nfqueue messages

func PutSessionAttachment

func PutSessionAttachment(entry *SessionEntry, name string, value interface{})

PutSessionAttachment is used to safely add an attachment to a session object

func ReleaseSession

func ReleaseSession(session *SessionEntry, owner string)

ReleaseSession is called by a subscriber to stop receiving traffic for a session

func Shutdown

func Shutdown()

Shutdown stops the event handling service

func Startup

func Startup()

Startup starts the event handling service

Types

type ConntrackEntry

type ConntrackEntry struct {
	ConntrackID      uint32
	Session          *SessionEntry
	SessionID        uint64
	CreationTime     time.Time
	LastActivityTime time.Time
	ClientSideTuple  Tuple
	ServerSideTuple  Tuple
	EventCount       uint64
	C2Sbytes         uint64
	S2Cbytes         uint64
	TotalBytes       uint64
	C2Srate          float32
	S2Crate          float32
	TotalRate        float32
	PurgeFlag        bool
}

ConntrackEntry stores the details of a conntrack entry

func (ConntrackEntry) String

func (c ConntrackEntry) String() string

String returns string representation of conntrack

type ConntrackHandlerFunction

type ConntrackHandlerFunction func(int, *ConntrackEntry)

ConntrackHandlerFunction defines a pointer to a conntrack callback function

type NetloggerHandlerFunction

type NetloggerHandlerFunction func(*NetloggerMessage)

NetloggerHandlerFunction defines a pointer to a netlogger callback function

type NetloggerMessage

type NetloggerMessage struct {
	Version      uint8
	Protocol     uint8
	IcmpType     uint16
	SrcInterface uint8
	DstInterface uint8
	SrcAddress   string
	DstAddress   string
	SrcPort      uint16
	DstPort      uint16
	Mark         uint32
	Prefix       string
}

NetloggerMessage is used to pass the details of NFLOG events to interested plugins

type NfqueueHandlerFunction

type NfqueueHandlerFunction func(NfqueueMessage, uint32, bool) NfqueueResult

NfqueueHandlerFunction defines a pointer to a nfqueue callback function

type NfqueueMessage

type NfqueueMessage struct {
	Session  *SessionEntry
	Tuple    Tuple
	Packet   gopacket.Packet
	Length   int
	IP4layer *layers.IPv4
	IP6layer *layers.IPv6
	TCPlayer *layers.TCP
	UDPlayer *layers.UDP
	Payload  []byte
}

NfqueueMessage is used to pass nfqueue traffic to interested plugins

type NfqueueResult

type NfqueueResult struct {
	Owner          string
	PacketMark     uint32
	SessionRelease bool
}

NfqueueResult returns status and other information from a subscription handler function

type SessionEntry

type SessionEntry struct {
	SessionID          uint64
	PacketCount        uint64
	ByteCount          uint64
	CreationTime       time.Time
	LastActivityTime   time.Time
	ClientSideTuple    Tuple
	ServerSideTuple    Tuple
	ConntrackConfirmed bool
	EventCount         uint64
	// contains filtered or unexported fields
}

SessionEntry stores details related to a session

type SubscriptionHolder

type SubscriptionHolder struct {
	Owner         string
	Priority      int
	NfqueueFunc   NfqueueHandlerFunction
	ConntrackFunc ConntrackHandlerFunction
	NetloggerFunc NetloggerHandlerFunction
}

SubscriptionHolder stores the details of a data callback subscription

type Tuple

type Tuple struct {
	Protocol      uint8
	ClientAddress net.IP
	ClientPort    uint16
	ServerAddress net.IP
	ServerPort    uint16
}

Tuple represent a session using the protocol and source and destination address and port values.

func (Tuple) Equal

func (t Tuple) Equal(o Tuple) bool

Equal returns true if two Tuples are equal, false otherwise

func (Tuple) EqualReverse

func (t Tuple) EqualReverse(o Tuple) bool

EqualReverse returns true if two Tuples are equal when one is inversed in the other direction, false otherwise 1.2.3.4:5 -> 6.7.8.9:0 == 6.7.8.9:0 -> 1.2.3.4:5 = true

func (Tuple) String

func (t Tuple) String() string

String returns string representation of tuple

func (Tuple) StringReverse

func (t Tuple) StringReverse() string

StringReverse returns string representation of reverse tuple

Jump to

Keyboard shortcuts

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