proxy

package
v0.2.15 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2022 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var WillSendManually = fmt.Errorf("sending manually")

WillSendManually lets the proxy know that QueryInterceptor will handle sending the message

Functions

This section is empty.

Types

type Config

type Config struct {
	ServerCertificate        *tls.Certificate
	DefaultClientCertificate *tls.Certificate
	ListenAddress            *net.TCPAddr
	CredentialInterceptor    CredentialInterceptor
	QueryInterceptor         QueryInterceptor
	Mode                     Mode
	AwsAuthOnly              bool `default:false`
}

Config contains the various options for setting up the proxy

type CredentialInterceptor

type CredentialInterceptor func(creds *Credentials) error

CredentialInterceptor provides a way to update credentials being forwarded to the server proxy

type Credentials

type Credentials struct {
	Host     string
	Database string
	Username string
	Password string
	// Misc connection parameters to be passed along
	Options map[string]string
	// SSL Settings for the outbound connection
	SSLMode           pg.SSLMode
	ClientCertificate *tls.Certificate
	RootCertificate   *x509.Certificate
}

Credentials represents connection details to an upstream database or proxy

type Manager

type Manager struct {
	ActiveSessions sync.Map
	// contains filtered or unexported fields
}

Manager watches a group of proxies

func NewManager

func NewManager(opts ...Option) (*Manager, error)

NewManager returns an instance of Manager

func (*Manager) Start

func (m *Manager) Start(ctx context.Context) error

Start starts the proxy server

type Mode

type Mode int

Mode indicates what kind of mode the proxy is in

const (
	// ClientSide proxy mode is for running on the end-user laptop
	ClientSide Mode = iota
	// ServerSide proxy mode is for the in-cluster
	ServerSide
)

type Option

type Option func(*Config) error

Option lets you set a config option

func MergeOptions

func MergeOptions(lists ...[]Option) []Option

MergeOptions is a helper to merge an option list

func WithAWSAuthOnly

func WithAWSAuthOnly(aws_auth_only bool) Option

func WithClientCertificate

func WithClientCertificate(certPath, keyPath string) Option

WithClientCertificate sets up the default client certificates

func WithCredentialInterceptor

func WithCredentialInterceptor(credFactory CredentialInterceptor) Option

WithCredentialInterceptor sets the credential retrieval strategy

func WithGeneratedClientCertificate

func WithGeneratedClientCertificate() Option

WithGeneratedClientCertificate generates the default client certificates

func WithGeneratedServerCertificate

func WithGeneratedServerCertificate() Option

WithGeneratedServerCertificate generates a self-signed server certificate for the proxy

func WithListenAddress

func WithListenAddress(addr string) Option

WithListenAddress sets the IP/port that the proxy will accept connections on

func WithMode

func WithMode(mode Mode) Option

WithMode sets the mode of the proxy

func WithQueryInterceptor

func WithQueryInterceptor(interceptor QueryInterceptor) Option

WithQueryInterceptor adds a function for custom message handling

func WithServerCertificate

func WithServerCertificate(certPath, keyPath string) Option

WithServerCertificate sets the SSL settings for the proxy

type Proxy

type Proxy struct {
	ID uint64
	// contains filtered or unexported fields
}

Proxy - Manages a Proxy connection, piping data between proxy and remote.

func (*Proxy) ParseCredentials

func (p *Proxy) ParseCredentials(connectionParams map[string]string) Credentials

ParseCredentials takes connection parameters and turns them into Credentials

func (*Proxy) Start

func (p *Proxy) Start() error

Start boots the proxy

func (*Proxy) Stop

func (p *Proxy) Stop()

Stop shuts the proxy down and cleans up the connections

type QueryInterceptor

type QueryInterceptor func(frontend pg.SendOnlyFrontend, backend pg.SendOnlyBackend, msg *pgproto3.Query) error

QueryInterceptor provides a way to define custom behavior for handling messages

Jump to

Keyboard shortcuts

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