This commit is contained in:
Adam Ierymenko 2019-10-01 13:09:53 -07:00
parent 1711cced3e
commit d1b780c7be
No known key found for this signature in database
GPG key ID: C8877CF2D7A5D7F3
4 changed files with 99 additions and 9 deletions

View file

@ -38,6 +38,23 @@ func apiGet(basePath, authToken, urlPath string, result interface{}) {
}
}
func apiPost(basePath, authToken, urlPath string, post, result interface{}) {
statusCode, err := zerotier.APIPost(basePath, zerotier.APISocketName, authToken, urlPath, post, result)
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
}
}
func enabledDisabled(f bool) string {
if f {
return "ENABLED"