summaryrefslogtreecommitdiff
path: root/vendor/github.com/jackc/pgx/v5/pgconn/config.go
diff options
context:
space:
mode:
authorLibravatar kim <grufwub@gmail.com>2025-05-22 16:27:55 +0200
committerLibravatar kim <gruf@noreply.codeberg.org>2025-05-22 16:27:55 +0200
commitb6ff55662e0281c0d6e111f9307625ef695df2fa (patch)
tree5f7761efa0b51a7a7d56f96fce3681c8e9b66fe9 /vendor/github.com/jackc/pgx/v5/pgconn/config.go
parent[chore/woodpecker] don't make `test` depend on `lint` (#4189) (diff)
downloadgotosocial-b6ff55662e0281c0d6e111f9307625ef695df2fa.tar.xz
[chore] update dependencies (#4188)
Update dependencies: - github.com/gin-gonic/gin v1.10.0 -> v1.10.1 - github.com/gin-contrib/sessions v1.10.3 -> v1.10.4 - github.com/jackc/pgx/v5 v5.7.4 -> v5.7.5 - github.com/minio/minio-go/v7 v7.0.91 -> v7.0.92 - github.com/pquerna/otp v1.4.0 -> v1.5.0 - github.com/tdewolff/minify/v2 v2.23.5 -> v2.23.8 - github.com/yuin/goldmark v1.7.11 -> v1.7.12 - go.opentelemetry.io/otel{,/*} v1.35.0 -> v1.36.0 - modernc.org/sqlite v1.37.0 -> v1.37.1 Reviewed-on: https://codeberg.org/superseriousbusiness/gotosocial/pulls/4188 Reviewed-by: Daenney <daenney@noreply.codeberg.org> Co-authored-by: kim <grufwub@gmail.com> Co-committed-by: kim <grufwub@gmail.com>
Diffstat (limited to 'vendor/github.com/jackc/pgx/v5/pgconn/config.go')
-rw-r--r--vendor/github.com/jackc/pgx/v5/pgconn/config.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/vendor/github.com/jackc/pgx/v5/pgconn/config.go b/vendor/github.com/jackc/pgx/v5/pgconn/config.go
index 46b39f14e..1c28c4079 100644
--- a/vendor/github.com/jackc/pgx/v5/pgconn/config.go
+++ b/vendor/github.com/jackc/pgx/v5/pgconn/config.go
@@ -51,6 +51,8 @@ type Config struct {
KerberosSpn string
Fallbacks []*FallbackConfig
+ SSLNegotiation string // sslnegotiation=postgres or sslnegotiation=direct
+
// ValidateConnect is called during a connection attempt after a successful authentication with the PostgreSQL server.
// It can be used to validate that the server is acceptable. If this returns an error the connection is closed and the next
// fallback config is tried. This allows implementing high availability behavior such as libpq does with target_session_attrs.
@@ -198,9 +200,11 @@ func NetworkAddress(host string, port uint16) (network, address string) {
// PGSSLKEY
// PGSSLROOTCERT
// PGSSLPASSWORD
+// PGOPTIONS
// PGAPPNAME
// PGCONNECT_TIMEOUT
// PGTARGETSESSIONATTRS
+// PGTZ
//
// See http://www.postgresql.org/docs/11/static/libpq-envars.html for details on the meaning of environment variables.
//
@@ -318,6 +322,7 @@ func ParseConfigWithOptions(connString string, options ParseConfigOptions) (*Con
"sslkey": {},
"sslcert": {},
"sslrootcert": {},
+ "sslnegotiation": {},
"sslpassword": {},
"sslsni": {},
"krbspn": {},
@@ -386,6 +391,7 @@ func ParseConfigWithOptions(connString string, options ParseConfigOptions) (*Con
config.Port = fallbacks[0].Port
config.TLSConfig = fallbacks[0].TLSConfig
config.Fallbacks = fallbacks[1:]
+ config.SSLNegotiation = settings["sslnegotiation"]
passfile, err := pgpassfile.ReadPassfile(settings["passfile"])
if err == nil {
@@ -449,9 +455,12 @@ func parseEnvSettings() map[string]string {
"PGSSLSNI": "sslsni",
"PGSSLROOTCERT": "sslrootcert",
"PGSSLPASSWORD": "sslpassword",
+ "PGSSLNEGOTIATION": "sslnegotiation",
"PGTARGETSESSIONATTRS": "target_session_attrs",
"PGSERVICE": "service",
"PGSERVICEFILE": "servicefile",
+ "PGTZ": "timezone",
+ "PGOPTIONS": "options",
}
for envname, realname := range nameMap {
@@ -646,6 +655,7 @@ func configTLS(settings map[string]string, thisHost string, parseConfigOptions P
sslkey := settings["sslkey"]
sslpassword := settings["sslpassword"]
sslsni := settings["sslsni"]
+ sslnegotiation := settings["sslnegotiation"]
// Match libpq default behavior
if sslmode == "" {
@@ -657,6 +667,13 @@ func configTLS(settings map[string]string, thisHost string, parseConfigOptions P
tlsConfig := &tls.Config{}
+ if sslnegotiation == "direct" {
+ tlsConfig.NextProtos = []string{"postgresql"}
+ if sslmode == "prefer" {
+ sslmode = "require"
+ }
+ }
+
if sslrootcert != "" {
var caCertPool *x509.CertPool