fix(ssh): resolve ~/.ssh/config aliases at connect time (#977)#979
Merged
fix(ssh): resolve ~/.ssh/config aliases at connect time (#977)#979
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #977 — typing an SSH config alias like
aia-bastionin the SSH host field used to fail withEAI_NONAMEbecause the alias was passed straight togetaddrinfoinstead of being resolved through~/.ssh/config. This PR makes the SSH config a runtime source of truth for tunnel creation, with fullssh_config(5)-compatible matching.ssh(1)behavior. Editing~/.ssh/configtakes effect on the next connection (mtime-cached, no restart needed).Hostglob/negation, allMatchtypes (host,originalhost,user,localuser,exec,all,canonical,final),ProxyJumpinjection, hostname canonicalization,Include.useSSHConfigtoggle (resolution is always on).SSHConfiguration.portmigrated toInt?so an explicit form value of 22 can override a non-22 config Port.Architecture
Three layers, in
TablePro/Core/SSH/:New types:
SSHConfigDocument,SSHConfigBlock,SSHConfigCriteria,HostPattern,MatchCondition,CanonicalizeMode,SSHDirective,ResolvedSSHTarget,ResolverEnvironment.New components:
SSHConfigResolver— pure resolver, two-pass (Match canonical/final on second pass), explicit-form-wins precedence.SSHConfigCache— actor with mtime-based invalidation; main config file's mtime always tracked.SSHHostPatternMatcher—fnmatch(3)glob + negation, mirrors OpenSSHmatch_pattern_list.SSHHostnameCanonicalizer—getaddrinfo+AI_CANONNAMEforCanonicalizeHostname/CanonicalDomains.SSHMatchExecutor— runsMatch execvia/bin/sh -cwith 5s timeout; replaces busy-poll withwaitUntilExit+ DispatchWorkItem timeout.LibSSH2TunnelFactory.buildAuthenticatedChainnow resolves the primary host and every jump hop up front; auth helpers takeResolvedSSHTarget. Removed the duplicatefindEntry/resolveIdentityFilespaths.Test plan
swiftlint lint TablePro/Core/SSH/ TableProTests/Core/SSH/— 0 violations in new files.xcodebuild build— clean.xcodebuild test -only-testing:TableProTests/SSHConfigResolverTests— 17 pass.xcodebuild testacross all SSH suites — 274 pass / 0 fail (excluding 1 pre-existing flakyHostKeyStoreTests/testPortDifferentiationunrelated to this PR).ProxyJumpinjection,Match host/originalhost/exec/canonical/finalsemantics, two-pass canonicalization, glob patterns, jump-host alias resolution,Match finaloverriding first-pass values, mtime-based cache invalidation,Match execexit codes and timeout.aia-bastion(or anyHostalias) in the SSH host field, leave port/user empty, click Test Connection — should succeed.Host alias / ProxyJump bastionin~/.ssh/config, leave jump hosts empty in form — tunnel should chain throughbastion.Migration notes
SSHConfiguration.portandSSHJumpHost.portare nowInt?. Old JSON with explicit"port": 22decodes toOptional(22)and is treated as an explicit override.useSSHConfigfield removed from model, storage (StoredConnection JSON), CloudKit sync, deeplink, exports, and all three foreign-app importers (TablePlus / DBeaver / Sequel Ace). Old JSON containing the field decodes silently (CodingKey removed). Old app versions writing to the same iCloud account keep working.Files
40 files changed: 1944 insertions, 471 deletions. 7 new source files in
TablePro/Core/SSH/, 4 new test files inTableProTests/Core/SSH/.