-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue 14: Wildcard hosts #19
base: main
Are you sure you want to change the base?
Conversation
* Add test for prefixed and trailing wildcard, and ensure both cases are handled correctly. * Accidentally covered a few uncovered lines in `lexer.go` with the new tests.
* Added logic to handle MACs, Ciphers and Forwards. * Added tests for the mentioned additions. * Currently we are **only** appending to the fields of the basic host config. That means that it gets its own values *and* those of the wildcard host.
…d host handling in `Includes` I thought about the best way to do it, and came up with the decision to **not** duplicate code. This required the breakdown of the `parse` function, and the creation of a function that would handle **ONLY** the extraction of host data. Without default values and such. It has a boolean parameter to return either only the virtual or actual hosts.
So, the last commit does a big change in my opinion, and I will try to explain my train of thoughts. At the beginning I was using two variables to save Virtual and Actual hosts in the
So using option 3, I separated a large chunk of the code in a new function. Tests pass, coverage did not drop and the virtual hosts seem to be working correctly now. Of course I understand this might not be so easy to review but I'm willing to assist any way I can. |
Issue: #14
Currently this PR is marked as draft, because I'd love to clear out the
TODO
at the bottom and probably address requests from reviews if there are such.Still I've tested this locally and at the moment it suits my (rather basic) needs well.
Here is a quick outline of the made changes:
Changes
Port
value is read from config or if we are using the hardcoded one.sshConfigs
array, we cycle through it and in case thePort
is0
(the default one) we set it to22
.wildcardHosts
variable. Where we were adding the host to the config, now we do additional check to see if it is an actual host or a wildcard one. If it is wildcard it goes in to the new variable.wildcardHosts
added. If we have we callapplyWildcardRules
with the hosts and wildcard hosts.Host
values using regex in the form of^wildcard$
where wildcard is theHost
value with*
replaced with.*
.mergeSSHConfigs
.nil
on success andError
otherwise.if
/else
conditions and I try to not do that.TestMultiWildcard
,TestUnmatchedWildcardBetween
,TestUnmatchedWildcardPrefix
,TestUnmatchedWildcardPost
. Each of them tests a different placement of the wildcard and one of them tests multiple wildcards.TODO - Already addressed in latest commit.
LocalForwards
,RemoteForwards
,DynamicForwards
- Currently we do not handle those. Might need to implement them specifically and not use reflection, must check. - ✔️Ciphers
,MACs
- First attempt at using reflection to add to a string array failed. Either read/try a bit more to make it work or do not use reflection, must check. - ✔️Include
ed file, it will be applied only to hosts inside this include. - ✔️