summaryrefslogtreecommitdiff
path: root/one.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'one.cpp')
-rw-r--r--one.cpp27
1 files changed, 26 insertions, 1 deletions
diff --git a/one.cpp b/one.cpp
index 727044de..e5884557 100644
--- a/one.cpp
+++ b/one.cpp
@@ -299,7 +299,7 @@ static int cli(int argc,char **argv)
responseHeaders,
responseBody);
if (scode == 200) {
- printf("%s",cliFixJsonCRs(responseBody).c_str());
+ printf("%s", cliFixJsonCRs(responseBody).c_str());
return 0;
} else {
printf("%u %s %s" ZT_EOL_S,scode,command.c_str(),responseBody.c_str());
@@ -308,6 +308,11 @@ static int cli(int argc,char **argv)
} else if ((command == "info")||(command == "status")) {
const unsigned int scode = Http::GET(1024 * 1024 * 16,60000,(const struct sockaddr *)&addr,"/status",requestHeaders,responseHeaders,responseBody);
+ if (scode == 0) {
+ printf("Error connecting to the ZeroTier service: %s\n\nPlease check that the service is running and that TCP port 9993 can be contacted via 127.0.0.1." ZT_EOL_S, responseBody.c_str());
+ return 1;
+ }
+
nlohmann::json j;
try {
j = OSUtils::jsonParse(responseBody);
@@ -338,6 +343,11 @@ static int cli(int argc,char **argv)
} else if (command == "listpeers") {
const unsigned int scode = Http::GET(1024 * 1024 * 16,60000,(const struct sockaddr *)&addr,"/peer",requestHeaders,responseHeaders,responseBody);
+ if (scode == 0) {
+ printf("Error connecting to the ZeroTier service: %s\n\nPlease check that the service is running and that TCP port 9993 can be contacted via 127.0.0.1." ZT_EOL_S, responseBody.c_str());
+ return 1;
+ }
+
nlohmann::json j;
try {
j = OSUtils::jsonParse(responseBody);
@@ -400,6 +410,11 @@ static int cli(int argc,char **argv)
} else if (command == "listnetworks") {
const unsigned int scode = Http::GET(1024 * 1024 * 16,60000,(const struct sockaddr *)&addr,"/network",requestHeaders,responseHeaders,responseBody);
+ if (scode == 0) {
+ printf("Error connecting to the ZeroTier service: %s\n\nPlease check that the service is running and that TCP port 9993 can be contacted via 127.0.0.1." ZT_EOL_S, responseBody.c_str());
+ return 1;
+ }
+
nlohmann::json j;
try {
j = OSUtils::jsonParse(responseBody);
@@ -504,6 +519,11 @@ static int cli(int argc,char **argv)
} else if (command == "listmoons") {
const unsigned int scode = Http::GET(1024 * 1024 * 16,60000,(const struct sockaddr *)&addr,"/moon",requestHeaders,responseHeaders,responseBody);
+ if (scode == 0) {
+ printf("Error connecting to the ZeroTier service: %s\n\nPlease check that the service is running and that TCP port 9993 can be contacted via 127.0.0.1." ZT_EOL_S, responseBody.c_str());
+ return 1;
+ }
+
nlohmann::json j;
try {
j = OSUtils::jsonParse(responseBody);
@@ -619,6 +639,11 @@ static int cli(int argc,char **argv)
requestHeaders["Content-Length"] = cl;
const unsigned int scode = Http::GET(1024 * 1024 * 16,60000,(const struct sockaddr *)&addr,"/network",requestHeaders,responseHeaders,responseBody);
+ if (scode == 0) {
+ printf("Error connecting to the ZeroTier service: %s\n\nPlease check that the service is running and that TCP port 9993 can be contacted via 127.0.0.1." ZT_EOL_S, responseBody.c_str());
+ return 1;
+ }
+
nlohmann::json j;
try {
j = OSUtils::jsonParse(responseBody);