Skip to content

Commit

Permalink
feat: add easy way to generate keypairs from the cli
Browse files Browse the repository at this point in the history
  • Loading branch information
soerenschneider committed Jul 5, 2023
1 parent 13695df commit 5632aa8
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions cmd/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@ var (
"/etc/dyndns/client.json",
"~/.dyndns/config.json",
}
configPath string
once bool
cmdVersion bool
configPath string
once bool
cmdVersion bool
cmdGenKeypair bool
)

func main() {
Expand All @@ -40,6 +41,10 @@ func main() {
os.Exit(0)
}

if cmdGenKeypair {
generateKeypair()
}

util.InitLogging()
if configPath == "" {
configPath = getDefaultConfigFileOrEmpty()
Expand Down Expand Up @@ -192,3 +197,17 @@ func getKeypair(path string) verification.SignatureKeypair {

return keypair
}

func generateKeypair() {
keypair, err := verification.NewKeyPair()
if err != nil {
log.Fatal().Msgf("Can not create keypair: %v", err)
}

jsonEncoded, err := keypair.AsJson()
if err != nil {
log.Fatal().Err(err).Msg("could not marshall keypair")
}
fmt.Printf("%s\n", jsonEncoded)
os.Exit(0)
}

0 comments on commit 5632aa8

Please sign in to comment.