mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-06-05 03:53:44 +02:00
Better error messages when the ZeroTier service can't be contacted
Fixes #681
This commit is contained in:
parent
f9b07c63db
commit
1bec8ddce4
1 changed files with 26 additions and 1 deletions
27
one.cpp
27
one.cpp
|
@ -299,7 +299,7 @@ static int cli(int argc,char **argv)
|
||||||
responseHeaders,
|
responseHeaders,
|
||||||
responseBody);
|
responseBody);
|
||||||
if (scode == 200) {
|
if (scode == 200) {
|
||||||
printf("%s",cliFixJsonCRs(responseBody).c_str());
|
printf("%s", cliFixJsonCRs(responseBody).c_str());
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
printf("%u %s %s" ZT_EOL_S,scode,command.c_str(),responseBody.c_str());
|
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")) {
|
} else if ((command == "info")||(command == "status")) {
|
||||||
const unsigned int scode = Http::GET(1024 * 1024 * 16,60000,(const struct sockaddr *)&addr,"/status",requestHeaders,responseHeaders,responseBody);
|
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;
|
nlohmann::json j;
|
||||||
try {
|
try {
|
||||||
j = OSUtils::jsonParse(responseBody);
|
j = OSUtils::jsonParse(responseBody);
|
||||||
|
@ -338,6 +343,11 @@ static int cli(int argc,char **argv)
|
||||||
} else if (command == "listpeers") {
|
} else if (command == "listpeers") {
|
||||||
const unsigned int scode = Http::GET(1024 * 1024 * 16,60000,(const struct sockaddr *)&addr,"/peer",requestHeaders,responseHeaders,responseBody);
|
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;
|
nlohmann::json j;
|
||||||
try {
|
try {
|
||||||
j = OSUtils::jsonParse(responseBody);
|
j = OSUtils::jsonParse(responseBody);
|
||||||
|
@ -400,6 +410,11 @@ static int cli(int argc,char **argv)
|
||||||
} else if (command == "listnetworks") {
|
} else if (command == "listnetworks") {
|
||||||
const unsigned int scode = Http::GET(1024 * 1024 * 16,60000,(const struct sockaddr *)&addr,"/network",requestHeaders,responseHeaders,responseBody);
|
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;
|
nlohmann::json j;
|
||||||
try {
|
try {
|
||||||
j = OSUtils::jsonParse(responseBody);
|
j = OSUtils::jsonParse(responseBody);
|
||||||
|
@ -504,6 +519,11 @@ static int cli(int argc,char **argv)
|
||||||
} else if (command == "listmoons") {
|
} else if (command == "listmoons") {
|
||||||
const unsigned int scode = Http::GET(1024 * 1024 * 16,60000,(const struct sockaddr *)&addr,"/moon",requestHeaders,responseHeaders,responseBody);
|
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;
|
nlohmann::json j;
|
||||||
try {
|
try {
|
||||||
j = OSUtils::jsonParse(responseBody);
|
j = OSUtils::jsonParse(responseBody);
|
||||||
|
@ -619,6 +639,11 @@ static int cli(int argc,char **argv)
|
||||||
requestHeaders["Content-Length"] = cl;
|
requestHeaders["Content-Length"] = cl;
|
||||||
const unsigned int scode = Http::GET(1024 * 1024 * 16,60000,(const struct sockaddr *)&addr,"/network",requestHeaders,responseHeaders,responseBody);
|
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;
|
nlohmann::json j;
|
||||||
try {
|
try {
|
||||||
j = OSUtils::jsonParse(responseBody);
|
j = OSUtils::jsonParse(responseBody);
|
||||||
|
|
Loading…
Add table
Reference in a new issue