From 04de2302a7987d6046abed7b8c970488ed314e58 Mon Sep 17 00:00:00 2001 From: Joseph Henry Date: Wed, 3 Oct 2018 14:24:21 -0700 Subject: [PATCH 1/3] More insightful errors for get command --- one.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/one.cpp b/one.cpp index b770451c0..0b18ed911 100644 --- a/one.cpp +++ b/one.cpp @@ -630,7 +630,7 @@ 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]; @@ -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()); return 1; } + bool bNetworkFound = false; if (j.is_array()) { for(unsigned long i=0;i Date: Tue, 23 Oct 2018 10:58:25 -0700 Subject: [PATCH 2/3] Removed unnecessary block before get request. Possible bug fix for Synology NAS ticket #27 --- one.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/one.cpp b/one.cpp index 0b18ed911..abe8bb375 100644 --- a/one.cpp +++ b/one.cpp @@ -633,10 +633,6 @@ static int cli(int argc,char **argv) 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) { From 7c726533850eb0a6f3a40d72f42bd50a8e93e621 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Tue, 23 Oct 2018 13:21:25 -0700 Subject: [PATCH 3/3] because Windows.... --- node/InetAddress.cpp | 8 ++++++++ service/OneService.cpp | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/node/InetAddress.cpp b/node/InetAddress.cpp index 3eb5579f8..54daa668e 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(this)->sin_addr.s_addr, buf, INET_ADDRSTRLEN); +#else inet_ntop(AF_INET, &reinterpret_cast(this)->sin_addr.s_addr, buf, INET_ADDRSTRLEN); +#endif } break; case AF_INET6: { +#ifdef _WIN32 + inet_ntop(AF_INET6, (void*)reinterpret_cast(this)->sin6_addr.s6_addr, buf, INET6_ADDRSTRLEN); +#else inet_ntop(AF_INET6, reinterpret_cast(this)->sin6_addr.s6_addr, buf, INET6_ADDRSTRLEN); +#endif } break; } return buf; diff --git a/service/OneService.cpp b/service/OneService.cpp index 91d10d226..9d3a95993 100644 --- a/service/OneService.cpp +++ b/service/OneService.cpp @@ -67,7 +67,7 @@ #include #include #include -#include +//#include #define stat _stat #else #include