Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/models/TailDeviceInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ class TailDeviceInfo final : public QObject
QString os{};
QString curAddr{};
QString relay{};
QDateTime created {};
QDateTime lastSeen {};
QList<QString> tailscaleIPs{};
QList<QString> allowedIPs{};
QList<QString> tags{};
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
19 changes: 18 additions & 1 deletion src/models/TailStatus.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
Loading