cli

package
v0.0.0-...-45df43f Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package cli provides virtual command-line access in pgproxy include start,cli and stop action.

Package cli provides virtual command-line access in pgproxy include start,cli and stop action.

Index

Constants

View Source
View Source
const (
	VERSION = "0.1.0"
)

Variables

This section is empty.

Functions

func Main

func Main(configPath string)

Main starts pgproxy using the TOML configuration at configPath. An empty configPath falls back to the -config flag (default "pgproxy.conf"), unless -version was given, in which case Main prints the version and returns immediately. Otherwise Main blocks until it receives SIGINT/SIGTERM, then shuts the proxy down gracefully - a SIGHUP instead reloads the [Filter] rules from configPath without dropping connections (REVIEW.md M8; see run's doc comment for what SIGHUP does and does not reload). It is a thin wrapper around mainBody() that wires up the real process-wide flag set and OS signal channels; mainBody() (and run(), which it calls) carry the actual logic and are what tests exercise directly, since calling Main more than once per test binary would panic on flag redefinition.

Types

type ProxyConfig

type ProxyConfig struct {
	ServerConfig struct {
		ProxyAddr string

		// TLSCert/TLSKey, if both set, terminate TLS on ProxyAddr
		// (REVIEW.md H3): a client's SSLRequest is accepted and upgraded
		// instead of always being denied. TLSClientCA additionally
		// requires mutual TLS (the client must present a certificate
		// signed by a CA in that file).
		TLSCert     string
		TLSKey      string
		TLSClientCA string

		// MaxConnections caps concurrent sessions; 0 (default) is
		// unlimited (REVIEW.md M4).
		MaxConnections int

		// IdleTimeout closes a session that goes this long between
		// client messages, e.g. "5m" (REVIEW.md M4); empty (default) is
		// no idle timeout. Parsed with time.ParseDuration.
		IdleTimeout string

		// MetricsLogInterval, if set (e.g. "1m"), logs a snapshot of
		// proxy.Metrics at INFO level on that interval (REVIEW.md M8) -
		// grep/journalctl-friendly monitoring without an added metrics
		// dependency. Empty (default) disables periodic logging; the
		// counters are still collected either way and available to a
		// caller using pgproxy as a library via proxy.WithMetrics.
		MetricsLogInterval string
	}
	DB           map[string]proxy.DBConfig `toml:"DB"`
	FilterConfig parser.FilterConfig       `toml:"Filter"`

	// ACL restricts which clients may connect at all (REVIEW.md H4): see
	// proxy.ACL's doc comment for the exact matching rules. The zero
	// value (no [ACL] section, or an empty one) allows everything, same
	// as omitting it entirely.
	ACL proxy.ACL `toml:"ACL"`
}

proxy server config struct

Jump to

Keyboard shortcuts

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