Skip to content
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

Incorrectly drops duplicates of some keywords #4

Open
lsowen opened this issue Jul 5, 2021 · 2 comments
Open

Incorrectly drops duplicates of some keywords #4

lsowen opened this issue Jul 5, 2021 · 2 comments

Comments

@lsowen
Copy link

lsowen commented Jul 5, 2021

First off, thank you for this package, definitely making my life easier. However, I did notice an issue where a keyword (in my case LocalForward) is dropped if it is specified more than once for a host.

Example input:

Host server
     Hostname server.example.com
     ServerAliveInterval 300
     PubkeyAuthentication yes
     IdentitiesOnly no
     LocalForward 8443 api.internal.example.com:443
     LocalForward 9443 api-02.internal.example.com:443

Example program

from pathlib import Path
import pysshconfig


sshconfig_path = Path('./ssh_config')
with sshconfig_path.open('r') as input_fp:
    sshconfig = pysshconfig.load(input_fp)

with sshconfig_path.open('w') as output_fp:
    pysshconfig.dump(results, output_fp)

Expected that the output be the same as the input. Actual:

Host server
     Hostname server.example.com
     ServerAliveInterval 300
     PubkeyAuthentication yes
     IdentitiesOnly no
     LocalForward 8443 api.internal.example.com:443

I am using version 0.0.2

@zfrank
Copy link
Owner

zfrank commented Jul 12, 2021

Thanks for raising this! You're correct, pysshconfig assumes that there will only be one instance of each keyword inside a Host block. That was an oversight on my part. I'll come up with a solution.

@lsowen
Copy link
Author

lsowen commented Jul 13, 2021

Maybe a dict of sets? eg:

{
   "Hostname": set("server.example.com"),
...
}

I don't know if every option allows duplicates? Or maybe just some of them?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants