sni

package
v0.0.0-...-3bfe646 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// ListenAddr is the underlying listener address
	ListenAddr string
}

Config is Mux configuration parameters

func (*Config) Check

func (c *Config) Check() error

Check checks if configuration parameters are valid

type Dialer

type Dialer func() (net.Conn, error)

Dialer is a dialer to remote location

type Frontend

type Frontend struct {
	// Host is SNI host,used for routing
	Host string
	// Name is Frontend name, used to identify frontends
	Name string
	// Dial if present, used to dial the remote location
	Dial Dialer
	// Default controls if the default location is set with no SNI routes matched
	Default bool
	// contains filtered or unexported fields
}

Frontend is a mux Frontend either web handler or remote dialer

func (*Frontend) Check

func (f *Frontend) Check() error

Check checks if this frontend's parameters are valid

type ListenConfig

type ListenConfig struct {
	// ListenAddr is the SNI listener address
	ListenAddr string
	// Frontends is the list of frontends to initialize SNI mux with
	Frontends []Frontend
}

ListenConfig is the SNI mux configuration

type Mux

type Mux struct {
	sync.RWMutex
	Config

	logrus.FieldLogger
	// contains filtered or unexported fields
}

Mux is SNI multiplexer

func Listen

func Listen(config ListenConfig) (*Mux, error)

Listen creates a new SNI mux that listens on the specified address, starts it and adds all provided frontends to it. Returns the created mux

func New

func New(config Config) (*Mux, error)

New returns new instance of Mux

func (*Mux) AddFrontend

func (m *Mux) AddFrontend(f Frontend) error

AddFrontend adds frontend, returns error if SNI Host route already exists

func (*Mux) AddFrontends

func (m *Mux) AddFrontends(frontends ...Frontend) error

AddFrontends adds multiple SNI frontends

func (*Mux) DefaultFrontend

func (m *Mux) DefaultFrontend() *Frontend

DefaultFrontend returns default frontend, nil if not set

func (*Mux) ExistingFrontends

func (m *Mux) ExistingFrontends() map[string]*Frontend

ExistingFrontends returns map of existing frontends, read only

func (*Mux) HasFrontend

func (m *Mux) HasFrontend(host string) bool

HasFrontend returns true if there's a frontend matching given SNI host

func (*Mux) RemoveFrontend

func (m *Mux) RemoveFrontend(host string) error

RemoveFrontend removes frontend by SNI Host name

func (*Mux) Run

func (m *Mux) Run() error

Run binds to listening socket and starts routing requests

Jump to

Keyboard shortcuts

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