From f4a5abeed975ac361f048ace1966325762316a17 Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Tue, 24 Sep 2019 12:19:28 -0700 Subject: [PATCH] Go CLI work --- {ext/misc => attic}/linux-old-glibc-compat.c | 0 go/cmd/zerotier/cli/service.go | 18 +++ go/cmd/zerotier/cli/status.go | 18 +++ go/cmd/zerotier/zerotier.go | 112 ++++++++++++++++++- go/go.mod | 2 +- go/pkg/zerotier/localconfig.go | 12 +- go/pkg/zerotier/node.go | 2 +- 7 files changed, 154 insertions(+), 10 deletions(-) rename {ext/misc => attic}/linux-old-glibc-compat.c (100%) create mode 100644 go/cmd/zerotier/cli/service.go create mode 100644 go/cmd/zerotier/cli/status.go diff --git a/ext/misc/linux-old-glibc-compat.c b/attic/linux-old-glibc-compat.c similarity index 100% rename from ext/misc/linux-old-glibc-compat.c rename to attic/linux-old-glibc-compat.c diff --git a/go/cmd/zerotier/cli/service.go b/go/cmd/zerotier/cli/service.go new file mode 100644 index 000000000..ce1eefb1d --- /dev/null +++ b/go/cmd/zerotier/cli/service.go @@ -0,0 +1,18 @@ +/* + * Copyright (c)2019 ZeroTier, Inc. + * + * Use of this software is governed by the Business Source License included + * in the LICENSE.TXT file in the project's root directory. + * + * Change Date: 2023-01-01 + * + * On the date above, in accordance with the Business Source License, use + * of this software will be governed by version 2.0 of the Apache License. + */ +/****/ + +package cli + +// Service is "zerotier service ..." +func Service(args []string) { +} diff --git a/go/cmd/zerotier/cli/status.go b/go/cmd/zerotier/cli/status.go new file mode 100644 index 000000000..61578200f --- /dev/null +++ b/go/cmd/zerotier/cli/status.go @@ -0,0 +1,18 @@ +/* + * Copyright (c)2019 ZeroTier, Inc. + * + * Use of this software is governed by the Business Source License included + * in the LICENSE.TXT file in the project's root directory. + * + * Change Date: 2023-01-01 + * + * On the date above, in accordance with the Business Source License, use + * of this software will be governed by version 2.0 of the Apache License. + */ +/****/ + +package cli + +// Status shows service status info +func Status(args []string) { +} diff --git a/go/cmd/zerotier/zerotier.go b/go/cmd/zerotier/zerotier.go index fb3d6237f..98aafc984 100644 --- a/go/cmd/zerotier/zerotier.go +++ b/go/cmd/zerotier/zerotier.go @@ -14,11 +14,71 @@ package main import ( + "flag" + "fmt" "os" - "os/signal" - "syscall" + "zerotier/cmd/zerotier/cli" + "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] [-options] [command args] + +Global Options + -j Output raw JSON where applicable + -p Connect to service running at this path + -t 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 [options] Add a VL1 root + static [...] Add a root with a set identity and IPs + dynamic [default locator] Add a dynamic root fetched by name + removeroot [options] Remove a VL1 root + static Remove a root with a set identity + dynamic Remove a dynamic root fetched by name + networks Show joined VL2 virtual networks + join Join a virtual network + leave Leave a virtual network + show Show verbose network info + set