This commit is contained in:
Adam Ierymenko 2019-09-25 12:36:49 -07:00
commit 8a9669f130
No known key found for this signature in database
GPG key ID: C8877CF2D7A5D7F3
6 changed files with 307 additions and 79 deletions

View file

@ -25,62 +25,6 @@ import (
"zerotier/pkg/zerotier"
)
var copyrightText = fmt.Sprintf(`ZeroTier Network Virtualization Service Version %d.%d.%d
(c)2019 ZeroTier, Inc.
Licensed under the ZeroTier BSL (see LICENSE.txt)`, zerotier.CoreVersionMajor, zerotier.CoreVersionMinor, zerotier.CoreVersionRevision)
func printHelp() {
fmt.Println(copyrightText + `
Usage: zerotier [-options] <command> [-options] [command args]
Global Options
-j Output raw JSON where applicable
-p <path> Connect to service running at this path
-t <authtoken.secret path> Use secret auth token from this file
Commands:
help Show this help
version Print version
service [path] Start in system service mode
status Show ZeroTier service status and config
peers Show VL1 peers
roots Show VL1 root servers
addroot <type> [options] Add a VL1 root
static <identity> <ip/port> [...] Add a root with a set identity and IPs
dynamic <name> [default locator] Add a dynamic root fetched by name
removeroot <type> [options] Remove a VL1 root
static <identity> Remove a root with a set identity
dynamic <name> Remove a dynamic root fetched by name
networks Show joined VL2 virtual networks
join <network ID> Join a virtual network
leave <network ID> Leave a virtual network
show <network ID> Show verbose network info
set <network ID> <option> <value> Set a network local config option
manageips <boolean> Is IP management allowed?
manageroutes <boolean> Is route management allowed?
globalips <boolean> Can IPs in global IP space be managed?
globalroutes <boolean> Can global IP space routes be set?
defaultroute <boolean> Can default route be overridden?
set <local config option> <value> Set a local configuration option
phy <IP/bits> blacklist <boolean> Set or clear blacklist for CIDR
phy <IP/bits> trust <path ID/0> Set or clear trusted path ID for CIDR
virt <address> try <IP/port> [...] Set explicit IPs for reaching a peer
port <port> Set primary local port for VL1 P2P
secondaryport <port/0> Set or disable secondary VL1 P2P port
tertiaryport <port/0> Set or disable tertiary VL1 P2P port
portsearch <boolean> Set or disable port search on startup
portmapping <boolean> Set or disable use of uPnP and NAT-PMP
explicitaddresses <IP/port> [...] Set explicit external IPs to advertise
Most commands require a secret token to permit control of a running ZeroTier
service. The CLI will automatically try to read this token from the
authtoken.secret file in the service's working directory and then from a
file called .zerotierauth in the user's home directory. The -t option can be
used to explicitly specify a location.
`)
}
func readAuthToken(basePath string) string {
data, _ := ioutil.ReadFile(path.Join(basePath, "authtoken.secret"))
if len(data) > 0 {
@ -118,13 +62,13 @@ func main() {
tflag := globalOpts.String("t", "", "")
err := globalOpts.Parse(os.Args[1:])
if err != nil {
printHelp()
cli.Help()
os.Exit(1)
return
}
args := globalOpts.Args()
if len(args) < 1 || *hflag {
printHelp()
cli.Help()
os.Exit(0)
return
}
@ -151,7 +95,7 @@ func main() {
switch args[0] {
case "help":
printHelp()
cli.Help()
os.Exit(0)
case "version":
fmt.Printf("%d.%d.%d\n", zerotier.CoreVersionMajor, zerotier.CoreVersionMinor, zerotier.CoreVersionRevision)
@ -180,6 +124,6 @@ func main() {
cli.Set(basePath, authToken, cmdArgs)
}
printHelp()
cli.Help()
os.Exit(1)
}