diff options
Diffstat (limited to 'web/service/server.go')
| -rw-r--r-- | web/service/server.go | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/web/service/server.go b/web/service/server.go index c73fce57..f2540252 100644 --- a/web/service/server.go +++ b/web/service/server.go @@ -390,3 +390,29 @@ func (s *ServerService) GetDb() ([]byte, error) { return fileContents, nil } + +func (s *ServerService) GetNewX25519Cert() (interface{}, error) { + // Run the command + cmd := exec.Command(xray.GetBinaryPath(), "x25519") + var out bytes.Buffer + cmd.Stdout = &out + err := cmd.Run() + if err != nil { + return nil, err + } + + lines := strings.Split(out.String(), "\n") + + privateKeyLine := strings.Split(lines[0], ":") + publicKeyLine := strings.Split(lines[1], ":") + + privateKey := strings.TrimSpace(privateKeyLine[1]) + publicKey := strings.TrimSpace(publicKeyLine[1]) + + keyPair := map[string]interface{}{ + "privateKey": privateKey, + "publicKey": publicKey, + } + + return keyPair, nil +} |
