engine

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2024 License: MPL-2.0 Imports: 15 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Logger  Logger
	IO      io.PacketIO
	Ruleset ruleset.Ruleset

	Workers                          int // Number of workers. Zero or negative means auto (number of CPU cores).
	WorkerQueueSize                  int
	WorkerTCPMaxBufferedPagesTotal   int
	WorkerTCPMaxBufferedPagesPerConn int
	WorkerTCPTimeout                 time.Duration
	WorkerUDPMaxStreams              int
}

Config is the configuration for the engine.

type Engine

type Engine interface {
	// UpdateRuleset updates the ruleset.
	UpdateRuleset(ruleset.Ruleset) error
	// Run runs the engine, until an error occurs or the context is cancelled.
	Run(context.Context) error
}

Engine is the main engine for OpenGFW.

func NewEngine

func NewEngine(config Config) (Engine, error)

type Logger

type Logger interface {
	WorkerStart(id int)
	WorkerStop(id int)

	TCPStreamNew(workerID int, info ruleset.StreamInfo)
	TCPStreamPropUpdate(info ruleset.StreamInfo, close bool)
	TCPStreamAction(info ruleset.StreamInfo, action ruleset.Action, noMatch bool)
	TCPFlush(workerID, flushed, closed int)

	UDPStreamNew(workerID int, info ruleset.StreamInfo)
	UDPStreamPropUpdate(info ruleset.StreamInfo, close bool)
	UDPStreamAction(info ruleset.StreamInfo, action ruleset.Action, noMatch bool)

	ModifyError(info ruleset.StreamInfo, err error)

	AnalyzerDebugf(streamID int64, name string, format string, args ...interface{})
	AnalyzerInfof(streamID int64, name string, format string, args ...interface{})
	AnalyzerErrorf(streamID int64, name string, format string, args ...interface{})
}

Logger is the combined logging interface for the engine, workers and analyzers.

Jump to

Keyboard shortcuts

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