From 82c799b9d16861dd2627b58d38402804835588f3 Mon Sep 17 00:00:00 2001 From: travis laduke Date: Tue, 25 Oct 2022 11:25:21 -0700 Subject: [PATCH] Expose surface addresses in info json Surface Addresses are the addresses that the roots report back to you. This is helpful for trouble shooting. If you're behind NAT, the source port is different than what zerotier is bound to. If the list of surface address ports is larger than the list of bound addresses, you are probably behind symmetric NAT. Anways this can be added to later with a more simple "easy" or "hard" nat computed message somewhere. --- node/Node.hpp | 3 +++ service/OneService.cpp | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/node/Node.hpp b/node/Node.hpp index 52506ed9e..834f50cc9 100644 --- a/node/Node.hpp +++ b/node/Node.hpp @@ -35,6 +35,7 @@ #include "NetworkController.hpp" #include "Hashtable.hpp" #include "Bond.hpp" +#include "SelfAwareness.hpp" // Bit mask for "expecting reply" hash #define ZT_EXPECTING_REPLIES_BUCKET_MASK1 255 @@ -187,6 +188,8 @@ public: inline const Identity &identity() const { return _RR.identity; } + inline const std::vector SurfaceAddresses() const { return _RR.sa->whoami(); } + inline Bond *bondController() const { return _RR.bc; } /** diff --git a/service/OneService.cpp b/service/OneService.cpp index a9cb229ec..d17b539f2 100644 --- a/service/OneService.cpp +++ b/service/OneService.cpp @@ -1560,6 +1560,15 @@ public: } settings["listeningOn"] = boundAddrArray; + std::vector surfaceAddrs = _node-> SurfaceAddresses(); + auto surfaceAddrArray = json::array(); + for (int i = 0; i < surfaceAddrs.size(); i++) { + char ipBuf[64] = { 0 }; + surfaceAddrs[i].toString(ipBuf); + surfaceAddrArray.push_back(ipBuf); + } + settings["surfaceAddresses"] = surfaceAddrArray; + #ifdef ZT_USE_MINIUPNPC settings["portMappingEnabled"] = OSUtils::jsonBool(settings["portMappingEnabled"],true); #else