diff --git a/src/models/TailDeviceInfo.h b/src/models/TailDeviceInfo.h index 827b77c..0243878 100644 --- a/src/models/TailDeviceInfo.h +++ b/src/models/TailDeviceInfo.h @@ -61,6 +61,8 @@ class TailDeviceInfo final : public QObject QString os{}; QString curAddr{}; QString relay{}; + QDateTime created {}; + QDateTime lastSeen {}; QList tailscaleIPs{}; QList allowedIPs{}; QList tags{}; @@ -93,6 +95,8 @@ class TailDeviceInfo final : public QObject , addrs(other.addrs) , curAddr(other.curAddr) , relay(other.relay) + , created(other.created) + , lastSeen(other.lastSeen) , online(other.online) , exitNode(other.exitNode) , exitNodeOption(other.exitNodeOption) @@ -120,6 +124,8 @@ class TailDeviceInfo final : public QObject addrs = other.addrs; curAddr = other.curAddr; relay = other.relay; + created = other.created; + lastSeen = other.lastSeen; online = other.online; exitNode = other.exitNode; exitNodeOption = other.exitNodeOption; @@ -173,6 +179,15 @@ class TailDeviceInfo final : public QObject self.exitNodeOption = jsonReadBool(obj, "ExitNodeOption"); self.online = jsonReadBool(obj, "Online"); self.active = jsonReadBool(obj, "Active"); + self.relay = jsonReadString(obj, "Relay"); + + // Try to parse created + auto createdStr = jsonReadString(obj, "Created"); + self.created = QDateTime::fromString(createdStr, Qt::DateFormat::ISODateWithMs); + + // And try to parse last seen + auto lastSeenStr = jsonReadString(obj, "LastSeen"); + self.lastSeen = QDateTime::fromString(lastSeenStr, Qt::DateFormat::ISODateWithMs); if (obj.contains("KeyExpiry") && !obj["KeyExpiry"].isNull()) { self.keyExpiry = QDateTime::fromString(obj["KeyExpiry"].toString(), Qt::DateFormat::ISODate); diff --git a/src/models/TailStatus.h b/src/models/TailStatus.h index 1e30e00..526b823 100644 --- a/src/models/TailStatus.h +++ b/src/models/TailStatus.h @@ -145,7 +145,24 @@ class TailStatus final : public QObject if (child.isNull()) { continue; } - newStatus.peers.push_back(TailDeviceInfo::parse(child.toObject())); + auto dev = TailDeviceInfo::parse(child.toObject()); + + // NOTE: If the created date is way back in time something is off, this has been reported + // by users. For more info: + // See issue https://github.com/SneWs/tail-tray/issues/106 + if (dev.dnsName.isEmpty() || dev.dnsName.length() < 2) { + // If no valid dns name, we ignore it... + continue; + } + + if (dev.created.date().year() < 2020) { + // Don't track expired or invalid devices that should be of no interest to the user + // From the issue above we can see some odd dates like 1973-01 so it's not unix epoc either... + // So I just picked a year before Tailscale was funded/started for now... please + // correct this if you can figure out why this happens on some users tailnets. + continue; + } + newStatus.peers.push_back(dev); } }