diff --git a/domain-server/src/NodeConnectionData.cpp b/domain-server/src/NodeConnectionData.cpp index 13bb9123d8..93d6802d84 100644 --- a/domain-server/src/NodeConnectionData.cpp +++ b/domain-server/src/NodeConnectionData.cpp @@ -29,6 +29,9 @@ NodeConnectionData NodeConnectionData::fromDataStream(QDataStream& dataStream, c // NOTE: QDataStream::readBytes() - The buffer is allocated using new []. Destroy it with the delete [] operator. delete[] rawBytes; + + // read the hardware address sent by the client + dataStream >> newHeader.hardwareAddress; } dataStream >> newHeader.nodeType diff --git a/domain-server/src/NodeConnectionData.h b/domain-server/src/NodeConnectionData.h index 9264db637e..bcbbdf0a40 100644 --- a/domain-server/src/NodeConnectionData.h +++ b/domain-server/src/NodeConnectionData.h @@ -28,6 +28,7 @@ public: HifiSockAddr senderSockAddr; QList interestList; QString placeName; + QString hardwareAddress; QByteArray protocolVersion; }; diff --git a/libraries/networking/src/NodeList.cpp b/libraries/networking/src/NodeList.cpp index 7a778edaad..361070b306 100644 --- a/libraries/networking/src/NodeList.cpp +++ b/libraries/networking/src/NodeList.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -346,6 +347,28 @@ void NodeList::sendDomainServerCheckIn() { // include the protocol version signature in our connect request QByteArray protocolVersionSig = protocolVersionsSignature(); packetStream.writeBytes(protocolVersionSig.constData(), protocolVersionSig.size()); + + // if possible, include the MAC address for the current interface in our connect request + QString hardwareAddress; + + for (auto networkInterface : QNetworkInterface::allInterfaces()) { + for (auto interfaceAddress : networkInterface.addressEntries()) { + if (interfaceAddress.ip() == _localSockAddr.getAddress()) { + // this is the interface whose local IP matches what we've detected the current IP to be + hardwareAddress = networkInterface.hardwareAddress(); + + // stop checking interfaces and addresses + break; + } + } + + // stop looping if this was the current interface + if (!hardwareAddress.isEmpty()) { + break; + } + } + + packetStream << hardwareAddress; } // pack our data to send to the domain-server including diff --git a/libraries/networking/src/udt/PacketHeaders.cpp b/libraries/networking/src/udt/PacketHeaders.cpp index 88285602e1..b2fca69b03 100644 --- a/libraries/networking/src/udt/PacketHeaders.cpp +++ b/libraries/networking/src/udt/PacketHeaders.cpp @@ -67,7 +67,7 @@ PacketVersion versionForPacketType(PacketType packetType) { return static_cast(DomainConnectionDeniedVersion::IncludesExtraInfo); case PacketType::DomainConnectRequest: - return static_cast(DomainConnectRequestVersion::HasProtocolVersions); + return static_cast(DomainConnectRequestVersion::HasMACAddress); case PacketType::DomainServerAddedNode: return static_cast(DomainServerAddedNodeVersion::PermissionsGrid); diff --git a/libraries/networking/src/udt/PacketHeaders.h b/libraries/networking/src/udt/PacketHeaders.h index 502ecc3951..8d63b972cc 100644 --- a/libraries/networking/src/udt/PacketHeaders.h +++ b/libraries/networking/src/udt/PacketHeaders.h @@ -207,7 +207,8 @@ enum class AvatarMixerPacketVersion : PacketVersion { enum class DomainConnectRequestVersion : PacketVersion { NoHostname = 17, HasHostname, - HasProtocolVersions + HasProtocolVersions, + HasMACAddress }; enum class DomainConnectionDeniedVersion : PacketVersion {