initial: ZeroTier-like P2P mesh VPN server with multi-tenant Web UI
This commit is contained in:
36
cmd/zeromesh-cli/main.go
Normal file
36
cmd/zeromesh-cli/main.go
Normal file
@@ -0,0 +1,36 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"zeromesh/internal/identity"
|
||||
)
|
||||
|
||||
func main() {
|
||||
var cmd string
|
||||
flag.StringVar(&cmd, "cmd", "", "command: gen-identity | show-identity")
|
||||
flag.Parse()
|
||||
|
||||
switch cmd {
|
||||
case "gen-identity":
|
||||
id := identity.Generate()
|
||||
data, _ := id.Serialize()
|
||||
fmt.Println(data)
|
||||
case "show-identity":
|
||||
idPath := flag.Arg(0)
|
||||
if idPath == "" {
|
||||
idPath = "./data/agent.identity"
|
||||
}
|
||||
id, err := identity.LoadOrGenerate(idPath)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "error: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
fmt.Printf("Address: %s\n", id.Address)
|
||||
fmt.Printf("Public: %s\n", id.PublicKeyHex())
|
||||
default:
|
||||
fmt.Println("Usage: zeromesh-cli -cmd=gen-identity")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user