Debian Codegraph @

config.go

raw symbols SCIP
1 // Package ssh_config provides tools for manipulating SSH config files.
2 //
3 // Importantly, this parser attempts to preserve comments in a given file, so
4 // you can manipulate a `ssh_config` file from a program, if your heart desires.
5 //
6 // The Get() and GetStrict() functions will attempt to read values from
7 // $HOME/.ssh/config, falling back to /etc/ssh/ssh_config. The first argument is
8 // the host name to match on ("example.com"), and the second argument is the key
9 // you want to retrieve ("Port"). The keywords are case insensitive.
10 //
11 // port := ssh_config.Get("myhost", "Port")
12 //
13 // You can also manipulate an SSH config file and then print it or write it back
14 // to disk.
15 //
16 // f, _ := os.Open(filepath.Join(os.Getenv("HOME"), ".ssh", "config"))
17 // cfg, _ := ssh_config.Decode(f)
18 // for _, host := range cfg.Hosts {
19 // fmt.Println("patterns:", host.Patterns)
20 // for _, node := range host.Nodes {
21 // fmt.Println(node.String())
22 // }
23 // }
24 //
25 // // Write the cfg back to disk:
26 // fmt.Println(cfg.String())
27 //
28 // BUG: the Match directive is currently unsupported; parsing a config with
29 // a Match directive will trigger an error.
30 package ssh_configscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/
31
32 import (
33 "bytesscip-go gomod github.com/golang/go/src go1.18 bytes/"
34 "errorsscip-go gomod github.com/golang/go/src go1.18 errors/"
35 "fmtscip-go gomod github.com/golang/go/src go1.18 fmt/"
36 "ioscip-go gomod github.com/golang/go/src go1.18 io/"
37 "osscip-go gomod github.com/golang/go/src go1.18 os/"
38 osuserscip-go gomod github.com/golang/go/src go1.18 `os/user`/ "os/userscip-go gomod github.com/golang/go/src go1.18 `os/user`/"
39 "path/filepathscip-go gomod github.com/golang/go/src go1.18 `path/filepath`/"
40 "regexpscip-go gomod github.com/golang/go/src go1.18 regexp/"
41 "runtimescip-go gomod github.com/golang/go/src go1.18 runtime/"
42 "stringsscip-go gomod github.com/golang/go/src go1.18 strings/"
43 "syncscip-go gomod github.com/golang/go/src go1.18 sync/"
44 )
45
46 const versionscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/version. = "1.2"
47
48 var _ = versionscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/version.
49
50 type configFinderscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/configFinder# func() string
51
52 // UserSettings checks ~/.ssh and /etc/ssh for configuration files. The config
53 // files are parsed and cached the first time Get() or GetStrict() is called.
54 type UserSettingsscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings# struct {
55 IgnoreErrorsscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#IgnoreErrors. bool
56 IgnoreMatchDirectivescip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#IgnoreMatchDirective. bool
57 customConfigscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#customConfig. *Configscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Config#
58 customConfigFinderscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#customConfigFinder. configFinderscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/configFinder#
59 systemConfigscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#systemConfig. *Configscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Config#
60 systemConfigFinderscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#systemConfigFinder. configFinderscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/configFinder#
61 userConfigscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#userConfig. *Configscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Config#
62 userConfigFinderscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#userConfigFinder. configFinderscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/configFinder#
63 loadConfigsscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#loadConfigs. syncscip-go gomod github.com/golang/go/src go1.18 sync/.Oncescip-go gomod github.com/golang/go/src go1.18 sync/Once#
64 onceErrscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#onceErr. error
65 }
66
67 func homedirscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/homedir().() string {
68 user, err := osuserscip-go gomod github.com/golang/go/src go1.18 `os/user`/.Currentscip-go gomod github.com/golang/go/src go1.18 `os/user`/Current().()
69 if err == nil {
70 return user.HomeDirscip-go gomod github.com/golang/go/src go1.18 `os/user`/User#HomeDir.
71 } else {
72 return osscip-go gomod github.com/golang/go/src go1.18 os/.Getenvscip-go gomod github.com/golang/go/src go1.18 os/Getenv().("HOME")
73 }
74 }
75
76 func userConfigFinderscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/userConfigFinder().() string {
77 return filepathscip-go gomod github.com/golang/go/src go1.18 `path/filepath`/.Joinscip-go gomod github.com/golang/go/src go1.18 `path/filepath`/Join().(homedirscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/homedir().(), ".ssh", "config")
78 }
79
80 // DefaultUserSettings is the default UserSettings and is used by Get and
81 // GetStrict. It checks both $HOME/.ssh/config and /etc/ssh/ssh_config for keys,
82 // and it will return parse errors (if any) instead of swallowing them.
83 var DefaultUserSettingsscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/DefaultUserSettings. = &UserSettingsscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#{
84 IgnoreErrorsscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#IgnoreErrors.: false,
85 IgnoreMatchDirectivescip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#IgnoreMatchDirective.: false,
86 systemConfigFinderscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#systemConfigFinder.: systemConfigFinderscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/systemConfigFinder().,
87 userConfigFinderscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#userConfigFinder.: userConfigFinderscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/userConfigFinder().,
88 }
89
90 func systemConfigFinderscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/systemConfigFinder().() string {
91 return filepathscip-go gomod github.com/golang/go/src go1.18 `path/filepath`/.Joinscip-go gomod github.com/golang/go/src go1.18 `path/filepath`/Join().("/", "etc", "ssh", "ssh_config")
92 }
93
94 func findValscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/findVal().(c *Configscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Config#, alias, key string) (string, error) {
95 if c == nil {
96 return "", nil
97 }
98 val, err := c.Getscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Config#Get().(alias, key)
99 if err != nil || val == "" {
100 return "", err
101 }
102 if err := validatescip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/validate().(key, val); err != nil {
103 return "", err
104 }
105 return val, nil
106 }
107
108 func findAllscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/findAll().(c *Configscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Config#, alias, key string) ([]string, error) {
109 if c == nil {
110 return nil, nil
111 }
112 return c.GetAllscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Config#GetAll().(alias, key)
113 }
114
115 // Get finds the first value for key within a declaration that matches the
116 // alias. Get returns the empty string if no value was found, or if IgnoreErrors
117 // is false and we could not parse the configuration file. Use GetStrict to
118 // disambiguate the latter cases.
119 //
120 // The match for key is case insensitive.
121 //
122 // Get is a wrapper around DefaultUserSettings.Get.
123 func Getscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Get().(alias, key string) string {
124 return DefaultUserSettingsscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/DefaultUserSettings..Getscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#Get().(alias, key)
125 }
126
127 // GetAll retrieves zero or more directives for key for the given alias. GetAll
128 // returns nil if no value was found, or if IgnoreErrors is false and we could
129 // not parse the configuration file. Use GetAllStrict to disambiguate the
130 // latter cases.
131 //
132 // In most cases you want to use Get or GetStrict, which returns a single value.
133 // However, a subset of ssh configuration values (IdentityFile, for example)
134 // allow you to specify multiple directives.
135 //
136 // The match for key is case insensitive.
137 //
138 // GetAll is a wrapper around DefaultUserSettings.GetAll.
139 func GetAllscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/GetAll().(alias, key string) []string {
140 return DefaultUserSettingsscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/DefaultUserSettings..GetAllscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#GetAll().(alias, key)
141 }
142
143 // GetStrict finds the first value for key within a declaration that matches the
144 // alias. If key has a default value and no matching configuration is found, the
145 // default will be returned. For more information on default values and the way
146 // patterns are matched, see the manpage for ssh_config.
147 //
148 // The returned error will be non-nil if and only if a user's configuration file
149 // or the system configuration file could not be parsed, and u.IgnoreErrors is
150 // false.
151 //
152 // GetStrict is a wrapper around DefaultUserSettings.GetStrict.
153 func GetStrictscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/GetStrict().(alias, key string) (string, error) {
154 return DefaultUserSettingsscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/DefaultUserSettings..GetStrictscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#GetStrict().(alias, key)
155 }
156
157 // GetAllStrict retrieves zero or more directives for key for the given alias.
158 //
159 // In most cases you want to use Get or GetStrict, which returns a single value.
160 // However, a subset of ssh configuration values (IdentityFile, for example)
161 // allow you to specify multiple directives.
162 //
163 // The returned error will be non-nil if and only if a user's configuration file
164 // or the system configuration file could not be parsed, and u.IgnoreErrors is
165 // false.
166 //
167 // GetAllStrict is a wrapper around DefaultUserSettings.GetAllStrict.
168 func GetAllStrictscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/GetAllStrict().(alias, key string) ([]string, error) {
169 return DefaultUserSettingsscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/DefaultUserSettings..GetAllStrictscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#GetAllStrict().(alias, key)
170 }
171
172 // Get finds the first value for key within a declaration that matches the
173 // alias. Get returns the empty string if no value was found, or if IgnoreErrors
174 // is false and we could not parse the configuration file. Use GetStrict to
175 // disambiguate the latter cases.
176 //
177 // The match for key is case insensitive.
178 func (u *UserSettingsscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#) Getscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#Get().(alias, key string) string {
179 val, err := u.GetStrictscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#GetStrict().(alias, key)
180 if err != nil {
181 return ""
182 }
183 return val
184 }
185
186 // GetAll retrieves zero or more directives for key for the given alias. GetAll
187 // returns nil if no value was found, or if IgnoreErrors is false and we could
188 // not parse the configuration file. Use GetStrict to disambiguate the latter
189 // cases.
190 //
191 // The match for key is case insensitive.
192 func (u *UserSettingsscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#) GetAllscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#GetAll().(alias, key string) []string {
193 val, _ := u.GetAllStrictscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#GetAllStrict().(alias, key)
194 return val
195 }
196
197 // GetStrict finds the first value for key within a declaration that matches the
198 // alias. If key has a default value and no matching configuration is found, the
199 // default will be returned. For more information on default values and the way
200 // patterns are matched, see the manpage for ssh_config.
201 //
202 // error will be non-nil if and only if a user's configuration file or the
203 // system configuration file could not be parsed, and u.IgnoreErrors is false.
204 func (u *UserSettingsscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#) GetStrictscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#GetStrict().(alias, key string) (string, error) {
205 u.doLoadConfigsscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#doLoadConfigs().()
206 //lint:ignore S1002 I prefer it this way
207 if u.onceErrscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#onceErr. != nil && u.IgnoreErrorsscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#IgnoreErrors. == false {
208 return "", u.onceErrscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#onceErr.
209 }
210 // TODO this is getting repetitive
211 if u.customConfigscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#customConfig. != nil {
212 val, err := findValscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/findVal().(u.customConfigscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#customConfig., alias, key)
213 if err != nil || val != "" {
214 return val, err
215 }
216 }
217 val, err := findValscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/findVal().(u.userConfigscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#userConfig., alias, key)
218 if err != nil || val != "" {
219 return val, err
220 }
221 val2, err2 := findValscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/findVal().(u.systemConfigscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#systemConfig., alias, key)
222 if err2 != nil || val2 != "" {
223 return val2, err2
224 }
225 return Defaultscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Default().(key), nil
226 }
227
228 // GetAllStrict retrieves zero or more directives for key for the given alias.
229 // If key has a default value and no matching configuration is found, the
230 // default will be returned. For more information on default values and the way
231 // patterns are matched, see the manpage for ssh_config.
232 //
233 // The returned error will be non-nil if and only if a user's configuration file
234 // or the system configuration file could not be parsed, and u.IgnoreErrors is
235 // false.
236 func (u *UserSettingsscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#) GetAllStrictscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#GetAllStrict().(alias, key string) ([]string, error) {
237 u.doLoadConfigsscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#doLoadConfigs().()
238 //lint:ignore S1002 I prefer it this way
239 if u.onceErrscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#onceErr. != nil && u.IgnoreErrorsscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#IgnoreErrors. == false {
240 return nil, u.onceErrscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#onceErr.
241 }
242 if u.customConfigscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#customConfig. != nil {
243 val, err := findAllscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/findAll().(u.customConfigscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#customConfig., alias, key)
244 if err != nil || val != nil {
245 return val, err
246 }
247 }
248 val, err := findAllscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/findAll().(u.userConfigscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#userConfig., alias, key)
249 if err != nil || val != nil {
250 return val, err
251 }
252 val2, err2 := findAllscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/findAll().(u.systemConfigscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#systemConfig., alias, key)
253 if err2 != nil || val2 != nil {
254 return val2, err2
255 }
256 // TODO: IdentityFile has multiple default values that we should return.
257 if def := Defaultscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Default().(key); def != "" {
258 return []string{def}, nil
259 }
260 return []string{}, nil
261 }
262
263 // ConfigFinder will invoke f to try to find a ssh config file in a custom
264 // location on disk, instead of in /etc/ssh or $HOME/.ssh. f should return the
265 // name of a file containing SSH configuration.
266 //
267 // ConfigFinder must be invoked before any calls to Get or GetStrict and panics
268 // if f is nil. Most users should not need to use this function.
269 func (u *UserSettingsscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#) ConfigFinderscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#ConfigFinder().(f func() string) {
270 if f == nil {
271 panic("cannot call ConfigFinder with nil function")
272 }
273 u.customConfigFinderscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#customConfigFinder. = f
274 }
275
276 func (u *UserSettingsscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#) doLoadConfigsscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#doLoadConfigs().() {
277 u.loadConfigsscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#loadConfigs..Doscip-go gomod github.com/golang/go/src go1.18 sync/Once#Do().(func() {
278 var filename string
279 var err error
280 if u.customConfigFinderscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#customConfigFinder. != nil {
281 filename = u.customConfigFinderscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#customConfigFinder.()
282 u.customConfigscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#customConfig., err = parseFilescip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/parseFile().(filename, u.IgnoreMatchDirectivescip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#IgnoreMatchDirective.)
283 // IsNotExist should be returned because a user specified this
284 // function - not existing likely means they made an error
285 // We should also respect the ignore flag
286 if err != nil && !u.IgnoreErrorsscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#IgnoreErrors. {
287 u.onceErrscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#onceErr. = err
288 }
289 return
290 }
291 if u.userConfigFinderscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#userConfigFinder. == nil {
292 filename = userConfigFinderscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/userConfigFinder().()
293 } else {
294 filename = u.userConfigFinderscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#userConfigFinder.()
295 }
296 u.userConfigscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#userConfig., err = parseFilescip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/parseFile().(filename, u.IgnoreMatchDirectivescip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#IgnoreMatchDirective.)
297 //lint:ignore S1002 I prefer it this way
298 if err != nil && osscip-go gomod github.com/golang/go/src go1.18 os/.IsNotExistscip-go gomod github.com/golang/go/src go1.18 os/IsNotExist().(err) == false {
299 u.onceErrscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#onceErr. = err
300 return
301 }
302 if u.systemConfigFinderscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#systemConfigFinder. == nil {
303 filename = systemConfigFinderscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/systemConfigFinder().()
304 } else {
305 filename = u.systemConfigFinderscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#systemConfigFinder.()
306 }
307 u.systemConfigscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#systemConfig., err = parseFilescip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/parseFile().(filename, u.IgnoreMatchDirectivescip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#IgnoreMatchDirective.)
308 //lint:ignore S1002 I prefer it this way
309 if err != nil && osscip-go gomod github.com/golang/go/src go1.18 os/.IsNotExistscip-go gomod github.com/golang/go/src go1.18 os/IsNotExist().(err) == false {
310 u.onceErrscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#onceErr. = err
311 return
312 }
313 },
314 )
315 }
316
317 func parseFilescip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/parseFile().(filename string, ignoreMatchDirective bool) (*Configscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Config#, error) {
318 return parseWithDepthscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/parseWithDepth().(filename, ignoreMatchDirective, 0)
319 }
320
321 func parseWithDepthscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/parseWithDepth().(filename string, ignoreMatchDirective bool, depth uint8) (*Configscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Config#, error) {
322 b, err := osscip-go gomod github.com/golang/go/src go1.18 os/.ReadFilescip-go gomod github.com/golang/go/src go1.18 os/ReadFile().(filename)
323 if err != nil {
324 return nil, err
325 }
326 return decodeBytesscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/decodeBytes().(b, isSystemscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/isSystem().(filename), ignoreMatchDirective, depth)
327 }
328
329 func isSystemscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/isSystem().(filename string) bool {
330 // TODO: not sure this is the best way to detect a system repo
331 return stringsscip-go gomod github.com/golang/go/src go1.18 strings/.HasPrefixscip-go gomod github.com/golang/go/src go1.18 strings/HasPrefix().(filepathscip-go gomod github.com/golang/go/src go1.18 `path/filepath`/.Cleanscip-go gomod github.com/golang/go/src go1.18 `path/filepath`/Clean().(filename), "/etc/ssh")
332 }
333
334 // Decode reads r into a Config, or returns an error if r could not be parsed as
335 // an SSH config file.
336 func Decodescip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Decode().(r ioscip-go gomod github.com/golang/go/src go1.18 io/.Readerscip-go gomod github.com/golang/go/src go1.18 io/Reader#, ignoreMatchDirective bool) (*Configscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Config#, error) {
337 b, err := ioscip-go gomod github.com/golang/go/src go1.18 io/.ReadAllscip-go gomod github.com/golang/go/src go1.18 io/ReadAll().(r)
338 if err != nil {
339 return nil, err
340 }
341 return decodeBytesscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/decodeBytes().(b, false, ignoreMatchDirective, 0)
342 }
343
344 // DecodeBytes reads b into a Config, or returns an error if r could not be
345 // parsed as an SSH config file.
346 func DecodeBytesscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/DecodeBytes().(b []byte, ignoreMatchDirective bool) (*Configscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Config#, error) {
347 return decodeBytesscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/decodeBytes().(b, false, ignoreMatchDirective, 0)
348 }
349
350 func decodeBytesscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/decodeBytes().(b []byte, system, ignoreMatchDirective bool, depth uint8) (c *Configscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Config#, err error) {
351 defer func() {
352 if r := recover(); r != nil {
353 if _, ok := r.(runtimescip-go gomod github.com/golang/go/src go1.18 runtime/.Errorscip-go gomod github.com/golang/go/src go1.18 runtime/Error#); ok {
354 panic(r)
355 }
356 if e, ok := r.(error); ok && e == ErrDepthExceededscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/ErrDepthExceeded. {
357 err = e
358 return
359 }
360 err = errorsscip-go gomod github.com/golang/go/src go1.18 errors/.Newscip-go gomod github.com/golang/go/src go1.18 errors/New().(r.(string))
361 }
362 }()
363
364 c = parseSSHscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/parseSSH().(lexSSHscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/lexSSH().(b), system, ignoreMatchDirective, depth)
365 return c, err
366 }
367
368 // Config represents an SSH config file.
369 type Configscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Config# struct {
370 // A list of hosts to match against. The file begins with an implicit
371 // "Host *" declaration matching all hosts.
372 Hostsscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Config#Hosts. []*Hostscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Host#
373 depthscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Config#depth. uint8
374 positionscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Config#position. Positionscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Position#
375 ignoreMatchDirectivescip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Config#ignoreMatchDirective. bool
376 }
377
378 // Get finds the first value in the configuration that matches the alias and
379 // contains key. Get returns the empty string if no value was found, or if the
380 // Config contains an invalid conditional Include value.
381 //
382 // The match for key is case insensitive.
383 func (c *Configscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Config#) Getscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Config#Get().(alias, key string) (string, error) {
384 lowerKey := stringsscip-go gomod github.com/golang/go/src go1.18 strings/.ToLowerscip-go gomod github.com/golang/go/src go1.18 strings/ToLower().(key)
385 for _, host := range c.Hostsscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Config#Hosts. {
386 if !host.Matchesscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Host#Matches().(alias) {
387 continue
388 }
389 for _, node := range host.Nodesscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Host#Nodes. {
390 switch t := node.(type) {
391 case *Emptyscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Empty#:
392 continue
393 case *KVscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/KV#:
394 // "keys are case insensitive" per the spec
395 lkey := stringsscip-go gomod github.com/golang/go/src go1.18 strings/.ToLowerscip-go gomod github.com/golang/go/src go1.18 strings/ToLower().(t.Keyscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/KV#Key.)
396 if lkey == "match" && !c.ignoreMatchDirectivescip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Config#ignoreMatchDirective. {
397 panic("can't handle Match directives")
398 }
399 if lkey == lowerKey {
400 return t.Valuescip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/KV#Value., nil
401 }
402 case *Includescip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Include#:
403 val := t.Getscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Include#Get().(alias, key)
404 if val != "" {
405 return val, nil
406 }
407 default:
408 return "", fmtscip-go gomod github.com/golang/go/src go1.18 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.18 fmt/Errorf().("unknown Node type %v", t)
409 }
410 }
411 }
412 return "", nil
413 }
414
415 // GetAll returns all values in the configuration that match the alias and
416 // contains key, or nil if none are present.
417 func (c *Configscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Config#) GetAllscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Config#GetAll().(alias, key string) ([]string, error) {
418 lowerKey := stringsscip-go gomod github.com/golang/go/src go1.18 strings/.ToLowerscip-go gomod github.com/golang/go/src go1.18 strings/ToLower().(key)
419 all := []string(nil)
420 for _, host := range c.Hostsscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Config#Hosts. {
421 if !host.Matchesscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Host#Matches().(alias) {
422 continue
423 }
424 for _, node := range host.Nodesscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Host#Nodes. {
425 switch t := node.(type) {
426 case *Emptyscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Empty#:
427 continue
428 case *KVscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/KV#:
429 // "keys are case insensitive" per the spec
430 lkey := stringsscip-go gomod github.com/golang/go/src go1.18 strings/.ToLowerscip-go gomod github.com/golang/go/src go1.18 strings/ToLower().(t.Keyscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/KV#Key.)
431 if lkey == "match" {
432 panic("can't handle Match directives")
433 }
434 if lkey == lowerKey {
435 all = append(all, t.Valuescip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/KV#Value.)
436 }
437 case *Includescip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Include#:
438 val, _ := t.GetAllscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Include#GetAll().(alias, key)
439 if len(val) > 0 {
440 all = append(all, val...)
441 }
442 default:
443 return nil, fmtscip-go gomod github.com/golang/go/src go1.18 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.18 fmt/Errorf().("unknown Node type %v", t)
444 }
445 }
446 }
447
448 return all, nil
449 }
450
451 // String returns a string representation of the Config file.
452 func (c Configscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Config#) Stringscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Config#String().() string {
453 return marshalscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/marshal().(c).Stringscip-go gomod github.com/golang/go/src go1.18 bytes/Buffer#String().()
454 }
455
456 func (c Configscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Config#) MarshalTextscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Config#MarshalText().() ([]byte, error) {
457 return marshalscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/marshal().(c).Bytesscip-go gomod github.com/golang/go/src go1.18 bytes/Buffer#Bytes().(), nil
458 }
459
460 func marshalscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/marshal().(c Configscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Config#) *bytesscip-go gomod github.com/golang/go/src go1.18 bytes/.Bufferscip-go gomod github.com/golang/go/src go1.18 bytes/Buffer# {
461 var buf bytesscip-go gomod github.com/golang/go/src go1.18 bytes/.Bufferscip-go gomod github.com/golang/go/src go1.18 bytes/Buffer#
462 for i := range c.Hostsscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Config#Hosts. {
463 buf.WriteStringscip-go gomod github.com/golang/go/src go1.18 bytes/Buffer#WriteString().(c.Hostsscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Config#Hosts.[i].Stringscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Host#String().())
464 }
465 return &buf
466 }
467
468 // Pattern is a pattern in a Host declaration. Patterns are read-only values;
469 // create a new one with NewPattern().
470 type Patternscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Pattern# struct {
471 strscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Pattern#str. string // Its appearance in the file, not the value that gets compiled.
472 regexscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Pattern#regex. *regexpscip-go gomod github.com/golang/go/src go1.18 regexp/.Regexpscip-go gomod github.com/golang/go/src go1.18 regexp/Regexp#
473 notscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Pattern#not. bool // True if this is a negated match
474 }
475
476 // String prints the string representation of the pattern.
477 func (p Patternscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Pattern#) Stringscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Pattern#String().() string {
478 return p.strscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Pattern#str.
479 }
480
481 // Copied from regexp.go with * and ? removed.
482 var specialBytesscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/specialBytes. = []byte(`\.+()|[]{}^$`)
483
484 func specialscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/special().(b byte) bool {
485 return bytesscip-go gomod github.com/golang/go/src go1.18 bytes/.IndexBytescip-go gomod github.com/golang/go/src go1.18 bytes/IndexByte().(specialBytesscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/specialBytes., b) >= 0
486 }
487
488 // NewPattern creates a new Pattern for matching hosts. NewPattern("*") creates
489 // a Pattern that matches all hosts.
490 //
491 // From the manpage, a pattern consists of zero or more non-whitespace
492 // characters, `*' (a wildcard that matches zero or more characters), or `?' (a
493 // wildcard that matches exactly one character). For example, to specify a set
494 // of declarations for any host in the ".co.uk" set of domains, the following
495 // pattern could be used:
496 //
497 // Host *.co.uk
498 //
499 // The following pattern would match any host in the 192.168.0.[0-9] network range:
500 //
501 // Host 192.168.0.?
502 func NewPatternscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/NewPattern().(s string) (*Patternscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Pattern#, error) {
503 if s == "" {
504 return nil, errorsscip-go gomod github.com/golang/go/src go1.18 errors/.Newscip-go gomod github.com/golang/go/src go1.18 errors/New().("ssh_config: empty pattern")
505 }
506 negated := false
507 if s[0] == '!' {
508 negated = true
509 s = s[1:]
510 }
511 var buf bytesscip-go gomod github.com/golang/go/src go1.18 bytes/.Bufferscip-go gomod github.com/golang/go/src go1.18 bytes/Buffer#
512 buf.WriteBytescip-go gomod github.com/golang/go/src go1.18 bytes/Buffer#WriteByte().('^')
513 for i := 0; i < len(s); i++ {
514 // A byte loop is correct because all metacharacters are ASCII.
515 switch b := s[i]; b {
516 case '*':
517 buf.WriteStringscip-go gomod github.com/golang/go/src go1.18 bytes/Buffer#WriteString().(".*")
518 case '?':
519 buf.WriteStringscip-go gomod github.com/golang/go/src go1.18 bytes/Buffer#WriteString().(".?")
520 default:
521 // borrowing from QuoteMeta here.
522 if specialscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/special().(b) {
523 buf.WriteBytescip-go gomod github.com/golang/go/src go1.18 bytes/Buffer#WriteByte().('\\')
524 }
525 buf.WriteBytescip-go gomod github.com/golang/go/src go1.18 bytes/Buffer#WriteByte().(b)
526 }
527 }
528 buf.WriteBytescip-go gomod github.com/golang/go/src go1.18 bytes/Buffer#WriteByte().('$')
529 r, err := regexpscip-go gomod github.com/golang/go/src go1.18 regexp/.Compilescip-go gomod github.com/golang/go/src go1.18 regexp/Compile().(buf.Stringscip-go gomod github.com/golang/go/src go1.18 bytes/Buffer#String().())
530 if err != nil {
531 return nil, err
532 }
533 return &Patternscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Pattern#{strscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Pattern#str.: s, regexscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Pattern#regex.: r, notscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Pattern#not.: negated}, nil
534 }
535
536 // Host describes a Host directive and the keywords that follow it.
537 type Hostscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Host# struct {
538 // A list of host patterns that should match this host.
539 Patternsscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Host#Patterns. []*Patternscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Pattern#
540 // A Node is either a key/value pair or a comment line.
541 Nodesscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Host#Nodes. []Nodescip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Node#
542 // EOLComment is the comment (if any) terminating the Host line.
543 EOLCommentscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Host#EOLComment. string
544 // Whitespace if any between the Host declaration and a trailing comment.
545 spaceBeforeCommentscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Host#spaceBeforeComment. string
546
547 hasEqualsscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Host#hasEquals. bool
548 leadingSpacescip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Host#leadingSpace. int // TODO: handle spaces vs tabs here.
549 // The file starts with an implicit "Host *" declaration.
550 implicitscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Host#implicit. bool
551 }
552
553 // Matches returns true if the Host matches for the given alias. For
554 // a description of the rules that provide a match, see the manpage for
555 // ssh_config.
556 func (h *Hostscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Host#) Matchesscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Host#Matches().(alias string) bool {
557 found := false
558 for i := range h.Patternsscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Host#Patterns. {
559 if h.Patternsscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Host#Patterns.[i].regexscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Pattern#regex..MatchStringscip-go gomod github.com/golang/go/src go1.18 regexp/Regexp#MatchString().(alias) {
560 if h.Patternsscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Host#Patterns.[i].notscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Pattern#not. {
561 // Negated match. "A pattern entry may be negated by prefixing
562 // it with an exclamation mark (`!'). If a negated entry is
563 // matched, then the Host entry is ignored, regardless of
564 // whether any other patterns on the line match. Negated matches
565 // are therefore useful to provide exceptions for wildcard
566 // matches."
567 return false
568 }
569 found = true
570 }
571 }
572 return found
573 }
574
575 // String prints h as it would appear in a config file. Minor tweaks may be
576 // present in the whitespace in the printed file.
577 func (h *Hostscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Host#) Stringscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Host#String().() string {
578 var buf stringsscip-go gomod github.com/golang/go/src go1.18 strings/.Builderscip-go gomod github.com/golang/go/src go1.18 strings/Builder#
579 //lint:ignore S1002 I prefer to write it this way
580 if h.implicitscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Host#implicit. == false {
581 buf.WriteStringscip-go gomod github.com/golang/go/src go1.18 strings/Builder#WriteString().(stringsscip-go gomod github.com/golang/go/src go1.18 strings/.Repeatscip-go gomod github.com/golang/go/src go1.18 strings/Repeat().(" ", int(h.leadingSpacescip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Host#leadingSpace.)))
582 buf.WriteStringscip-go gomod github.com/golang/go/src go1.18 strings/Builder#WriteString().("Host")
583 if h.hasEqualsscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Host#hasEquals. {
584 buf.WriteStringscip-go gomod github.com/golang/go/src go1.18 strings/Builder#WriteString().(" = ")
585 } else {
586 buf.WriteStringscip-go gomod github.com/golang/go/src go1.18 strings/Builder#WriteString().(" ")
587 }
588 for i, pat := range h.Patternsscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Host#Patterns. {
589 buf.WriteStringscip-go gomod github.com/golang/go/src go1.18 strings/Builder#WriteString().(pat.Stringscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Pattern#String().())
590 if i < len(h.Patternsscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Host#Patterns.)-1 {
591 buf.WriteStringscip-go gomod github.com/golang/go/src go1.18 strings/Builder#WriteString().(" ")
592 }
593 }
594 buf.WriteStringscip-go gomod github.com/golang/go/src go1.18 strings/Builder#WriteString().(h.spaceBeforeCommentscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Host#spaceBeforeComment.)
595 if h.EOLCommentscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Host#EOLComment. != "" {
596 buf.WriteBytescip-go gomod github.com/golang/go/src go1.18 strings/Builder#WriteByte().('#')
597 buf.WriteStringscip-go gomod github.com/golang/go/src go1.18 strings/Builder#WriteString().(h.EOLCommentscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Host#EOLComment.)
598 }
599 buf.WriteBytescip-go gomod github.com/golang/go/src go1.18 strings/Builder#WriteByte().('\n')
600 }
601 for i := range h.Nodesscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Host#Nodes. {
602 buf.WriteStringscip-go gomod github.com/golang/go/src go1.18 strings/Builder#WriteString().(h.Nodesscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Host#Nodes.[i].Stringscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Node#String.())
603 buf.WriteBytescip-go gomod github.com/golang/go/src go1.18 strings/Builder#WriteByte().('\n')
604 }
605 return buf.Stringscip-go gomod github.com/golang/go/src go1.18 strings/Builder#String().()
606 }
607
608 // Node represents a line in a Config.
609 type Nodescip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Node# interface {
610 Posscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Node#Pos.() Positionscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Position#
611 Stringscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Node#String.() string
612 }
613
614 // KV is a line in the config file that contains a key, a value, and possibly
615 // a comment.
616 type KVscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/KV# struct {
617 Keyscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/KV#Key. string
618 Valuescip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/KV#Value. string
619 // Whitespace after the value but before any comment
620 spaceAfterValuescip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/KV#spaceAfterValue. string
621 Commentscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/KV#Comment. string
622 hasEqualsscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/KV#hasEquals. bool
623 leadingSpacescip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/KV#leadingSpace. int // Space before the key. TODO handle spaces vs tabs.
624 positionscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/KV#position. Positionscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Position#
625 }
626
627 // Pos returns k's Position.
628 func (k *KVscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/KV#) Posscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/KV#Pos().() Positionscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Position# {
629 return k.positionscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/KV#position.
630 }
631
632 // String prints k as it was parsed in the config file.
633 func (k *KVscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/KV#) Stringscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/KV#String().() string {
634 if k == nil {
635 return ""
636 }
637 equals := " "
638 if k.hasEqualsscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/KV#hasEquals. {
639 equals = " = "
640 }
641 line := stringsscip-go gomod github.com/golang/go/src go1.18 strings/.Repeatscip-go gomod github.com/golang/go/src go1.18 strings/Repeat().(" ", int(k.leadingSpacescip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/KV#leadingSpace.)) + k.Keyscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/KV#Key. + equals + k.Valuescip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/KV#Value. + k.spaceAfterValuescip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/KV#spaceAfterValue.
642 if k.Commentscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/KV#Comment. != "" {
643 line += "#" + k.Commentscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/KV#Comment.
644 }
645 return line
646 }
647
648 // Empty is a line in the config file that contains only whitespace or comments.
649 type Emptyscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Empty# struct {
650 Commentscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Empty#Comment. string
651 leadingSpacescip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Empty#leadingSpace. int // TODO handle spaces vs tabs.
652 positionscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Empty#position. Positionscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Position#
653 }
654
655 // Pos returns e's Position.
656 func (e *Emptyscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Empty#) Posscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Empty#Pos().() Positionscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Position# {
657 return e.positionscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Empty#position.
658 }
659
660 // String prints e as it was parsed in the config file.
661 func (e *Emptyscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Empty#) Stringscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Empty#String().() string {
662 if e == nil {
663 return ""
664 }
665 if e.Commentscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Empty#Comment. == "" {
666 return ""
667 }
668 return fmtscip-go gomod github.com/golang/go/src go1.18 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.18 fmt/Sprintf().("%s#%s", stringsscip-go gomod github.com/golang/go/src go1.18 strings/.Repeatscip-go gomod github.com/golang/go/src go1.18 strings/Repeat().(" ", int(e.leadingSpacescip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Empty#leadingSpace.)), e.Commentscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Empty#Comment.)
669 }
670
671 // Include holds the result of an Include directive, including the config files
672 // that have been parsed as part of that directive. At most 5 levels of Include
673 // statements will be parsed.
674 type Includescip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Include# struct {
675 // Comment is the contents of any comment at the end of the Include
676 // statement.
677 Commentscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Include#Comment. string
678 // an include directive can include several different files, and wildcards
679 directivesscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Include#directives. []string
680
681 muscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Include#mu. syncscip-go gomod github.com/golang/go/src go1.18 sync/.Mutexscip-go gomod github.com/golang/go/src go1.18 sync/Mutex#
682 // 1:1 mapping between matches and keys in files array; matches preserves
683 // ordering
684 matchesscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Include#matches. []string
685 // actual filenames are listed here
686 filesscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Include#files. map[string]*Configscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Config#
687 leadingSpacescip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Include#leadingSpace. int
688 positionscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Include#position. Positionscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Position#
689 depthscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Include#depth. uint8
690 hasEqualsscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Include#hasEquals. bool
691 }
692
693 const maxRecurseDepthscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/maxRecurseDepth. = 5
694
695 // ErrDepthExceeded is returned if too many Include directives are parsed.
696 // Usually this indicates a recursive loop (an Include directive pointing to the
697 // file it contains).
698 var ErrDepthExceededscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/ErrDepthExceeded. = errorsscip-go gomod github.com/golang/go/src go1.18 errors/.Newscip-go gomod github.com/golang/go/src go1.18 errors/New().("ssh_config: max recurse depth exceeded")
699
700 func removeDupsscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/removeDups().(arr []string) []string {
701 // Use map to record duplicates as we find them.
702 encountered := make(map[string]bool, len(arr))
703 result := make([]string, 0)
704
705 for v := range arr {
706 //lint:ignore S1002 I prefer it this way
707 if encountered[arr[v]] == false {
708 encountered[arr[v]] = true
709 result = append(result, arr[v])
710 }
711 }
712 return result
713 }
714
715 // NewInclude creates a new Include with a list of file globs to include.
716 // Configuration files are parsed greedily (e.g. as soon as this function runs).
717 // Any error encountered while parsing nested configuration files will be
718 // returned.
719 func NewIncludescip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/NewInclude().(directives []string, hasEquals bool, pos Positionscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Position#, comment string, system, ignoreMatchDirective bool, depth uint8,
720 ) (*Includescip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Include#, error) {
721 if depth > maxRecurseDepthscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/maxRecurseDepth. {
722 return nil, ErrDepthExceededscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/ErrDepthExceeded.
723 }
724 inc := &Includescip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Include#{
725 Commentscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Include#Comment.: comment,
726 directivesscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Include#directives.: directives,
727 filesscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Include#files.: make(map[string]*Configscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Config#),
728 positionscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Include#position.: pos,
729 leadingSpacescip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Include#leadingSpace.: pos.Colscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Position#Col. - 1,
730 depthscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Include#depth.: depth,
731 hasEqualsscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Include#hasEquals.: hasEquals,
732 }
733 // no need for inc.mu.Lock() since nothing else can access this inc
734 matches := make([]string, 0)
735 for i := range directives {
736 var path string
737 if filepathscip-go gomod github.com/golang/go/src go1.18 `path/filepath`/.IsAbsscip-go gomod github.com/golang/go/src go1.18 `path/filepath`/IsAbs().(directives[i]) {
738 path = directives[i]
739 } else if system {
740 path = filepathscip-go gomod github.com/golang/go/src go1.18 `path/filepath`/.Joinscip-go gomod github.com/golang/go/src go1.18 `path/filepath`/Join().("/etc/ssh", directives[i])
741 } else {
742 path = filepathscip-go gomod github.com/golang/go/src go1.18 `path/filepath`/.Joinscip-go gomod github.com/golang/go/src go1.18 `path/filepath`/Join().(homedirscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/homedir().(), ".ssh", directives[i])
743 }
744 theseMatches, err := filepathscip-go gomod github.com/golang/go/src go1.18 `path/filepath`/.Globscip-go gomod github.com/golang/go/src go1.18 `path/filepath`/Glob().(path)
745 if err != nil {
746 return nil, err
747 }
748 matches = append(matches, theseMatches...)
749 }
750 matches = removeDupsscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/removeDups().(matches)
751 inc.matchesscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Include#matches. = matches
752 for i := range matches {
753 config, err := parseWithDepthscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/parseWithDepth().(matches[i], ignoreMatchDirective, depth)
754 if err != nil {
755 return nil, err
756 }
757 inc.filesscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Include#files.[matches[i]] = config
758 }
759 return inc, nil
760 }
761
762 // Pos returns the position of the Include directive in the larger file.
763 func (i *Includescip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Include#) Posscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Include#Pos().() Positionscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Position# {
764 return i.positionscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Include#position.
765 }
766
767 // Get finds the first value in the Include statement matching the alias and the
768 // given key.
769 func (inc *Includescip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Include#) Getscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Include#Get().(alias, key string) string {
770 inc.muscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Include#mu..Lockscip-go gomod github.com/golang/go/src go1.18 sync/Mutex#Lock().()
771 defer inc.muscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Include#mu..Unlockscip-go gomod github.com/golang/go/src go1.18 sync/Mutex#Unlock().()
772 // TODO: we search files in any order which is not correct
773 for i := range inc.matchesscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Include#matches. {
774 cfg := inc.filesscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Include#files.[inc.matchesscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Include#matches.[i]]
775 if cfg == nil {
776 panic("nil cfg")
777 }
778 val, err := cfg.Getscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Config#Get().(alias, key)
779 if err == nil && val != "" {
780 return val
781 }
782 }
783 return ""
784 }
785
786 // GetAll finds all values in the Include statement matching the alias and the
787 // given key.
788 func (inc *Includescip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Include#) GetAllscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Include#GetAll().(alias, key string) ([]string, error) {
789 inc.muscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Include#mu..Lockscip-go gomod github.com/golang/go/src go1.18 sync/Mutex#Lock().()
790 defer inc.muscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Include#mu..Unlockscip-go gomod github.com/golang/go/src go1.18 sync/Mutex#Unlock().()
791 var vals []string
792
793 // TODO: we search files in any order which is not correct
794 for i := range inc.matchesscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Include#matches. {
795 cfg := inc.filesscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Include#files.[inc.matchesscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Include#matches.[i]]
796 if cfg == nil {
797 panic("nil cfg")
798 }
799 val, err := cfg.GetAllscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Config#GetAll().(alias, key)
800 if err == nil && len(val) != 0 {
801 // In theory if SupportsMultiple was false for this key we could
802 // stop looking here. But the caller has asked us to find all
803 // instances of the keyword (and could use Get() if they wanted) so
804 // let's keep looking.
805 vals = append(vals, val...)
806 }
807 }
808 return vals, nil
809 }
810
811 // String prints out a string representation of this Include directive. Note
812 // included Config files are not printed as part of this representation.
813 func (inc *Includescip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Include#) Stringscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Include#String().() string {
814 equals := " "
815 if inc.hasEqualsscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Include#hasEquals. {
816 equals = " = "
817 }
818 line := fmtscip-go gomod github.com/golang/go/src go1.18 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.18 fmt/Sprintf().("%sInclude%s%s", stringsscip-go gomod github.com/golang/go/src go1.18 strings/.Repeatscip-go gomod github.com/golang/go/src go1.18 strings/Repeat().(" ", int(inc.leadingSpacescip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Include#leadingSpace.)), equals, stringsscip-go gomod github.com/golang/go/src go1.18 strings/.Joinscip-go gomod github.com/golang/go/src go1.18 strings/Join().(inc.directivesscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Include#directives., " "))
819 if inc.Commentscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Include#Comment. != "" {
820 line += " #" + inc.Commentscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Include#Comment.
821 }
822 return line
823 }
824
825 var matchAllscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/matchAll. *Patternscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Pattern#
826
827 func initscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/init().() {
828 var err error
829 matchAllscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/matchAll., err = NewPatternscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/NewPattern().("*")
830 if err != nil {
831 panic(err)
832 }
833 }
834
835 func newConfigscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/newConfig().() *Configscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Config# {
836 return &Configscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Config#{
837 Hostsscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Config#Hosts.: []*Hostscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Host#{
838 &Hostscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Host#{
839 implicitscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Host#implicit.: true,
840 Patternsscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Host#Patterns.: []*Patternscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Pattern#{matchAllscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/matchAll.},
841 Nodesscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Host#Nodes.: make([]Nodescip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Node#, 0),
842 },
843 },
844 depthscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Config#depth.: 0,
845 }
846 }