nfqueue

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2021 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DumpPacketInError = false

DumpPacketInError if a packet dump will be show with the error string

View Source
var ErrorsBuffer = 20

ErrorsBuffer sets the default size for error channels

View Source
var ShowPacketInError = false

ShowPacketInError if a packet digest will be show with the error string

Functions

This section is empty.

Types

type Action

type Action interface {
	// Name returns the name of the action instance
	Name() string
	// Class returns the class name of the action
	Class() string
	// PluginClass returns the plugin class implemented by the action
	PluginClass() string
}

Action defines interface for actions (used by plugins)

type CbClose

type CbClose func() error

CbClose defines callback for cleanups

type CbPacket

type CbPacket func(gopacket.Packet, time.Time) (Verdict, error)

CbPacket defines a callback on packet

type CbTick

type CbTick func(time.Time, time.Time) error

CbTick defines callback for tick routines

type Config

type Config struct {
	Policy  Verdict
	OnError Verdict
	Tick    time.Duration
}

Config defines configuration for a netfilter queue

type Error

type Error struct {
	// contains filtered or unexported fields
}

Error is used for packet processing

func NewError

func NewError(packet gopacket.Packet, err error) *Error

NewError creates a new packet processing error

func (*Error) Error

func (e *Error) Error() string

Error implements error interface

func (*Error) String

func (e *Error) String() string

type Hooks

type Hooks struct {
	// contains filtered or unexported fields
}

Hooks is responsible for packet processor

func NewHooks

func NewHooks() *Hooks

NewHooks returns a new hooks collection

func (*Hooks) CloseHooks

func (h *Hooks) CloseHooks() []CbClose

CloseHooks returns on close hooks

func (*Hooks) Layers

func (h *Hooks) Layers() []gopacket.LayerType

Layers return registered layers

func (*Hooks) OnClose

func (h *Hooks) OnClose(fn CbClose)

OnClose adds a callback function when closes source

func (*Hooks) OnPacket

func (h *Hooks) OnPacket(layer gopacket.LayerType, fn CbPacket)

OnPacket adds a callback function on new packet

func (*Hooks) OnTick

func (h *Hooks) OnTick(fn CbTick)

OnTick adds a callback function on each tick

func (*Hooks) PacketHooks

func (h *Hooks) PacketHooks() []OnPacket

PacketHooks returns on packet hooks in order

func (*Hooks) PacketHooksByLayer

func (h *Hooks) PacketHooksByLayer(layer gopacket.LayerType) []OnPacket

PacketHooksByLayer returns on packet hooks by layer

func (*Hooks) TickHooks

func (h *Hooks) TickHooks() []CbTick

TickHooks returns on tick hooks

type OnPacket

type OnPacket struct {
	Layer    gopacket.LayerType
	Callback CbPacket
}

OnPacket stores callbacks by layer

type Option

type Option func(*options)

Option encapsules options for server

func SetLogger

func SetLogger(l yalogi.Logger) Option

SetLogger option allows set a custom logger

type PacketProcessor

type PacketProcessor interface {
	Process(qid int, hooks *Hooks) (stop func(), errs <-chan error, err error)
}

PacketProcessor attach to a netfilter queue with the qid

func NewProcessor

func NewProcessor(cfg Config, logger yalogi.Logger) PacketProcessor

NewProcessor creates a new basic go-nfqueue processor

type PacketService

type PacketService struct {
	// contains filtered or unexported fields
}

PacketService manages multiple nfqueues

func NewService

func NewService(p PacketProcessor, plugins []Plugin, opt ...Option) *PacketService

NewService creates a new Service

func (*PacketService) Ping

func (s *PacketService) Ping() error

Ping returns true if errors

func (*PacketService) Register

func (s *PacketService) Register(qid int) error

Register packet source with name and start it if service is started

func (*PacketService) Shutdown

func (s *PacketService) Shutdown()

Shutdown the service and stop processing registered packet sources

func (*PacketService) Start

func (s *PacketService) Start() error

Start the service

func (*PacketService) Unregister

func (s *PacketService) Unregister(qid int) error

Unregister queue by id, stopping if it's started

type Plugin

type Plugin interface {
	// Name returns the name of the plugin instance
	Name() string
	// Class returns the class name of the plugin
	Class() string
	// Register add hooks to a the packet processing pipeline
	Register(hooks *Hooks)
	// Layers returns layers required by the plugin
	Layers() []gopacket.LayerType
	// CleanUp of the plugin
	CleanUp()
}

Plugin defines interface for packet processing plugins

type Verdict

type Verdict int

Verdict represents the actions that a firewall can do

const (
	Default Verdict = iota
	Accept
	Drop
)

Action types

func ToVerdict

func ToVerdict(s string) (Verdict, error)

ToVerdict returns action from a string

func (Verdict) String

func (v Verdict) String() string

Directories

Path Synopsis
plugins
ipp

Jump to

Keyboard shortcuts

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