瀏覽代碼

Merge branch 'dev' of http://10.95.0.64/zerotier/ZeroTierOne into dev

Adam Ierymenko 2 年之前
父節點
當前提交
bcf27d78e5
共有 2 個文件被更改,包括 13 次插入1 次删除
  1. 3 0
      node/Node.hpp
  2. 10 1
      service/OneService.cpp

+ 3 - 0
node/Node.hpp

@@ -35,6 +35,7 @@
 #include "NetworkController.hpp"
 #include "NetworkController.hpp"
 #include "Hashtable.hpp"
 #include "Hashtable.hpp"
 #include "Bond.hpp"
 #include "Bond.hpp"
+#include "SelfAwareness.hpp"
 
 
 // Bit mask for "expecting reply" hash
 // Bit mask for "expecting reply" hash
 #define ZT_EXPECTING_REPLIES_BUCKET_MASK1 255
 #define ZT_EXPECTING_REPLIES_BUCKET_MASK1 255
@@ -187,6 +188,8 @@ public:
 
 
 	inline const Identity &identity() const { return _RR.identity; }
 	inline const Identity &identity() const { return _RR.identity; }
 
 
+	inline const std::vector<InetAddress> SurfaceAddresses() const { return _RR.sa->whoami(); }
+
 	inline Bond *bondController() const { return _RR.bc; }
 	inline Bond *bondController() const { return _RR.bc; }
 
 
 	/**
 	/**

+ 10 - 1
service/OneService.cpp

@@ -1526,7 +1526,7 @@ public:
 					settings["primaryPort"] = OSUtils::jsonInt(settings["primaryPort"],(uint64_t)_primaryPort) & 0xffff;
 					settings["primaryPort"] = OSUtils::jsonInt(settings["primaryPort"],(uint64_t)_primaryPort) & 0xffff;
 					settings["secondaryPort"] = OSUtils::jsonInt(settings["secondaryPort"],(uint64_t)_secondaryPort) & 0xffff;
 					settings["secondaryPort"] = OSUtils::jsonInt(settings["secondaryPort"],(uint64_t)_secondaryPort) & 0xffff;
 					settings["tertiaryPort"] = OSUtils::jsonInt(settings["tertiaryPort"],(uint64_t)_tertiaryPort) & 0xffff;
 					settings["tertiaryPort"] = OSUtils::jsonInt(settings["tertiaryPort"],(uint64_t)_tertiaryPort) & 0xffff;
-					// Enumerate all external listening address/port pairs
+					// Enumerate all local address/port pairs that this node is listening on
 					std::vector<InetAddress> boundAddrs(_binder.allBoundLocalInterfaceAddresses());
 					std::vector<InetAddress> boundAddrs(_binder.allBoundLocalInterfaceAddresses());
 					auto boundAddrArray = json::array();
 					auto boundAddrArray = json::array();
 					for (int i = 0; i < boundAddrs.size(); i++) {
 					for (int i = 0; i < boundAddrs.size(); i++) {
@@ -1535,6 +1535,15 @@ public:
 						boundAddrArray.push_back(ipBuf);
 						boundAddrArray.push_back(ipBuf);
 					}
 					}
 					settings["listeningOn"] = boundAddrArray;
 					settings["listeningOn"] = boundAddrArray;
+					// Enumerate all external address/port pairs that are reported for this node
+					std::vector<InetAddress> 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
 #ifdef ZT_USE_MINIUPNPC
 					settings["portMappingEnabled"] = OSUtils::jsonBool(settings["portMappingEnabled"],true);
 					settings["portMappingEnabled"] = OSUtils::jsonBool(settings["portMappingEnabled"],true);