mirror of
https://github.com/livekit/livekit.git
synced 2026-08-22 09:59:51 +00:00
Deprecate generate-keys
This commit is contained in:
+16
-3
@@ -37,14 +37,27 @@ import (
|
||||
"github.com/livekit/livekit-server/pkg/service"
|
||||
)
|
||||
|
||||
func generateKeys(_ context.Context, _ *cli.Command) error {
|
||||
func generateKeyFile(_ context.Context, c *cli.Command) error {
|
||||
filename := c.String("key-file")
|
||||
|
||||
file, err := os.OpenFile(filename, os.O_WRONLY|os.O_CREATE|os.O_EXCL, 0o600)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
apiKey := guid.New(utils.APIKeyPrefix)
|
||||
secret := utils.RandomSecret()
|
||||
fmt.Println("API Key: ", apiKey)
|
||||
fmt.Println("API Secret: ", secret)
|
||||
|
||||
file.WriteString(fmt.Sprintf("%s: %s", apiKey, secret))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func generateKeys(_ context.Context, _ *cli.Command) error {
|
||||
return fmt.Errorf("DEPRECATED. Use generete-key-file instead")
|
||||
}
|
||||
|
||||
func printPorts(_ context.Context, c *cli.Command) error {
|
||||
conf, err := getConfig(c)
|
||||
if err != nil {
|
||||
|
||||
@@ -144,6 +144,18 @@ func main() {
|
||||
Usage: "generates an API key and secret pair",
|
||||
Action: generateKeys,
|
||||
},
|
||||
{
|
||||
Name: "generate-key-file",
|
||||
Usage: "generates an API key and secret pair and write them to a key file",
|
||||
Action: generateKeyFile,
|
||||
Flags: []cli.Flag{
|
||||
&cli.StringFlag{
|
||||
Name: "key-file",
|
||||
Usage: "filename for the key file",
|
||||
Required: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "ports",
|
||||
Usage: "print ports that server is configured to use",
|
||||
|
||||
Reference in New Issue
Block a user