summaryrefslogtreecommitdiff
path: root/node
diff options
context:
space:
mode:
authorJoseph Henry <[email protected]>2022-02-25 11:39:21 -0800
committerJoseph Henry <[email protected]>2022-02-25 11:39:21 -0800
commitbc2c4cf80aceeb4bc86d570de1fe17f93f678ca4 (patch)
tree1ab91eb946ec532fadf137cd76f1ea718d526bd5 /node
parent1918c29fd7ee8f82e8f0428747b8f3ee4d913704 (diff)
parent9933d83cf89c9115dc2542ea5592817bdc03ff6f (diff)
Merge branch 'dev' of https://github.com/zerotier/zerotierone into dev
Diffstat (limited to 'node')
-rw-r--r--node/Peer.cpp4
-rw-r--r--node/SelfAwareness.cpp15
-rw-r--r--node/SelfAwareness.hpp7
3 files changed, 25 insertions, 1 deletions
diff --git a/node/Peer.cpp b/node/Peer.cpp
index 76f83940..5a76eda3 100644
--- a/node/Peer.cpp
+++ b/node/Peer.cpp
@@ -223,6 +223,8 @@ void Peer::received(
if (sinceLastPush >= ((hops == 0) ? ZT_DIRECT_PATH_PUSH_INTERVAL_HAVEPATH : ZT_DIRECT_PATH_PUSH_INTERVAL)) {
_lastDirectPathPushSent = now;
std::vector<InetAddress> pathsToPush(RR->node->directPaths());
+ std::vector<InetAddress> ma = RR->sa->whoami();
+ pathsToPush.insert(pathsToPush.end(), ma.begin(), ma.end());
if (!pathsToPush.empty()) {
std::vector<InetAddress>::const_iterator p(pathsToPush.begin());
while (p != pathsToPush.end()) {
@@ -452,7 +454,7 @@ void Peer::sendHELLO(void *tPtr,const int64_t localSocket,const InetAddress &atA
if (atAddress) {
outp.armor(_key,false,nullptr); // false == don't encrypt full payload, but add MAC
RR->node->expectReplyTo(outp.packetId());
- RR->node->putPacket(tPtr,localSocket,atAddress,outp.data(),outp.size());
+ RR->node->putPacket(tPtr,-1,atAddress,outp.data(),outp.size());
} else {
RR->node->expectReplyTo(outp.packetId());
RR->sw->send(tPtr,outp,false); // false == don't encrypt full payload, but add MAC
diff --git a/node/SelfAwareness.cpp b/node/SelfAwareness.cpp
index 57b409c1..45bc2541 100644
--- a/node/SelfAwareness.cpp
+++ b/node/SelfAwareness.cpp
@@ -99,6 +99,21 @@ void SelfAwareness::iam(void *tPtr,const Address &reporter,const int64_t receive
}
}
+std::vector<InetAddress> SelfAwareness::whoami()
+{
+ std::vector<InetAddress> surfaceAddresses;
+ Mutex::Lock _l(_phy_m);
+ Hashtable< PhySurfaceKey,PhySurfaceEntry >::Iterator i(_phy);
+ PhySurfaceKey *k = (PhySurfaceKey *)0;
+ PhySurfaceEntry *e = (PhySurfaceEntry *)0;
+ while (i.next(k,e)) {
+ if (std::find(surfaceAddresses.begin(), surfaceAddresses.end(), e->mySurface) == surfaceAddresses.end()) {
+ surfaceAddresses.push_back(e->mySurface);
+ }
+ }
+ return surfaceAddresses;
+}
+
void SelfAwareness::clean(int64_t now)
{
Mutex::Lock _l(_phy_m);
diff --git a/node/SelfAwareness.hpp b/node/SelfAwareness.hpp
index f34d5778..e0fbf91d 100644
--- a/node/SelfAwareness.hpp
+++ b/node/SelfAwareness.hpp
@@ -45,6 +45,13 @@ public:
void iam(void *tPtr,const Address &reporter,const int64_t receivedOnLocalSocket,const InetAddress &reporterPhysicalAddress,const InetAddress &myPhysicalAddress,bool trusted,int64_t now);
/**
+ * Return all known external surface addresses reported by peers
+ *
+ * @return A vector of InetAddress(es)
+ */
+ std::vector<InetAddress> whoami();
+
+ /**
* Clean up database periodically
*
* @param now Current time