Commit Graph

28 Commits (1b6543f29c8c08ccfc51a8d426ea44d960ae4d3e)

Author SHA1 Message Date
sergey.bashilov 1b6543f29c fix typos 2022-07-02 07:04:50 -05:00
sergey.bashilov 25935a39b6 add prefer-standby target_session_attrs 2022-07-02 07:04:50 -05:00
Eno Compton 0135721378 Add support for Unix sockets on Windows
Fixes #1199.
2022-05-07 06:59:53 -05:00
Oscar 3ce8a835e1 add support for read-only, primary, standby, prefer-standby target_session_attributes 2021-12-28 09:31:38 -06:00
Jack Christensen fb42201c18 Fix default host when parsing URL without host but with port
fixes https://github.com/jackc/pgconn/issues/72
2021-05-14 18:39:31 -05:00
Jack Christensen 3f76b98073 Allow dbname query parameter in URL conn string
fixes #69
2021-04-09 18:20:06 -05:00
Jack Christensen 74517d7315 Fix test when PGSSLMODE=disable
When PGSSLMODE=disable no fallback config was created which would cause
the check that fallbacks are deep copied to crash on:

copied.Fallbacks[0].Port = uint16(5433)
2021-01-30 13:03:56 -06:00
Moshe Katz 724bf94515 use proper pgpass location on Windows 2021-01-09 09:36:36 -06:00
Jack Christensen be69c1c10b Fix parseDSNSettings with bad backslash
fixes #49
2020-09-10 19:40:52 -05:00
Jack Christensen 44079b0d2c Fix panic on parsing DSN with trailing '='
Also correctly return error with leading '='.

fixes #47
2020-07-29 22:11:15 -05:00
georgysavva a6d9265506 Implement deep copy manually, stop using an external deep copy library. Add comment to the Config.Copy() method. 2020-06-01 20:52:08 +03:00
georgysavva 8d541d0004 Add Config.Copy() method that return a smart copy of the config. 2020-06-01 19:20:17 +03:00
Jack Christensen 18d2604119
Merge pull request #38 from lukedirtwalker/fixIPv6
Handle IPv6 in connection URLs
2020-05-13 08:50:38 -05:00
Lukas Vogel 08d071c094 Handle IPv6 in connection URLs
Previously IPv6 addresses were wrongly split and lead to a parse error.
This commit fixes the behavior.
2020-05-12 10:39:35 +02:00
georgysavva 391e1ef2ce Parse connect timeout setting into Config. Restrict context timeout via Config.ConnectTimeout on .Connect() call. 2020-05-02 16:35:22 +03:00
Greg Curtis 4ed48d05d2 Implement "verify-ca" SSL mode
ParseConfig currently treats the libpq "verify-ca" SSL mode as
"verify-full". This is okay from a security standpoint because
"verify-full" performs certificate verification and hostname
verification, whereas "verify-ca" only performs certificate
verification.

The downside to this approach is that checking the hostname is
unnecessary when the server's certificate has been signed by a private
CA. It can also cause the SSL handshake to fail when connecting to an
instance by IP. For example, a Google Cloud SQL instance typically
doesn't have a hostname and uses its own private CA to sign its
server and client certs.

This change uses the tls.Config.VerifyPeerCertificate function to
perform certificate verification without checking the hostname when the
"verify-ca" SSL mode is set. This brings pgconn's behavior closer to
that of libpq.

See https://github.com/golang/go/issues/21971#issuecomment-332693931
and https://pkg.go.dev/crypto/tls?tab=doc#example-Config-VerifyPeerCertificate
for more details on how this is implemented.
2020-03-17 23:36:06 -07:00
Jack Christensen cfbd2519e3 Add PGSERVICE and PGSERVICEFILE support 2020-03-07 13:17:39 -06:00
Jack Christensen 99f22ac8e4 Port DSN parser from pgx v3
Original implementation: 2d9d8dc52a by
Joshua Barone <joshua.barone@gmail.com>.

Also changed DSN tests to use "dbname" as key rather than "database" as
that is what the PostgreSQL documentation specifies. "database" still
actually works but it should not be encouraged as it is non-standard.
2019-09-14 18:37:33 -05:00
Jack Christensen a8362ef96d Parse postgresql:// protocol 2019-09-10 17:14:04 -05:00
Jack Christensen e6cf51b304 Expose min_read_buffer_size config param 2019-08-25 00:22:32 -05:00
Jack Christensen 3dec184811 Split ValidateConnect from AfterConnect
This avoids the foot-gun of ParseConfig setting AfterConnect because of
target_session_attrs and the user inadvertently overriding it with an
AfterConnect designed to setup the connection.

Now target_session_attrs will be handled with ValidateConnect.
2019-07-13 10:22:09 -05:00
Jack Christensen 59941377c8 Rename Config.AfterConnectFunc to AfterConnect
No need to include the type in the name.
2019-07-13 09:52:22 -05:00
Jack Christensen fbdfccf1f9 Use Go modules 2019-03-30 12:55:56 -05:00
Jack Christensen c447ff4e79 Use NoError instead of Nil for assertions 2019-01-19 14:51:07 -06:00
Jack Christensen bcc3da490c Run tests in parallel 2018-12-31 17:34:44 -06:00
Jack Christensen 8c574c39f8 Add support for libpq target_session_attrs
Generalize AcceptConnFunc into AfterConnectFunc.
2018-12-31 12:15:29 -06:00
Jack Christensen 1836f7be46 Support comma separated hosts and ports like libpq
Also add test and fix the fallback config implementation.
2018-12-31 11:14:13 -06:00
Jack Christensen beeb69ff0b Restructure connect process
- Moved lots of connection logic to pgconn from pgx
- Extracted pgpassfile package
2018-12-30 16:55:56 -06:00