mirror of
https://github.com/sheumann/DiskBrowser.git
synced 2024-11-25 17:43:15 +00:00
c237bd661f
This is adapted from NetDisk with minor changes.
41 lines
921 B
C
41 lines
921 B
C
#pragma noroot
|
|
|
|
#include <tcpip.h>
|
|
#include <misctool.h>
|
|
#include <orca.h>
|
|
#include "hostname.h"
|
|
|
|
#define DNR_WAIT_TIME 15 /*seconds*/
|
|
|
|
Boolean DoLookupName(Session *sess) {
|
|
dnrBuffer dnrInfo;
|
|
|
|
if (TCPIPValidateIPString(sess->hostName)) {
|
|
cvtRec cvtInfo;
|
|
TCPIPConvertIPToHex(&cvtInfo, sess->hostName);
|
|
sess->ipAddr = cvtInfo.cvtIPAddress;
|
|
return TRUE;
|
|
}
|
|
|
|
TCPIPDNRNameToIP(sess->hostName, &dnrInfo);
|
|
if (toolerror())
|
|
return FALSE;
|
|
|
|
sess->dnsTime = GetTick();
|
|
while (dnrInfo.DNRstatus == DNR_Pending) {
|
|
if (GetTick() - sess->dnsTime >= DNR_WAIT_TIME * 60)
|
|
break;
|
|
TCPIPPoll();
|
|
}
|
|
|
|
if (dnrInfo.DNRstatus == DNR_OK) {
|
|
sess->ipAddr = dnrInfo.DNRIPaddress;
|
|
return TRUE;
|
|
} else {
|
|
if (dnrInfo.DNRstatus == DNR_Pending) {
|
|
TCPIPCancelDNR(&dnrInfo);
|
|
}
|
|
return FALSE;
|
|
}
|
|
}
|