sniproxy

package
v1.6.1 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2023 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Overview

Package sniproxy is responsible for the SNI and plain HTTP proxy that will listen for incoming TLS/HTTP connections, read the server name either from the SNI field of ClientHello or from the HTTP Host header, and tunnel traffic to the respective hosts.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// TLSListenAddr is the listen address the SNI proxy will be listening to
	// TLS connections.
	TLSListenAddr *net.TCPAddr

	// HTTPListenAddr is the listen address the SNI proxy will be listening to
	// plain HTTP connections.
	HTTPListenAddr *net.TCPAddr

	// ForwardProxy is the address of the SOCKS5 proxy that the connections will
	// be forwarded to according to ForwardRules.
	ForwardProxy string

	// ForwardRules is a list of wildcards that define what connections will be
	// forwarded to the proxy using ForwardProxy.  If the list is empty and
	// ForwardProxy is set, all connections will be forwarded.
	ForwardRules []string

	// BlockRules is a list of wildcards that define connections to which hosts
	// will be blocked.
	BlockRules []string

	// DropRules is a list of wildcards that define connections to which hosts
	// will be dropped. "Dropped" means that they will be delayed for a specific
	// period of time.
	DropRules []string

	// BandwidthRate is a number of bytes per second the connections speed will
	// be limited to.  If not set, there is no limit.
	BandwidthRate float64

	// BandwidthRules is a map that allows to define connection speed for
	// domains that match the wildcards.  Has higher priority than
	// BandwidthRate.
	BandwidthRules map[string]float64
}

Config is the SNI proxy configuration.

type SNIContext

type SNIContext struct {
	// ID is a unique connection ID.
	ID uint64

	// RemoteHost is the hostname that was parsed from the connection's TLS
	// ClientHello.
	RemoteHost string

	// RemoteAddr is the address the proxy will connect to.  Basically, it is
	// just remoteHost:remotePort.
	RemoteAddr string
}

SNIContext represents a single tunnel connection context.

func NewSNIContext

func NewSNIContext(remoteHost string, remoteAddr string) (c *SNIContext)

NewSNIContext creates a new instance of *SNIContext.

type SNIProxy

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

SNIProxy is a struct that manages the SNI proxy server. This server's purpose is to handle TLS connections and tunnel them to the respective hosts. Also, it can handle plain HTTP connections, parse the target host and tunnel traffic there.

func New

func New(cfg *Config) (d *SNIProxy, err error)

New creates a new instance of *SNIProxy.

func (*SNIProxy) Close

func (p *SNIProxy) Close() (err error)

Close implements the io.Closer interface for SNIProxy.

TODO(ameshkov): wait until all workers finish their work.

func (*SNIProxy) Start

func (p *SNIProxy) Start() (err error)

Start starts the SNIProxy server.

Jump to

Keyboard shortcuts

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