mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2024-12-19 04:57:53 +00:00
More insightful errors for get command
This commit is contained in:
parent
ceff48b07c
commit
04de2302a7
7
one.cpp
7
one.cpp
@ -630,7 +630,7 @@ static int cli(int argc,char **argv)
|
|||||||
}
|
}
|
||||||
} else if (command == "get") {
|
} else if (command == "get") {
|
||||||
if (arg1.length() != 16) {
|
if (arg1.length() != 16) {
|
||||||
cliPrintHelp(argv[0],stderr);
|
fprintf(stderr,"invalid network ID format, must be a 16-digit hexidecimal number\n");
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
char jsons[1024], cl[128];
|
char jsons[1024], cl[128];
|
||||||
@ -654,16 +654,21 @@ static int cli(int argc,char **argv)
|
|||||||
printf("%u %s invalid JSON response (unknown exception)" ZT_EOL_S,scode,command.c_str());
|
printf("%u %s invalid JSON response (unknown exception)" ZT_EOL_S,scode,command.c_str());
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
bool bNetworkFound = false;
|
||||||
if (j.is_array()) {
|
if (j.is_array()) {
|
||||||
for(unsigned long i=0;i<j.size();++i) {
|
for(unsigned long i=0;i<j.size();++i) {
|
||||||
nlohmann::json &n = j[i];
|
nlohmann::json &n = j[i];
|
||||||
if (n.is_object()) {
|
if (n.is_object()) {
|
||||||
if (n["id"] == arg1) {
|
if (n["id"] == arg1) {
|
||||||
printf("%s\n", OSUtils::jsonString(n[arg2],"-").c_str());
|
printf("%s\n", OSUtils::jsonString(n[arg2],"-").c_str());
|
||||||
|
bNetworkFound = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!bNetworkFound) {
|
||||||
|
fprintf(stderr,"unknown network ID, check that you are a member of the network\n");
|
||||||
|
}
|
||||||
if (scode == 200) {
|
if (scode == 200) {
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user