From 2fde29e04a1a6e7c033ba0b73065589265e68466 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Thu, 1 Aug 2013 11:53:18 -0700 Subject: [PATCH] use a 0 public address to designate server local to DS --- domain-server/src/main.cpp | 5 +++-- libraries/shared/src/NodeList.cpp | 6 ++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/domain-server/src/main.cpp b/domain-server/src/main.cpp index 5d41efdc67..f62ce10e92 100644 --- a/domain-server/src/main.cpp +++ b/domain-server/src/main.cpp @@ -104,9 +104,10 @@ int main(int argc, const char * argv[]) // so hardcode the EC2 public address for now if (nodePublicAddress.sin_addr.s_addr == serverLocalAddress) { // If we're not running "local" then we do replace the IP - // with the EC2 IP. Otherwise, we use our normal public IP + // with 0. This designates to clients that the server is reachable + // at the same IP address if (!isLocalMode) { - nodePublicAddress.sin_addr.s_addr = 895283510; // local IP in this format... + nodePublicAddress.sin_addr.s_addr = 0; destinationSocket = (sockaddr*) &nodeLocalAddress; } } diff --git a/libraries/shared/src/NodeList.cpp b/libraries/shared/src/NodeList.cpp index 42aa024e9d..8819677bcc 100644 --- a/libraries/shared/src/NodeList.cpp +++ b/libraries/shared/src/NodeList.cpp @@ -352,6 +352,12 @@ int NodeList::processDomainServerList(unsigned char* packetData, size_t dataByte readPtr += unpackSocket(readPtr, (sockaddr*) &nodePublicSocket); readPtr += unpackSocket(readPtr, (sockaddr*) &nodeLocalSocket); + // if the public socket address is 0 then it's reachable at the same IP + // as the domain server + if (nodePublicSocket.sin_addr.s_addr == 0) { + inet_aton(_domainIP, &nodePublicSocket.sin_addr); + } + addOrUpdateNode((sockaddr*) &nodePublicSocket, (sockaddr*) &nodeLocalSocket, nodeType, nodeId); }