Skip to content

Commit fd0e415

Browse files
Allow TLS enabled connections when providing an established channel (#526)
Co-authored-by: Fabian Fett <[email protected]>
1 parent 96ed89f commit fd0e415

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

Sources/PostgresNIO/Connection/PostgresConnection+Configuration.swift

+15-2
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,22 @@ extension PostgresConnection {
192192
/// - Parameters:
193193
/// - channel: The `NIOCore/Channel` to use. The channel must already be active and connected to an
194194
/// endpoint (i.e. `NIOCore/Channel/isActive` must be `true`).
195-
/// - tls: The TLS mode to use. Defaults to ``TLS-swift.struct/disable``.
195+
/// - tls: The TLS mode to use.
196+
public init(establishedChannel channel: Channel, tls: PostgresConnection.Configuration.TLS, username: String, password: String?, database: String?) {
197+
self.init(endpointInfo: .configureChannel(channel), tls: tls, username: username, password: password, database: database)
198+
}
199+
200+
/// Create a configuration for establishing a connection to a Postgres server over a preestablished
201+
/// `NIOCore/Channel`.
202+
///
203+
/// This is provided for calling code which wants to manage the underlying connection transport on its
204+
/// own, such as when tunneling a connection through SSH.
205+
///
206+
/// - Parameters:
207+
/// - channel: The `NIOCore/Channel` to use. The channel must already be active and connected to an
208+
/// endpoint (i.e. `NIOCore/Channel/isActive` must be `true`).
196209
public init(establishedChannel channel: Channel, username: String, password: String?, database: String?) {
197-
self.init(endpointInfo: .configureChannel(channel), tls: .disable, username: username, password: password, database: database)
210+
self.init(establishedChannel: channel, tls: .disable, username: username, password: password, database: database)
198211
}
199212

200213
// MARK: - Implementation details

0 commit comments

Comments
 (0)