aboutsummaryrefslogtreecommitdiff
path: root/lib/ssh
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2023-12-25 14:17:33 +0700
committerShulhan <ms@kilabit.info>2023-12-25 14:17:33 +0700
commit34cecb708d68361c462fa65cceca962a184f9947 (patch)
tree9a634ed82b8c6b739307c3c238f950573a0d39f8 /lib/ssh
parent4907d9403e71d42e70a7aa1ff76b792ed2fba2f7 (diff)
downloadpakakeh.go-34cecb708d68361c462fa65cceca962a184f9947.tar.xz
ssh/config: update comment on [Config.Get]
Make it clear that the passed parameter is a host name and the returned section will contains default values if no host or match found.
Diffstat (limited to 'lib/ssh')
-rw-r--r--lib/ssh/config/config.go19
1 files changed, 10 insertions, 9 deletions
diff --git a/lib/ssh/config/config.go b/lib/ssh/config/config.go
index 1c156da5..6ba14393 100644
--- a/lib/ssh/config/config.go
+++ b/lib/ssh/config/config.go
@@ -135,20 +135,21 @@ func Load(file string) (cfg *Config, err error) {
return cfg, nil
}
-// Get the Host or Match configuration that match with the pattern "s".
-// If no Host or Match found, it still return non-nil Section but with empty
-// fields.
-func (cfg *Config) Get(s string) (section *Section) {
- section = NewSection(cfg, s)
- for _, hostMatch := range cfg.sections {
- if hostMatch.isMatch(s) {
+// Get the Host or Match configuration that match with the host name "s".
+// If no Host or Match found, it return non-nil Section with default values.
+func (cfg *Config) Get(host string) (section *Section) {
+ section = NewSection(cfg, host)
+
+ var hostMatch *Section
+ for _, hostMatch = range cfg.sections {
+ if hostMatch.isMatch(host) {
section.mergeField(hostMatch)
}
}
section.setDefaults()
- if s != `` && section.Field[KeyHostname] == `` {
- section.Set(KeyHostname, s)
+ if host != `` && section.Field[KeyHostname] == `` {
+ section.Set(KeyHostname, host)
}
return section