Commit Graph

10 Commits

Author SHA1 Message Date
Mark Nevill
14846fb743 all: rewrite the lexer to consume the entire input first
Previously we used the buffruneio package to buffer input. However,
the error handling was not good, and we would often panic when parsing
inputs.

SSH config files are generally not large, on the order of kilobytes or
megabytes, and it's fine to just read the entire thing into memory and
then parse from there. This also simplifies the parser significantly
and lets us remove a dependency and several defer calls.

Add a test that panicked with the old version and then modify the code
to ensure the test no longer panics.

Thanks to Mark Nevill (@devnev) for the initial error report and
failing test case.

Fixes #10.
Fixes #24.
2019-07-24 10:52:01 -10:00
Kevin Burke
f648cfb84b all: use ints instead of uints
Files are small and these are cheap enough that we should be more
worried about overflow errors than the space cost.
2019-06-29 20:37:49 -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
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
2b54512628 switch staticcheck for megacheck and fix things it complains about 2017-05-26 10:01:24 -07: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
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
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