mirror of
https://github.com/ScuroNeko/mtg.git
synced 2026-08-31 15:34:01 +03:00
FILE / ScuroNeko/mtg
cli_generate_secret.go
Исходный файл и его история в репозитории.
27 lines
642 B
Go
27 lines
642 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/9seconds/mtg/v2/mtglib"
|
|
)
|
|
|
|
type cliCommandGenerateSecret struct {
|
|
cli
|
|
|
|
HostName string `arg optional help:"Hostname to use for domain fronting. Default is '${domain_front}'." name:"hostname" default:"${domain_front}"` // nolint: lll, govet
|
|
Hex bool `help:"Print secret in hex encoding."`
|
|
}
|
|
|
|
func (c *cliCommandGenerateSecret) Run(cli *CLI) error { // nolint: unparam
|
|
secret := mtglib.GenerateSecret(cli.GenerateSecret.HostName)
|
|
|
|
if cli.GenerateSecret.Hex {
|
|
fmt.Println(secret.Hex()) // nolint: forbidigo
|
|
} else {
|
|
fmt.Println(secret.Base64()) // nolint: forbidigo
|
|
}
|
|
|
|
return nil
|
|
}
|