proxy

package
v0.0.0-...-a4bd7fa Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2025 License: MPL-2.0 Imports: 7 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 {
	// ListenFunc returns a net.Listener that listens for incoming source connections.
	ListenFunc func() (net.Listener, error)
	// DialFunc dials a remote and returns a net.Conn for the destination.
	DialFunc func() (net.Conn, error)
}

Config holds the configuration for a single proxy connection between a source and destination.

type Conn

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

Conn represents a single proxied TCP connection.

func NewConn

func NewConn(src, dst net.Conn) *Conn

NewConn returns a Conn joining the two given net.Conn

func (*Conn) Close

func (c *Conn) Close() error

Close closes both the source and destination connections.

func (*Conn) CopyBytes

func (c *Conn) CopyBytes() error

CopyBytes will continuously copy bytes in both directions between src and dst until either connection is closed.

type Listener

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

Listener is the implementation of a specific proxy listener. It has pluggable Listen and Dial methods to suit public mTLS vs upstream semantics. It handles the lifecycle of the listener and all connections opened through it

func NewListener

func NewListener(cfg *Config) *Listener

NewListener returns a Listener setup to listen for public mTLS connections and proxy them to the configured local application over TCP.

func (*Listener) Close

func (l *Listener) Close()

Close terminates the listener and all active connections.

func (*Listener) Errors

func (l *Listener) Errors() <-chan error

Errors returns a channel that the listener writes errors to. The channel is closed when the listener is closed.

func (*Listener) Listening

func (l *Listener) Listening() <-chan struct{}

Listening returns a channel that is closed when the Listener is ready to accept incoming connections.

func (*Listener) Serve

func (l *Listener) Serve() error

Serve runs the listener until it is stopped. It is an error to call Serve more than once for any given Listener instance.

Serve returns a non-nil error if the Listener is unable to accept any incoming connections. Errors related to individual connections are written to the Errors() channel.

func (*Listener) Wait

func (l *Listener) Wait()

Wait for the listener to be ready to accept connections.

type Server

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

Server implements a proxy server that manages TCP listeners for a configurable set of upstreams.

func New

func New(logger hclog.Logger, cfgs ...*Config) *Server

New returns a new, unstarted proxy server from the given proxy configurations. The proxy can be started by calling Serve.

func (*Server) Close

func (s *Server) Close()

Close shuts down the proxy and closes all active connections and listeners.

func (*Server) Serve

func (s *Server) Serve() error

Serve starts the proxy and initializes all of the configured listeners. It blocks until Close is called or an error occurs.

func (*Server) Wait

func (s *Server) Wait() <-chan struct{}

Wait returns a channel that is closed once the proxy is ready to serve requests on all listeners.

Jump to

Keyboard shortcuts

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