This commit is contained in:
Adam Ierymenko 2019-09-24 16:44:29 -07:00
commit e5bd230fb0
No known key found for this signature in database
GPG key ID: C8877CF2D7A5D7F3
15 changed files with 197 additions and 42 deletions

View file

@ -14,5 +14,5 @@
package cli
// AddRoot CLI command
func AddRoot(args []string) {
func AddRoot(basePath, authToken string, args []string) {
}

View file

@ -14,5 +14,5 @@
package cli
// Join CLI command
func Join(args []string) {
func Join(basePath, authToken string, args []string) {
}

View file

@ -14,5 +14,5 @@
package cli
// Leave CLI command
func Leave(args []string) {
func Leave(basePath, authToken string, args []string) {
}

View file

@ -14,5 +14,5 @@
package cli
// Networks CLI command
func Networks(args []string) {
func Networks(basePath, authToken string, args []string) {
}

View file

@ -14,5 +14,5 @@
package cli
// Peers CLI command
func Peers(args []string) {
func Peers(basePath, authToken string, args []string) {
}

View file

@ -14,5 +14,5 @@
package cli
// RemoveRoot CLI command
func RemoveRoot(args []string) {
func RemoveRoot(basePath, authToken string, args []string) {
}

View file

@ -14,5 +14,5 @@
package cli
// Roots CLI command
func Roots(args []string) {
func Roots(basePath, authToken string, args []string) {
}

View file

@ -13,6 +13,17 @@
package cli
// Service is "zerotier service ..."
func Service(args []string) {
/*
func nodeStart() {
osSignalChannel := make(chan os.Signal, 2)
signal.Notify(osSignalChannel, syscall.SIGTERM, syscall.SIGQUIT, syscall.SIGINT, syscall.SIGBUS)
signal.Ignore(syscall.SIGUSR1, syscall.SIGUSR2)
go func() {
<-osSignalChannel
}()
}
*/
// Service is "zerotier service ..."
func Service(basePath, authToken string, args []string) {
}

View file

@ -14,5 +14,5 @@
package cli
// Set CLI command
func Set(args []string) {
func Set(basePath, authToken string, args []string) {
}

View file

@ -14,5 +14,5 @@
package cli
// Show CLI command
func Show(args []string) {
func Show(basePath, authToken string, args []string) {
}

View file

@ -13,6 +13,37 @@
package cli
import (
"encoding/json"
"fmt"
"net/http"
"os"
"zerotier/pkg/zerotier"
)
// Status shows service status info
func Status(args []string) {
func Status(basePath, authToken string, args []string, jsonOutput bool) {
var status zerotier.APIStatus
statusCode, err := zerotier.APIGet(basePath, zerotier.APISocketName, authToken, "/status", &status)
if err != nil {
fmt.Printf("FATAL: API response code %d: %s\n", statusCode, err.Error())
os.Exit(1)
return
}
if statusCode != http.StatusOK {
if statusCode == http.StatusUnauthorized {
fmt.Printf("FATAL: API response code %d: unauthorized (authorization token incorrect)\n", statusCode)
}
fmt.Printf("FATAL: API response code %d\n", statusCode)
os.Exit(1)
return
}
if jsonOutput {
j, _ := json.MarshalIndent(&status, "", " ")
fmt.Println(string(j))
} else {
}
os.Exit(0)
}