summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/ZeroTierOne.h10
-rw-r--r--node/Node.cpp2
-rw-r--r--one.cpp26
-rw-r--r--service/ControlPlane.cpp4
4 files changed, 32 insertions, 10 deletions
diff --git a/include/ZeroTierOne.h b/include/ZeroTierOne.h
index 45ed626a..e60d4a74 100644
--- a/include/ZeroTierOne.h
+++ b/include/ZeroTierOne.h
@@ -561,6 +561,16 @@ typedef struct
uint64_t address;
/**
+ * Time we last received a unicast frame from this peer
+ */
+ uint64_t lastUnicastFrame;
+
+ /**
+ * Time we last received a multicast rame from this peer
+ */
+ uint64_t lastMulticastFrame;
+
+ /**
* Remote major version or -1 if not known
*/
int versionMajor;
diff --git a/node/Node.cpp b/node/Node.cpp
index 801d4078..09ad729e 100644
--- a/node/Node.cpp
+++ b/node/Node.cpp
@@ -343,6 +343,8 @@ ZT1_PeerList *Node::peers() const
for(std::map< Address,SharedPtr<Peer> >::iterator pi(peers.begin());pi!=peers.end();++pi) {
ZT1_Peer *p = &(pl->peers[pl->peerCount++]);
p->address = pi->second->address().toInt();
+ p->lastUnicastFrame = pi->second->lastUnicastFrame();
+ p->lastMulticastFrame = pi->second->lastMulticastFrame();
if (pi->second->remoteVersionKnown()) {
p->versionMajor = pi->second->remoteVersionMajor();
p->versionMinor = pi->second->remoteVersionMinor();
diff --git a/one.cpp b/one.cpp
index cc33a0f1..68e1fb93 100644
--- a/one.cpp
+++ b/one.cpp
@@ -675,16 +675,6 @@ int main(int argc,char **argv)
return 0; // forked
// else p == 0, so we are daemonized
}
-
- {
- // Write .pid file to home folder
- std::string pidPath(homeDir + ZT_PATH_SEPARATOR_S + ZT1_PID_PATH);
- FILE *pf = fopen(pidPath.c_str(),"w");
- if (pf) {
- fprintf(pf,"%ld",(long)getpid());
- fclose(pf);
- }
- }
#endif // __UNIX_LIKE__
#ifdef __WINDOWS__
@@ -723,6 +713,18 @@ int main(int argc,char **argv)
}
#endif // ZT_ENABLE_NETWORK_CONTROLLER
+#ifdef __UNIX_LIKE__
+ std::string pidPath(homeDir + ZT_PATH_SEPARATOR_S + ZT1_PID_PATH);
+ {
+ // Write .pid file to home folder
+ FILE *pf = fopen(pidPath.c_str(),"w");
+ if (pf) {
+ fprintf(pf,"%ld",(long)getpid());
+ fclose(pf);
+ }
+ }
+#endif // __UNIX_LIKE__
+
unsigned int returnValue = 0;
try {
@@ -762,5 +764,9 @@ int main(int argc,char **argv)
zt1Service = (OneService *)0;
delete controller;
+#ifdef __UNIX_LIKE__
+ OSUtils::rm(pidPath.c_str());
+#endif
+
return returnValue;
}
diff --git a/service/ControlPlane.cpp b/service/ControlPlane.cpp
index f65a9ee5..25f893a5 100644
--- a/service/ControlPlane.cpp
+++ b/service/ControlPlane.cpp
@@ -177,6 +177,8 @@ static void _jsonAppend(std::string &buf,const ZT1_Peer *peer)
Utils::snprintf(json,sizeof(json),
"{"
"\"address\": \"%.10llx\","
+ "\"lastUnicastFrame\": %llu,"
+ "\"lastMulticastFrame\": %llu,"
"\"versionMajor\": %d,"
"\"versionMinor\": %d,"
"\"versionRev\": %d,"
@@ -186,6 +188,8 @@ static void _jsonAppend(std::string &buf,const ZT1_Peer *peer)
"\"paths\": %s"
"}",
peer->address,
+ peer->lastUnicastFrame,
+ peer->lastMulticastFrame,
peer->versionMajor,
peer->versionMinor,
peer->versionRev,