Showing the changes to interface/src/main.cpp (1 of 2 files). Show all
Unified · Split
| @@ -58,7 +58,7 @@ int simulate_on = 1; · 57 unmodified lines | ||
| 58 | 58 | |
| 59 | 59 | const int MAX_PACKET_SIZE = 1500; |
| 60 | 60 | 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 | |
| 62 | 62 | const int DOMAINSERVER_PORT = 40102; |
| 63 | 63 | UDPSocket agentSocket(AGENT_UDP_PORT); |
| 64 | 64 | |
| @@ -929,19 +929,18 @@ int main(int argc, char** argv) · 864 unmodified lines | ||
| 929 | 929 | incomingPacket = new char[MAX_PACKET_SIZE]; |
| 930 | 930 | |
| 931 | 931 | // 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); | |
| 945 | 944 | |
| 946 | 945 | //std::cout << "Test address: " << inet_ntoa(testAddress.sin_addr) << "\n"; |
| 947 | 946 | |