pgwire

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTLSRequired = errors.New("postgres client TLS required")
	// ErrCancelRequest indicates the client sent a Postgres CancelRequest
	// rather than a startup message. We do not forward query cancellation, so
	// the proxy treats this as a benign close rather than an error.
	ErrCancelRequest = errors.New("postgres cancel request")
)

Functions

func ForwardPostAuth

func ForwardPostAuth(fe *pgproto3.Frontend, client net.Conn) error

ForwardPostAuth forwards ParameterStatus, BackendKeyData, and ReadyForQuery messages from upstream to the client. Returns when ReadyForQuery is received. The fe parameter should be the Frontend returned by HandleUpstreamAuth to share the same buffered reader.

func HandleUpstreamAuth

func HandleUpstreamAuth(conn net.Conn, user, password string) (*pgproto3.Frontend, error)

HandleUpstreamAuth handles the authentication exchange with the upstream PostgreSQL server. Supports CleartextPassword, MD5Password, and SASL (SCRAM-SHA-256). Returns the pgproto3 Frontend so that callers (e.g. ForwardPostAuth) can continue reading from the same buffered reader.

func ReadStartupMessage

func ReadStartupMessage(conn net.Conn, mode config.PostgresTLSMode, tlsConfig *tls.Config) (net.Conn, *pgproto3.StartupMessage, error)

ReadStartupMessage reads the initial PG startup message from the client and negotiates Postgres SSL/TLS when enabled. It returns the live client connection to use for the rest of the session, which may be TLS-wrapped.

func SendAuthOK

func SendAuthOK(conn net.Conn) error

SendAuthOK sends AuthenticationOk to the client.

func SendErrorResponse

func SendErrorResponse(conn net.Conn, severity, code, message string)

SendErrorResponse sends a PG ErrorResponse to the client.

func UpgradeToTLS added in v0.4.11

func UpgradeToTLS(conn net.Conn) (net.Conn, error)

UpgradeToTLS sends an SSLRequest to the backend and upgrades the connection to TLS. Returns the TLS-wrapped connection on success.

func WriteStartupMessage

func WriteStartupMessage(conn net.Conn, user, database string, params map[string]string) error

WriteStartupMessage sends a startup message to the upstream backend.

Types

This section is empty.

Jump to

Keyboard shortcuts

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