proxy

package
v0.0.0-...-1c5d739 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2023 License: Apache-2.0 Imports: 15 Imported by: 7

Documentation

Overview

Package proxy is used to create and register proxies that forward traffic from a port/ip combination, address, to a set of backends

Index

Constants

This section is empty.

Variables

View Source
var (
	// command to generate: openssl req -x509 -sha256 -nodes -days 1826 -newkey rsa:2048 -keyout NEW_SERVER_KEY.key -out NEW_SERVER_CERT.crt
	InsecureCertPEM = `` /* 1443-byte string literal not displayed */

	InsecureKeyPEM = `` /* 1703-byte string literal not displayed */

)

Functions

func ProxyLoop

func ProxyLoop(client net.Conn, backend net.Conn, quit chan bool)

func TempCertFile

func TempCertFile() (string, error)

TempCertFile creates a temp file with the contents set to proxyCertPEM and returns the temp file path.

func TempKeyFile

func TempKeyFile() (string, error)

TempKeyFile creates a temp file with the contents set to proxyCertPEM and returns the temp file path.

Types

type Proxy

type Proxy interface {
	Run() error
	Close() error
}

Proxy is the interface of a proxy.

type ProxyAddress

type ProxyAddress struct {
	IP   string
	Port uint16
}

ProxyAddress is a IP and port grouping

type ProxyFactory

type ProxyFactory func(protocol string, frontend ProxyAddress, backEnds ...ProxyAddress) (Proxy, error)

ProxyFactory is a function declaration for a proxy factory.

type ProxyRegistry

type ProxyRegistry interface {
	//CreateProxy create, registers and starts a proxy identified by key
	//protocol is TCP or UDP
	//frontEnd is the IP/Port to listen on
	//backends are the what is being proxied, It is up to the proxy implementation on how it distributes requests to the backends
	CreateProxy(key string, protocol string, frontend ProxyAddress, backEnds ...ProxyAddress) error

	//RemoveProxy stops and removes proxy.
	RemoveProxy(key string) (Proxy, error)
}

ProxyRegistry is an interface of a proxy registration service

func NewDefaultProxyRegistry

func NewDefaultProxyRegistry() ProxyRegistry

NewDefaultProxyRegistry Create a new ProxyRegistry

func NewProxyRegistry

func NewProxyRegistry(factory ProxyFactory) ProxyRegistry

NewProxyRegistry Create a new ProxyRegistry using the supplied ProxyFactory

type TCPMux

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

TCPMux is an implementation of tcp muxing RFC 1078.

func NewTCPMux

func NewTCPMux(listener net.Listener) (mux *TCPMux, err error)

NewTCPMux creates a new tcp mux with the given listener. If it succees, it is expected that this object is the owner of the listener and will close it when Close() is called on the TCPMux.

func (*TCPMux) Close

func (mux *TCPMux) Close()

Jump to

Keyboard shortcuts

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