diff --git a/one.cpp b/one.cpp index 3b158cc14..46a23b1ee 100644 --- a/one.cpp +++ b/one.cpp @@ -517,7 +517,7 @@ static int cli(int argc,char **argv) } /* zerotier-cli bond list */ if (arg1 == "list") { - const unsigned int scode = Http::GET(1024 * 1024 * 16,60000,(const struct sockaddr *)&addr,"/bonds",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; @@ -543,13 +543,13 @@ static int cli(int argc,char **argv) nlohmann::json &p = j[k]; bool isBonded = p["isBonded"]; if (isBonded) { - int8_t bondingPolicy = p["bondingPolicy"]; + int8_t bondingPolicyCode = p["bondingPolicyCode"]; int8_t numAliveLinks = p["numAliveLinks"]; int8_t numTotalLinks = p["numTotalLinks"]; bFoundBond = true; std::string policyStr = "none"; - if (bondingPolicy >= ZT_BOND_POLICY_NONE && bondingPolicy <= ZT_BOND_POLICY_BALANCE_AWARE) { - policyStr = Bond::getPolicyStrByCode(bondingPolicy); + if (bondingPolicyCode >= ZT_BOND_POLICY_NONE && bondingPolicyCode <= ZT_BOND_POLICY_BALANCE_AWARE) { + policyStr = Bond::getPolicyStrByCode(bondingPolicyCode); } printf("%10s %32s %d/%d" ZT_EOL_S, OSUtils::jsonString(p ["address"],"-").c_str(), @@ -683,13 +683,8 @@ static int cli(int argc,char **argv) /* zerotier-cli bond command was malformed in some way */ printf("(bond) command is missing required arguments" ZT_EOL_S); return 2; - const unsigned int scode = Http::GET(1024 * 1024 * 16,60000,(const struct sockaddr *)&addr,"/bonds",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; - } } else if (command == "listbonds") { - const unsigned int scode = Http::GET(1024 * 1024 * 16,60000,(const struct sockaddr *)&addr,"/bonds",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()); @@ -718,13 +713,13 @@ static int cli(int argc,char **argv) nlohmann::json &p = j[k]; bool isBonded = p["isBonded"]; if (isBonded) { - int8_t bondingPolicy = p["bondingPolicy"]; + int8_t bondingPolicyCode = p["bondingPolicyCode"]; int8_t numAliveLinks = p["numAliveLinks"]; int8_t numTotalLinks = p["numTotalLinks"]; bFoundBond = true; std::string policyStr = "none"; - if (bondingPolicy >= ZT_BOND_POLICY_NONE && bondingPolicy <= ZT_BOND_POLICY_BALANCE_AWARE) { - policyStr = Bond::getPolicyStrByCode(bondingPolicy); + if (bondingPolicyCode >= ZT_BOND_POLICY_NONE && bondingPolicyCode <= ZT_BOND_POLICY_BALANCE_AWARE) { + policyStr = Bond::getPolicyStrByCode(bondingPolicyCode); } printf("%10s %32s %d/%d" ZT_EOL_S, OSUtils::jsonString(p["address"],"-").c_str(), @@ -1121,17 +1116,7 @@ static int cli(int argc,char **argv) } dump << responseBody << ZT_EOL_S; - responseHeaders.clear(); - responseBody = ""; - - // get bonds - dump << ZT_EOL_S << "bonds" << ZT_EOL_S << "-----" << ZT_EOL_S; - scode = Http::GET(1024 * 1024 * 16,60000,(const struct sockaddr *)&addr,"/bonds",requestHeaders,responseHeaders,responseBody); - if (scode != 200) { - 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; - } - dump << responseBody << ZT_EOL_S; + // Bonds don't need to be queried separately since their data originates from "/peer" responses anyway responseHeaders.clear(); responseBody = "";