diff --git a/backend/api/api.go b/backend/api/api.go index 0ca447b1..11c16aa0 100644 --- a/backend/api/api.go +++ b/backend/api/api.go @@ -163,6 +163,11 @@ func (a *APIHandler) getHandler(c *gin.Context) { count := c.Query("c") changes := a.ConfigService.GetChanges(actor, chngKey, count) jsonObj(c, changes, nil) + case "keypairs": + kType := c.Query("k") + options := c.Query("o") + keypair := a.ServerService.GenKeypair(kType, options) + jsonObj(c, keypair, nil) default: jsonMsg(c, "API call", nil) } diff --git a/backend/service/server.go b/backend/service/server.go index e4a92fd2..c81b273c 100644 --- a/backend/service/server.go +++ b/backend/service/server.go @@ -159,3 +159,23 @@ func (s *ServerService) GetLogs(service string, count string, level string) []st return lines } + +func (s *ServerService) GenKeypair(keyType string, options string) []string { + if len(keyType) == 0 { + return []string{"No keypair to generate"} + } + sbExec := s.GetBinaryPath() + cmdArgs := []string{"generate", keyType + "-keypair"} + if keyType == "tls" || keyType == "ech" { + cmdArgs = append(cmdArgs, options) + } + // Run the command + cmd := exec.Command(sbExec, cmdArgs...) + var out bytes.Buffer + cmd.Stdout = &out + err := cmd.Run() + if err != nil { + return []string{"Failed to generate keypair"} + } + return strings.Split(out.String(), "\n") +} diff --git a/frontend/src/components/Ech.vue b/frontend/src/components/Ech.vue index 1c0edb97..933e7ff9 100644 --- a/frontend/src/components/Ech.vue +++ b/frontend/src/components/Ech.vue @@ -30,9 +30,23 @@ >{{ $t('tls.useText') }} + + + + + + {{ $t('actions.generate') }} + + + - + - + - + @@ -63,15 +79,61 @@