mirror of
https://github.com/ScuroNeko/mtg.git
synced 2026-09-01 01:24:02 +03:00
FILE / ScuroNeko/mtg
cli/generate_secret.go
Исходный файл и его история в репозитории.
27 lines
570 B
Go
27 lines
570 B
Go
package cli
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/9seconds/mtg/v2/mtglib"
|
|
)
|
|
|
|
type GenerateSecret struct {
|
|
base `kong:"-"`
|
|
|
|
HostName string `kong:"arg,required,help='Hostname to use for domain fronting.',name='hostname'"`
|
|
Hex bool `kong:"help='Print secret in hex encoding.',short='x'"`
|
|
}
|
|
|
|
func (c *GenerateSecret) Run(cli *CLI, _ string) error {
|
|
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
|
|
}
|