Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Packet ¶
type Packet struct { Buffer []byte // contains filtered or unexported fields }
Packet struct provides the packet data and methods to accept, drop or modify the packet.
type PacketHandler ¶
type PacketHandler interface {
Handle(p *Packet)
}
PacketHandler is an interface to handle a packet retrieved by netfilter.
type Queue ¶
type Queue struct { ID uint16 // contains filtered or unexported fields }
Queue represents a netfilter queue with methods to start processing the packets (Run) and to stop
func NewQueue ¶
func NewQueue(queueID uint16, handler PacketHandler, cfg *QueueConfig) *Queue
NewQueue creates a Queue instance and registers it.
type QueueConfig ¶
QueueConfig contains optional configuration parameters to initialize a queue.
type QueueFlag ¶
QueueFlag configures the kernel queue.
const ( // FailOpen (requires Linux kernel >= 3.6): the kernel will accept the packets if the kernel queue gets full. // If this flag is not set, the default action in this case is to drop packets. FailOpen QueueFlag = (1 << 0) // Conntrack (requires Linux kernel >= 3.6): the kernel will include the Connection Tracking system information. Conntrack QueueFlag = (1 << 1) // GSO (requires Linux kernel >= 3.10): the kernel will not normalize offload packets, // i.e. your application will need to be able to handle packets larger than the mtu. GSO QueueFlag = (1 << 2) // UIDGid makes the kernel dump UID and GID of the socket to which each packet belongs. UIDGid QueueFlag = (1 << 3) // Secctx makes the kernel dump security context of the socket to which each packet belongs. Secctx QueueFlag = (1 << 4) )
type QueueRegistry ¶
type QueueRegistry struct {
// contains filtered or unexported fields
}
QueueRegistry stores a list of the netfilter queues registered. It returns a Queue based on the queue ID so that it is possible to build up a singleton registry to interact with netfilter library. This registry is not thread-safe on purpose. Queues should be registered before started.
func NewQueueRegistry ¶
func NewQueueRegistry() *QueueRegistry
NewQueueRegistry creates an instance of QueueRegistry.
func (*QueueRegistry) Get ¶
func (r *QueueRegistry) Get(queueID uint16) *Queue
Get returns a queue from the registry based on the queueID.
func (*QueueRegistry) Register ¶
func (r *QueueRegistry) Register(queueID uint16, queue *Queue)
Register adds a queue to the registry.
func (*QueueRegistry) Unregister ¶
func (r *QueueRegistry) Unregister(queueID uint16)
Unregister removes a queue from the registry.