Merge pull request #15828 from roxanneskelly/bugz812

BUGZ-812 - Log system info on domain connect or connect refusal
This commit is contained in:
Shannon Romano 2019-06-24 16:05:55 -07:00 committed by GitHub
commit f5169093e0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 48 additions and 19 deletions

View file

@ -136,7 +136,8 @@ void DomainGatekeeper::processConnectRequestPacket(QSharedPointer<ReceivedMessag
} else { } else {
qDebug() << "Refusing connection from node at" << message->getSenderSockAddr() qDebug() << "Refusing connection from node at" << message->getSenderSockAddr()
<< "with hardware address" << nodeConnection.hardwareAddress << "with hardware address" << nodeConnection.hardwareAddress
<< "and machine fingerprint" << nodeConnection.machineFingerprint; << "and machine fingerprint" << nodeConnection.machineFingerprint
<< "sysinfo" << nodeConnection.SystemInfo;
} }
} }

View file

@ -37,7 +37,11 @@ NodeConnectionData NodeConnectionData::fromDataStream(QDataStream& dataStream, c
dataStream >> newHeader.machineFingerprint; dataStream >> newHeader.machineFingerprint;
// and the operating system type // and the operating system type
dataStream >> newHeader.SystemInfo; QByteArray compressedSystemInfo;
dataStream >> compressedSystemInfo;
if (!compressedSystemInfo.isEmpty()) {
newHeader.SystemInfo = qUncompress(compressedSystemInfo);
}
dataStream >> newHeader.connectReason; dataStream >> newHeader.connectReason;

View file

@ -1,6 +1,6 @@
set(TARGET_NAME networking) set(TARGET_NAME networking)
setup_hifi_library(Network) setup_hifi_library(Network)
link_hifi_libraries(shared) link_hifi_libraries(shared platform)
target_openssl() target_openssl()
target_tbb() target_tbb()

View file

@ -26,6 +26,8 @@
#include <ThreadHelpers.h> #include <ThreadHelpers.h>
#include <LogHandler.h> #include <LogHandler.h>
#include <UUID.h> #include <UUID.h>
#include <platform/Platform.h>
#include <platform/PlatformKeys.h>
#include "AccountManager.h" #include "AccountManager.h"
#include "AddressManager.h" #include "AddressManager.h"
@ -42,6 +44,7 @@
using namespace std::chrono; using namespace std::chrono;
const int KEEPALIVE_PING_INTERVAL_MS = 1000; const int KEEPALIVE_PING_INTERVAL_MS = 1000;
const int MAX_SYSTEM_INFO_SIZE = 1000;
NodeList::NodeList(char newOwnerType, int socketListenPort, int dtlsListenPort) : NodeList::NodeList(char newOwnerType, int socketListenPort, int dtlsListenPort) :
LimitedNodeList(socketListenPort, dtlsListenPort), LimitedNodeList(socketListenPort, dtlsListenPort),
@ -418,19 +421,20 @@ void NodeList::sendDomainServerCheckIn() {
auto accountManager = DependencyManager::get<AccountManager>(); auto accountManager = DependencyManager::get<AccountManager>();
packetStream << FingerprintUtils::getMachineFingerprint(); packetStream << FingerprintUtils::getMachineFingerprint();
QString systemInfo; auto desc = platform::getAll();
#if defined Q_OS_WIN
systemInfo = "OS:Windows"; QByteArray systemInfo(desc.dump().c_str());
#elif defined Q_OS_OSX QByteArray compressedSystemInfo = qCompress(systemInfo);
systemInfo = "OS:OSX";
#elif defined Q_OS_LINUX if (compressedSystemInfo.size() > MAX_SYSTEM_INFO_SIZE) {
systemInfo = "OS:Linux"; // Highly unlikely, as not even unreasonable machines will
#elif defined Q_OS_ANDROID // overflow the max size, but prevent MTU overflow anyway.
systemInfo = "OS:Android"; // We could do something sophisticated like clearing specific
#else // values if they're too big, but we'll save that for later.
systemInfo = "OS:Unknown"; compressedSystemInfo.clear();
#endif }
packetStream << systemInfo;
packetStream << compressedSystemInfo;
packetStream << _connectReason; packetStream << _connectReason;

View file

@ -20,6 +20,7 @@
#include <LogHandler.h> #include <LogHandler.h>
#include <shared/QtHelpers.h> #include <shared/QtHelpers.h>
#include <platform/Platform.h>
#include "NetworkLogging.h" #include "NetworkLogging.h"
ThreadedAssignment::ThreadedAssignment(ReceivedMessage& message) : ThreadedAssignment::ThreadedAssignment(ReceivedMessage& message) :
@ -38,6 +39,16 @@ ThreadedAssignment::ThreadedAssignment(ReceivedMessage& message) :
// if the NL tells us we got a DS response, clear our member variable of queued check-ins // if the NL tells us we got a DS response, clear our member variable of queued check-ins
auto nodeList = DependencyManager::get<NodeList>(); auto nodeList = DependencyManager::get<NodeList>();
connect(nodeList.data(), &NodeList::receivedDomainServerList, this, &ThreadedAssignment::clearQueuedCheckIns); connect(nodeList.data(), &NodeList::receivedDomainServerList, this, &ThreadedAssignment::clearQueuedCheckIns);
platform::create();
if (!platform::enumeratePlatform()) {
qCDebug(networking) << "Failed to enumerate platform.";
}
}
ThreadedAssignment::~ThreadedAssignment() {
stop();
platform::destroy();
} }
void ThreadedAssignment::setFinished(bool isFinished) { void ThreadedAssignment::setFinished(bool isFinished) {

View file

@ -22,7 +22,7 @@ class ThreadedAssignment : public Assignment {
Q_OBJECT Q_OBJECT
public: public:
ThreadedAssignment(ReceivedMessage& message); ThreadedAssignment(ReceivedMessage& message);
~ThreadedAssignment() { stop(); } ~ThreadedAssignment();
virtual void aboutToFinish() { }; virtual void aboutToFinish() { };
void addPacketStatsAndSendStatsPacket(QJsonObject statsObject); void addPacketStatsAndSendStatsPacket(QJsonObject statsObject);

View file

@ -72,7 +72,7 @@ PacketVersion versionForPacketType(PacketType packetType) {
return static_cast<PacketVersion>(DomainConnectionDeniedVersion::IncludesExtraInfo); return static_cast<PacketVersion>(DomainConnectionDeniedVersion::IncludesExtraInfo);
case PacketType::DomainConnectRequest: case PacketType::DomainConnectRequest:
return static_cast<PacketVersion>(DomainConnectRequestVersion::HasSystemInfo); return static_cast<PacketVersion>(DomainConnectRequestVersion::HasCompressedSystemInfo);
case PacketType::DomainServerAddedNode: case PacketType::DomainServerAddedNode:
return static_cast<PacketVersion>(DomainServerAddedNodeVersion::PermissionsGrid); return static_cast<PacketVersion>(DomainServerAddedNodeVersion::PermissionsGrid);

View file

@ -347,7 +347,8 @@ enum class DomainConnectRequestVersion : PacketVersion {
AlwaysHasMachineFingerprint, AlwaysHasMachineFingerprint,
HasTimestamp, HasTimestamp,
HasReason, HasReason,
HasSystemInfo HasSystemInfo,
HasCompressedSystemInfo
}; };
enum class DomainConnectionDeniedVersion : PacketVersion { enum class DomainConnectionDeniedVersion : PacketVersion {

View file

@ -5,3 +5,11 @@ link_hifi_libraries(shared)
GroupSources("src") GroupSources("src")
target_json() target_json()
if (APPLE)
# link in required OS X frameworks and include the right GL headers
find_library(OpenGL OpenGL)
find_library(AppKit AppKit)
target_link_libraries(${TARGET_NAME} ${OpenGL} ${AppKit})
endif ()