mirror of
https://github.com/ScuroNeko/mtg.git
synced 2026-08-31 12:54:01 +03:00
Add command for generating secrets
This commit is contained in:
@@ -1,18 +1,41 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"github.com/alecthomas/kong"
|
||||
)
|
||||
|
||||
var version = "dev" // has to be set by ldflags
|
||||
|
||||
type CLI struct {
|
||||
GenerateSecret struct {
|
||||
HostName string `arg optional help:"Hostname to use for domain fronting. Default is '${domain_front}'." name:"hostname" default:"${domain_front}"`
|
||||
Hex bool `help:"Print secret in hex encoding."`
|
||||
} `cmd help:"Generate new proxy secret."`
|
||||
Access struct {
|
||||
ConfigPath string `arg required type:"existingfile" help:"Path to the configuration file." name:"config-path"`
|
||||
} `cmd help:"Print access information."`
|
||||
Run struct {
|
||||
ConfigPath string `arg required type:"existingfile" help:"Path to the configuration file." name:"config-path"`
|
||||
} `cmd help:"Run proxy."`
|
||||
}
|
||||
|
||||
func main() {
|
||||
rand.Seed(time.Now().UTC().UnixNano())
|
||||
|
||||
f, _ := os.Open("example.config.toml")
|
||||
cli := &CLI{}
|
||||
ctx := kong.Parse(cli, kong.Vars{
|
||||
"domain_front": "amazonaws.com",
|
||||
"config_path": "/etc/mtg.toml",
|
||||
})
|
||||
|
||||
fmt.Println(parseConfig(f))
|
||||
switch ctx.Command() {
|
||||
case "generate-secret":
|
||||
runGenerateSecret(cli)
|
||||
case "access":
|
||||
case "run":
|
||||
panic("not implemented yet")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user