naggie / dsnet

FAST command to manage a centralised wireguard VPN. Think wg-quick but quicker: key generation + address allocation.
https://calbryant.uk/blog/how-to-set-up-a-wireguard-vpn-in-minutes-with-dsnet/
MIT License
673 stars 33 forks source link

cobra and viper support for non interactive use #40

Closed xsteadfastx closed 3 years ago

xsteadfastx commented 3 years ago

This PR is the plan to include cobra and viper to dsnet for abilities for non-interactive use like suggested in #17.

xsteadfastx commented 3 years ago

this would be just a beginning. next thing would be adding flags for the things the prompt asks for.

botto commented 3 years ago

Excellent, this looks great.

Not as part of this PR but what would you think of maybe using viper to handle the config in general, as it supports other formats too?

xsteadfastx commented 3 years ago

Excellent, this looks great.

Not as part of this PR but what would you think of maybe using viper to handle the config in general, as it supports other formats too?

yes this would be great... in the init command we could add a flag for the config file format you want to have... json standard and yaml/toml as option.

naggie commented 3 years ago

Thanks @xsteadfastx -- will review and test this as soon as I can. Cobra/viper seems to be the library to use.

Regarding supporting toml or other configuration file support; this isn't an option as the configuration file (well, database) is edited programmatically so comments can't be retained.

xsteadfastx commented 3 years ago

Thanks

i never used this but viper also supports writing config files... so there is a chance to support multiple formats: https://github.com/spf13/viper#writing-config-files

but this is just... a niche feature :)

i hope my PR is ok and that you find it useful. thank you for this wonderful piece of software... making everything a little easier!

xsteadfastx commented 3 years ago

Btw, just tested it in a productive environment for myself and i could add all the new peers in a scripted way, with success!

naggie commented 3 years ago

note for myself -- check out https://github.com/AlecAivazis/survey for the interactive stuff.

Sorry @xsteadfastx still haven't got round to reviewing. Will do in the next week hopefully

xsteadfastx commented 3 years ago

no problem :) i just can say we use my PR fork here in production... generating alot of client configs on the fly through ansible... without any problems so far :)

botto commented 3 years ago

no problem :) i just can say we use my PR fork here in production... generating alot of client configs on the fly through ansible... without any problems so far :)

That's very encouraging. Nice to hear it's a useful tool

botto commented 3 years ago

Hey @xsteadfastx I created a PR with some suggestions against your branch https://github.com/xsteadfastx/dsnet/pull/1

I think we probably want to keep the CLI interface backwards compatible and not have the usage confusing when using the CLI as a human and not a script

xsteadfastx commented 3 years ago

Hey @xsteadfastx I created a PR with some suggestions against your branch xsteadfastx#1

I think we probably want to keep the CLI interface backwards compatible and not have the usage confusing when using the CLI as a human and not a script

yes this is a really good idea. cool thanks for your input to get this merged and be compatible... :)

botto commented 3 years ago

Thank you @xsteadfastx !