History

Domain IP is used if static, else looked up.

Philip Rosedale committed 13 years ago

Commit c360fab1 parent 10ff0742 files · +14 −15Browse files

Showing the changes to interface/src/main.cpp (1 of 2 files). Show all

Unified · Split

interface/src/main.cpp+13−14
@@ -58,7 +58,7 @@ int simulate_on = 1; · 57 unmodified lines
5858
5959 const int MAX_PACKET_SIZE = 1500;
6060 char DOMAIN_HOSTNAME[] = "highfidelity.below92.com";
61−char DOMAIN_IP[100] = "192.168.1.47"; // IP Address will be re-set by lookup on startup
61+char DOMAIN_IP[100] = "192.168.1.47"; // IP Address will be used first if not empty string
6262 const int DOMAINSERVER_PORT = 40102;
6363 UDPSocket agentSocket(AGENT_UDP_PORT);
6464
@@ -929,19 +929,18 @@ int main(int argc, char** argv) · 864 unmodified lines
929929 incomingPacket = new char[MAX_PACKET_SIZE];
930930
931931 // Lookup the IP address of things we have hostnames
932− /*
933− printf("need to look this one up\n");
934− struct hostent* pHostInfo;
935− if ((pHostInfo = gethostbyname(DOMAIN_HOSTNAME)) != NULL) {
936− sockaddr_in tempAddress;
937− memcpy(&tempAddress.sin_addr, pHostInfo->h_addr_list[0], pHostInfo->h_length);
938− strcpy(DOMAIN_IP, inet_ntoa(tempAddress.sin_addr));
939− printf("Domain server found: %s\n", DOMAIN_IP);
940−
941− } else {
942− printf("Failed lookup domain server\n");
943− }
944− */
932+ if (atoi(DOMAIN_IP) == 0) {
933+ struct hostent* pHostInfo;
934+ if ((pHostInfo = gethostbyname(DOMAIN_HOSTNAME)) != NULL) {
935+ sockaddr_in tempAddress;
936+ memcpy(&tempAddress.sin_addr, pHostInfo->h_addr_list[0], pHostInfo->h_length);
937+ strcpy(DOMAIN_IP, inet_ntoa(tempAddress.sin_addr));
938+ printf("Domain server %s: %s\n", DOMAIN_HOSTNAME, DOMAIN_IP);
939+
940+ } else {
941+ printf("Failed lookup domainserver\n");
942+ }
943+ } else printf("Using static domainserver IP: %s\n", DOMAIN_IP);
945944
946945 //std::cout << "Test address: " << inet_ntoa(testAddress.sin_addr) << "\n";
947946