23 lines
773 B
C++
23 lines
773 B
C++
|
#include "dns.h"
|
||
|
|
||
|
PRErrorCode LookupName(char *hostname, PRNetAddr *result) {
|
||
|
// Attempt to resolve a name.
|
||
|
PRAddrInfo *addrInfos = PR_GetAddrInfoByName(hostname, PR_AF_UNSPEC, PR_AI_ADDRCONFIG);
|
||
|
void *iter = nullptr;
|
||
|
// PRNetAddr firstAddr;
|
||
|
// PRNetAddr tempAddr;
|
||
|
// do {
|
||
|
iter = PR_EnumerateAddrInfo(iter, addrInfos, 0, result);
|
||
|
char ipString[80];
|
||
|
PRStatus status = PR_NetAddrToString(result, ipString, 75);
|
||
|
if(status == PR_FAILURE) {
|
||
|
const PRErrorCode err = PR_GetError();
|
||
|
fprintf(stderr, "Error: Converting PRNetAddr to string %d: %s\n",
|
||
|
err, PR_ErrorToName(err));
|
||
|
return err;
|
||
|
}
|
||
|
printf("Found IP Address: %s\n", ipString);
|
||
|
return 0;
|
||
|
// break;
|
||
|
// } while(iter);
|
||
|
}
|