2018-08-05 23:04:34 +00:00
|
|
|
#pragma noroot
|
|
|
|
|
2018-07-30 04:40:03 +00:00
|
|
|
#include <tcpip.h>
|
|
|
|
#include <misctool.h>
|
2018-08-01 23:24:43 +00:00
|
|
|
#include <orca.h>
|
2018-07-30 04:40:03 +00:00
|
|
|
#include "hostname.h"
|
|
|
|
|
|
|
|
#define DNR_WAIT_TIME 15 /*seconds*/
|
|
|
|
|
|
|
|
Boolean DoLookupName(Session *sess) {
|
|
|
|
dnrBuffer dnrInfo;
|
|
|
|
|
2018-07-31 02:35:45 +00:00
|
|
|
if (TCPIPValidateIPString(sess->hostName)) {
|
|
|
|
cvtRec cvtInfo;
|
|
|
|
TCPIPConvertIPToHex(&cvtInfo, sess->hostName);
|
|
|
|
sess->ipAddr = cvtInfo.cvtIPAddress;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
TCPIPDNRNameToIP(sess->hostName, &dnrInfo);
|
2018-07-30 04:40:03 +00:00
|
|
|
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 {
|
2018-07-31 02:35:45 +00:00
|
|
|
if (dnrInfo.DNRstatus == DNR_Pending) {
|
|
|
|
TCPIPCancelDNR(&dnrInfo);
|
|
|
|
}
|
2018-07-30 04:40:03 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|