protocol

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2022 License: GPL-3.0 Imports: 7 Imported by: 0

README

Protocol Filter

Protocol Filter defines an interface to identify the protocol used in a connection.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotEnoughData = errors.New("not enough data in buffer")
)

Functions

This section is empty.

Types

type ConnBuf

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

Thread-safe buffer in order to allow inspection of the connection

func NewConnBuf

func NewConnBuf() *ConnBuf

func (*ConnBuf) Close

func (cb *ConnBuf) Close() error

func (*ConnBuf) Peek

func (cb *ConnBuf) Peek(p []byte, n int) error

Peek copies at least n bytes from the buffer, or return error

func (*ConnBuf) Read

func (cb *ConnBuf) Read(p []byte) (n int, err error)

func (*ConnBuf) SetDownstream

func (cb *ConnBuf) SetDownstream(w io.Writer) error

func (*ConnBuf) Write

func (cb *ConnBuf) Write(p []byte) (n int, err error)

type Protocol

type Protocol interface {
	// Name prints the name of the protocol, like "TLS", which is going to be used as a key in the ProtocolGroup
	Name() config.Protocol

	// Clone creates a new Protocol instance with the same rules (as a deep copy)
	Clone() Protocol

	// ApplyRules save the rules for later Identify calls.
	// Note the rules are out-of-order intentionally to prevent conflicting rules.
	// Protocol implementations should make sure the CATCHEALL rule is always the last rule to be applied.
	ApplyRules(rules []config.Rule) error

	// Identify identifies the rule that matches the request.
	Identify(ctx context.Context, cBuf *ConnBuf) (config.Rule, error) // Identify will keep checking cBuf until it can make a deterministic decision or the context is cancelled.
}

Protocol is the interface for protocol identification.

type ProtocolManager

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

func NewProtocolManager

func NewProtocolManager() *ProtocolManager

func (*ProtocolManager) FindAction

func (pm *ProtocolManager) FindAction(ctx context.Context, cBuf *ConnBuf) (config.Action, error)

func (*ProtocolManager) GetProtocol

func (pm *ProtocolManager) GetProtocol(name config.Protocol) Protocol

func (*ProtocolManager) ImportProtocolGroup

func (pm *ProtocolManager) ImportProtocolGroup(pg config.ProtocolGroup) error

Called after RegisterProtocol, or will see error upon unknown protocol

func (*ProtocolManager) RegisterProtocol

func (pm *ProtocolManager) RegisterProtocol(p Protocol)

Called before ImportProtocolGroup, or will see error upon unknown protocol

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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