tcp

package
v3.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetRulePriority

func GetRulePriority(rule string) int

GetRulePriority computes the priority for a given rule. The priority is calculated using the length of rule. There is a special case where the HostSNI(`*`) has a priority of -1.

func ParseHostSNI

func ParseHostSNI(rule string) ([]string, error)

ParseHostSNI extracts the HostSNIs declared in a rule. This is a first naive implementation used in TCP routing.

Types

type ConnData

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

ConnData contains TCP connection metadata.

func NewConnData

func NewConnData(serverName string, conn tcp.WriteCloser, alpnProtos []string) (ConnData, error)

NewConnData builds a connData struct from the given parameters.

type Muxer

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

Muxer defines a muxer that handles TCP routing with rules.

func NewMuxer

func NewMuxer() (*Muxer, error)

NewMuxer returns a TCP muxer.

func (*Muxer) AddRoute

func (m *Muxer) AddRoute(rule string, syntax string, priority int, handler tcp.Handler) error

AddRoute adds a new route, associated to the given handler, at the given priority, to the muxer.

func (*Muxer) HasRoutes

func (m *Muxer) HasRoutes() bool

HasRoutes returns whether the muxer has routes.

func (Muxer) Match

func (m Muxer) Match(meta ConnData) (tcp.Handler, bool)

Match returns the handler of the first route matching the connection metadata, and whether the match is exactly from the rule HostSNI(*).

Jump to

Keyboard shortcuts

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