summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--node/InetAddress.cpp8
-rw-r--r--one.cpp11
-rw-r--r--service/OneService.cpp2
3 files changed, 15 insertions, 6 deletions
diff --git a/node/InetAddress.cpp b/node/InetAddress.cpp
index 3eb5579f..54daa668 100644
--- a/node/InetAddress.cpp
+++ b/node/InetAddress.cpp
@@ -142,11 +142,19 @@ char *InetAddress::toIpString(char buf[64]) const
buf[0] = (char)0;
switch(ss_family) {
case AF_INET: {
+#ifdef _WIN32
+ inet_ntop(AF_INET, (void*)&reinterpret_cast<const struct sockaddr_in *>(this)->sin_addr.s_addr, buf, INET_ADDRSTRLEN);
+#else
inet_ntop(AF_INET, &reinterpret_cast<const struct sockaddr_in *>(this)->sin_addr.s_addr, buf, INET_ADDRSTRLEN);
+#endif
} break;
case AF_INET6: {
+#ifdef _WIN32
+ inet_ntop(AF_INET6, (void*)reinterpret_cast<const struct sockaddr_in6 *>(this)->sin6_addr.s6_addr, buf, INET6_ADDRSTRLEN);
+#else
inet_ntop(AF_INET6, reinterpret_cast<const struct sockaddr_in6 *>(this)->sin6_addr.s6_addr, buf, INET6_ADDRSTRLEN);
+#endif
} break;
}
return buf;
diff --git a/one.cpp b/one.cpp
index b770451c..abe8bb37 100644
--- a/one.cpp
+++ b/one.cpp
@@ -630,13 +630,9 @@ static int cli(int argc,char **argv)
}
} else if (command == "get") {
if (arg1.length() != 16) {
- cliPrintHelp(argv[0],stderr);
+ fprintf(stderr,"invalid network ID format, must be a 16-digit hexidecimal number\n");
return 2;
}
- char jsons[1024], cl[128];
- OSUtils::ztsnprintf(cl,sizeof(cl),"%u",(unsigned int)strlen(jsons));
- requestHeaders["Content-Type"] = "application/json";
- 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) {
@@ -654,16 +650,21 @@ static int cli(int argc,char **argv)
printf("%u %s invalid JSON response (unknown exception)" ZT_EOL_S,scode,command.c_str());
return 1;
}
+ bool bNetworkFound = false;
if (j.is_array()) {
for(unsigned long i=0;i<j.size();++i) {
nlohmann::json &n = j[i];
if (n.is_object()) {
if (n["id"] == arg1) {
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) {
return 0;
} else {
diff --git a/service/OneService.cpp b/service/OneService.cpp
index 91d10d22..9d3a9599 100644
--- a/service/OneService.cpp
+++ b/service/OneService.cpp
@@ -67,7 +67,7 @@
#include <ShlObj.h>
#include <netioapi.h>
#include <iphlpapi.h>
-#include <unistd.h>
+//#include <unistd.h>
#define stat _stat
#else
#include <sys/types.h>