15 Commits

Author SHA1 Message Date
Sylvie Crowe ed12436768 Allow User to Ignore Match Directive (#5)
* Add the possibility to ignore the Match directive

* cleanup

* cleanup

* cleanup

* cleanup

* fix: duplicated code leftover from merge

* fix: match directive bypass for GetAll

The new ignoreMatchDirective flag needed to be added in one other place.

---------

Co-authored-by: fferro <francesco.ferro@yahooinc.com>
2024-10-27 16:23:32 -07:00
Sylvie Crowe cba6b6a60f Add reload config (#2)
* add function that can clear cached config files

Once the first call to `Get()`, `GetStrict()`, `GetAll()`,
or`GetAllStrict()` has been made, the contents of the config files will
be cached for all future calls to any of those functions. This can be
frustrating if the user wants to capture changes to the config file that
were made externally. This
change adds the `ClearCachedConfigs()` function to provide control over
that.

* change ClearCachedConfigs to ReloadConfigs

Clearing cached data is somewhat vague and could be more confusing to
users who are not familiar with this library. But Reloading the config
data is very straightforward. For this reason, the ability to clear the
cache has been replaced with the ability to reload.

The reload simply clears the cache and then loads the contents again.

Additionally, this contains a bug fix that ensure the loadConfigs
pointer is set to a non-null value before it is used.

* add tests for reloading ssh config files

This adds 2 tests. The first checks that ssh config data is cached and
does not update if the file changes afterward. The second checks that
the `ReloadConfigs()` function will discard the cached data and load the
current config file contents.
2024-03-05 19:38:17 -08:00
Scott Lessans 9b1b4df300 config: fix EOL whitespace for key/value pairs and Host lines
See the description in the CHANGELOG - we were handling this
incorrectly and attaching whitespace to the end of values where that
didn't make much sense to do.
2022-03-31 10:57:24 -07:00
Kevin Burke c7f8dec5c7 fuzz_test: add fuzz tests
Also add a sample corpus.
2021-11-02 14:58:53 -07:00
Dustin Spicuzza 124166206d Support retrieving multiple values for a given keyword
IdentityFile among others supports being provided multiple times and
aggregated across, potentially, multiple files. Support that workflow
by adding GetAll and GetAllStrict alongside the current functions.
2021-03-27 13:38:21 -07:00
Kevin Burke 555f37af0a Correctly parse files without trailing newline
If the file did not have a newline character as the last character,
parseKV() would panic with an NPE. Handle the parser changes better.

Fixes #21.
2018-08-30 14:46:27 -06:00
Eugene Terentev fe204ef364 Fix DOS line endings parsing
Previously we would fail to lex lines ending with CRLF properly.
2018-03-17 10:50:38 -07:00
Sergey Lukjanov c665f6f442 Fix potential index out of range error
I had some extra spaces and junk in my ssh config and it was causing
this part of the code to fail with an out of range error.
2018-01-27 11:46:18 -08:00
Kevin Burke 7897293c53 Cleanup for public release
- Test Include string representation

- Add docs and examples
2017-05-25 08:00:10 -07:00
Kevin Burke 1c4ddb97d7 use Default() and validate() 2017-05-24 21:30:13 -07:00
Kevin Burke c20644453d add Default() and start of a validate() function 2017-05-24 10:11:10 -07:00
Kevin Burke 54fabb9a37 Implement Include directive
It's tricky because it involves recursive filesystem parsing, depth
checking and glob matching. But figured it out.

Fixes #4.
2017-05-23 20:09:31 -07:00
Kevin Burke ad36f0d71a Implement negative match
Fixes #3.
2017-04-23 16:39:17 -07:00
Kevin Burke 67c39ca6b4 Implement Get and wildcard match
Lots of changes and new API's here.

Fixes #7.
2017-04-23 11:42:22 -07:00
Kevin Burke 29f594a81c Add alpha SSH config parser
The error handling is nonexistent and there's no easy way to get
data out. But we can parse a SSH config file into a Go struct, and
roundtrip that struct back to a file that looks (roughly) the same.
2017-04-17 11:08:10 -07:00