Skip to content

Commit cf7ce45

Browse files
authored
feat(connections): connect through a SOCKS5 proxy (#1882) (#1899)
1 parent 532a7cd commit cf7ce45

41 files changed

Lines changed: 1896 additions & 113 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
### Added
1111

12+
- Connect through a SOCKS5 proxy. Set a host, port, and an optional username and password on the connection form's new SOCKS Proxy pane, alongside SSH Tunnel, Cloudflare Tunnel, and Cloud SQL Auth Proxy. The database hostname is resolved by the proxy, so names that only resolve behind it work. (#1882)
1213
- SQL Server connections can now use Windows Authentication (Kerberos) on macOS. Pick Windows Authentication in the connection form to sign in with the Kerberos ticket you already have from `kinit`, or enter a Kerberos principal and password to sign in with your domain credentials. Connect by hostname, not IP address. (#1879)
1314
- Teradata support through a downloadable driver written in native Swift. Connect over TD2 or TDNEGO logon, optionally with TLS, browse databases, tables, and columns, run SQL, edit rows, and create or alter tables. (#1867)
1415

@@ -18,6 +19,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1819

1920
### Fixed
2021

22+
- Fixed duplicating a connection dropping its Cloudflare Tunnel and Cloud SQL Auth Proxy settings and stored secrets.
23+
- Fixed the tunnel panes warning about only some of the other enabled connection methods. Each pane now lists every conflicting method with a button to turn it off.
2124
- Fixed Copy as, the context menu's Delete, and the Edit menu's copy and delete commands acting on only the active row instead of every row in a cell-range or column selection in the data grid. (#1898)
2225
- Fixed the Edit menu's Copy as JSON copying the wrong rows when the grid was sorted or filtered. (#1898)
2326
- Fixed tables picked in the sidebar showing up unchecked and getting silently skipped when exporting to SQL or MQL. The export sheet now checks them and applies the format's default per-table options, so Export works right away.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
//
2+
// DatabaseManager+SOCKSProxy.swift
3+
// TablePro
4+
//
5+
6+
import Foundation
7+
8+
extension DatabaseManager {
9+
func buildSOCKSProxyEffectiveConnection(
10+
for connection: DatabaseConnection
11+
) async throws -> DatabaseConnection {
12+
guard let config = connection.resolvedSOCKSProxyConfig else { return connection }
13+
14+
let password = config.username.isEmpty
15+
? nil
16+
: connectionStorage.loadSOCKSProxyPassword(for: connection.id)
17+
18+
let tunnelPort = try await SOCKSProxyManager.shared.createTunnel(
19+
connectionId: connection.id,
20+
config: config,
21+
password: password,
22+
targetHost: connection.host,
23+
targetPort: connection.port
24+
)
25+
26+
return tunneledConnection(from: connection, localPort: tunnelPort)
27+
}
28+
29+
func handleSOCKSProxyTunnelDied(connectionId: UUID) async {
30+
await recoverDeadTunnel(
31+
connectionId: connectionId,
32+
kind: "SOCKS Proxy",
33+
disconnectedMessage: String(localized: "SOCKS proxy disconnected. Click to reconnect.")
34+
)
35+
}
36+
}

TablePro/Core/Database/DatabaseManager+SSH.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ extension DatabaseManager {
3131
return try await buildCloudflareEffectiveConnection(for: connection)
3232
case .cloudSQLProxy:
3333
return try await buildCloudSQLProxyEffectiveConnection(for: connection)
34+
case .socksProxy:
35+
return try await buildSOCKSProxyEffectiveConnection(for: connection)
3436
case .ssh, .none:
3537
break
3638
}

TablePro/Core/Database/DatabaseManager+SystemEvents.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ extension DatabaseManager {
5050
await handleCloudflareTunnelDied(connectionId: connectionId)
5151
case .cloudSQLProxy:
5252
await handleCloudSQLProxyTunnelDied(connectionId: connectionId)
53+
case .socksProxy:
54+
await handleSOCKSProxyTunnelDied(connectionId: connectionId)
5355
}
5456
}
5557
}

TablePro/Core/Database/DatabaseManager+Tunnel.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ extension DatabaseManager {
7676
case .ssh: return SSHTunnelManager.shared
7777
case .cloudflare: return CloudflareTunnelManager.shared
7878
case .cloudSQLProxy: return CloudSQLProxyManager.shared
79+
case .socksProxy: return SOCKSProxyManager.shared
7980
case .none: return nil
8081
}
8182
}

TablePro/Core/Plugins/PluginManager+Registration.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,11 @@ extension PluginManager {
466466
.capabilities.supportsCloudflareTunnel ?? true
467467
}
468468

469+
func supportsSOCKSProxy(for databaseType: DatabaseType) -> Bool {
470+
PluginMetadataRegistry.shared.snapshot(forTypeId: databaseType.pluginTypeId)?
471+
.capabilities.supportsSOCKSProxy ?? true
472+
}
473+
469474
func supportsColumnReorder(for databaseType: DatabaseType) -> Bool {
470475
PluginMetadataRegistry.shared.snapshot(forTypeId: databaseType.pluginTypeId)?
471476
.supportsColumnReorder ?? false

TablePro/Core/Plugins/PluginMetadataRegistry.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ struct PluginMetadataSnapshot: Sendable {
6262
var supportsCloudflareTunnel: Bool = true
6363
var supportsClientKeyPassphrase: Bool = false
6464

65+
var supportsSOCKSProxy: Bool { supportsSSH }
66+
6567
static let defaults = CapabilityFlags(
6668
supportsSchemaSwitching: false,
6769
supportsImport: true,

0 commit comments

Comments
 (0)