feat: add pre_connect hook and optional shortcut alias display
Test / test (pull_request) Successful in 4m27s
Test / test (pull_request) Successful in 4m27s
- ssh.pre_connect: local shell command run before every connection, layered like proxy_jump (global, instance/static host, rules; "none" disables). Host details are passed as NETSSH_* env vars, a non-zero exit aborts the connection, --dry-run only prints it. - shortcuts.show: show shortcut aliases in the TUI host list, an ALIAS column in `cache list` / `hosts list` (also via --aliases) and in Tab completion. - Both editable in `netssh configure`; README and CHANGELOG updated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017GpWAuVpPncumMViLLc8N4
This commit is contained in:
1 parent
20d7a40543
commit
796925b1a2
15 files changed
+507
-23
No files matched your search
@@ -438,9 +438,10 @@ func TestSaveKeepsSSHOptions(t *testing.T) {
|
||||
AddressFamily: "inet",
|
||||
ExtraArgs: []string{"-A"},
|
||||
Options: map[string]string{"serveraliveinterval": "60"},
|
||||
PreConnect: `vpn-check "$NETSSH_HOST" && echo 'ok'`,
|
||||
}
|
||||
cfg := config.Config{
|
||||
NetBoxes: []config.NetBoxConfig{{Name: "prod", URL: "https://prod.example", Token: "t", TokenVersion: 1, SSH: config.SSHOptions{HostKeyChecking: "off"}}},
|
||||
NetBoxes: []config.NetBoxConfig{{Name: "prod", URL: "https://prod.example", Token: "t", TokenVersion: 1, SSH: config.SSHOptions{HostKeyChecking: "off", PreConnect: "none"}}},
|
||||
Resolver: config.ResolverConfig{Strategies: []string{"primary_ip"}},
|
||||
Cache: config.CacheConfig{TTL: 3600},
|
||||
SSH: config.SSHConfig{
|
||||
@@ -651,3 +652,28 @@ func TestParseGroupsAndSaveMulti(t *testing.T) {
|
||||
t.Fatalf("got %v %+v", loaded.Groups, loaded.Multi)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSaveKeepsShortcutsShow(t *testing.T) {
|
||||
t.Setenv("XDG_CONFIG_HOME", t.TempDir())
|
||||
t.Setenv("HOME", t.TempDir())
|
||||
for _, sc := range []config.ShortcutsConfig{
|
||||
{Domains: []string{".example.com"}, Show: true},
|
||||
{Show: true}, // no shortcut rules yet: the switch alone must survive
|
||||
} {
|
||||
cfg := config.Config{
|
||||
Resolver: config.ResolverConfig{Strategies: []string{"primary_ip"}},
|
||||
Cache: config.CacheConfig{TTL: 3600},
|
||||
Shortcuts: sc,
|
||||
}
|
||||
if err := save(cfg); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
loaded, err := config.Load()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !loaded.Shortcuts.Show || !reflect.DeepEqual(loaded.Shortcuts.Domains, sc.Domains) {
|
||||
t.Fatalf("shortcuts lost: %+v", loaded.Shortcuts)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user