interface\r
\r
uses\r
- {$ifdef win32}\r
+ {$ifdef mswindows}\r
dnswin,\r
{$endif}\r
lsocket,lcore,\r
\r
dnsserverids : array[0..numsock-1] of integer;\r
startts:double;\r
- {$ifdef win32}\r
+ {$ifdef mswindows}\r
dwas : tdnswinasync;\r
{$endif}\r
\r
procedure asyncprocess(socketno:integer);\r
procedure receivehandler(sender:tobject;error:word);\r
function sendquery(socketno:integer;const packet:tdnspacket;len:integer):boolean;\r
- {$ifdef win32}\r
+ {$ifdef mswindows}\r
procedure winrequestdone(sender:tobject;error:word);\r
{$endif}\r
\r
onrequestdone:tsocketevent;\r
\r
//addr and port allow the application to specify a dns server specifically\r
- //for this dnsasync object. This is not a reccomended mode of operation\r
+ //for this dnsasync object. This is not a recommended mode of operation\r
//because it limits the app to one dns server but is kept for compatibility\r
//and special uses.\r
- addr,port:string;\r
+ addr,port:ansistring;\r
\r
overrideaf : integer;\r
\r
procedure cancel;//cancel an outstanding dns request\r
- function dnsresult:string; //get result of dnslookup as a string\r
+ function dnsresult:ansistring; //get result of dnslookup as a string\r
procedure dnsresultbin(var binip:tbinip); //get result of dnslookup as a tbinip\r
property dnsresultlist : tbiniplist read fresultlist;\r
- procedure forwardlookup(const name:string); //start forward lookup,\r
- //preffering ipv4\r
+ procedure forwardlookup(const name:ansistring); //start forward lookup,\r
+ //preferring ipv4\r
procedure reverselookup(const binip:tbinip); //start reverse lookup\r
- procedure customlookup(const name:string;querytype:integer); //start custom type lookup\r
+ procedure customlookup(const name:ansistring;querytype:integer); //start custom type lookup\r
\r
constructor create(aowner:tcomponent); override;\r
destructor destroy; override;\r
socketno : integer;\r
begin\r
for socketno := 0 to numsock -1 do begin\r
- if assigned(sockets[socketno]) then begin
+ if assigned(sockets[socketno]) then begin\r
if dnsserverids[socketno] >= 0 then begin\r
reportlag(dnsserverids[socketno],-1);\r
dnsserverids[socketno] := -1;\r
end;\r
sockets[socketno].release;\r
setstate_request_init('',states[socketno]);\r
- end;
+ end;\r
end;\r
+\r
+ {$ifdef mswindows}\r
+ if assigned(dwas) then begin\r
+ dwas.release;\r
+ dwas := nil;\r
+ end;\r
+ {$endif}\r
+\r
inherited destroy;\r
end;\r
\r
Src : TInetSockAddrV;\r
SrcLen : Integer;\r
fromip:tbinip;\r
- fromport:string;\r
+ fromport:ansistring;\r
begin\r
socketno := tlsocket(sender).tag;\r
//writeln('got a reply on socket number ',socketno);\r
\r
function tdnsasync.sendquery(socketno:integer;const packet:tdnspacket;len:integer):boolean;\r
var\r
- destination : string;\r
+ destination : tbinip;\r
inaddr : tinetsockaddrv;\r
trytolisten:integer;\r
begin\r
end;\r
if addr <> '' then begin\r
dnsserverids[socketno] := -1;\r
- destination := addr\r
+ destination := ipstrtobinf(addr);\r
end else begin\r
- destination := getcurrentsystemnameserver(dnsserverids[socketno]);\r
+ destination := getcurrentsystemnameserverbin(dnsserverids[socketno]);\r
end;\r
- destinations[socketno] := ipstrtobinf(destination);\r
+ destinations[socketno] := destination;\r
\r
- {$ifdef ipv6}{$ifdef win32}\r
+ {$ifdef ipv6}{$ifdef mswindows}\r
if destinations[socketno].family = AF_INET6 then if (requestaf = useaf_default) then requestaf := useaf_preferv6;\r
{$endif}{$endif}\r
\r
exit;\r
end;\r
\r
- if (overridednsserver <> '') and (addr = '') then addr := overridednsserver;\r
-\r
if overrideaf = useaf_default then begin\r
{$ifdef ipv6}\r
- {$ifdef win32}if not (usewindns and (addr = '')) then{$endif}\r
+ {$ifdef mswindows}if not (usewindns and (addr = '')) then{$endif}\r
initpreferredmode;\r
{$endif}\r
requestaf := useaf;\r
requestaf := overrideaf;\r
end;\r
\r
- {$ifdef win32}\r
+ {$ifdef mswindows}\r
if usewindns and (addr = '') then begin\r
dwas := tdnswinasync.create;\r
dwas.onrequestdone := winrequestdone;\r
inc(numsockused);\r
end;\r
{$endif}\r
+\r
for i := 0 to numsockused-1 do begin\r
asyncprocess(i);\r
end;\r
-\r
end;\r
\r
procedure tdnsasync.reverselookup;\r
begin\r
- if (overridednsserver <> '') and (addr = '') then addr := overridednsserver;\r
- {$ifdef win32}\r
+ {$ifdef mswindows}\r
if usewindns and (addr = '') then begin\r
dwas := tdnswinasync.create;\r
dwas.onrequestdone := winrequestdone;\r
\r
procedure tdnsasync.customlookup;\r
begin\r
- if (overridednsserver <> '') and (addr = '') then addr := overridednsserver;\r
setstate_custom(name,querytype,states[0]);\r
numsockused := 1;\r
asyncprocess(0);\r
var\r
socketno : integer;\r
begin\r
- {$ifdef win32}\r
+ {$ifdef mswindows}\r
if assigned(dwas) then begin\r
dwas.release;\r
dwas := nil;\r
onrequestdone(self,0);\r
end;\r
\r
-{$ifdef win32}\r
+{$ifdef mswindows}\r
procedure tdnsasync.winrequestdone(sender:tobject;error:word);\r
\r
begin\r