X-Git-Url: http://www.lcore.org/git/lcore.git/blobdiff_plain/e27ef2c6aab3a2a8051314bd37bb3b2386775f36..7839389a75b803b3f9e3c88a8f269c178497cdb2:/dnsasync.pas diff --git a/dnsasync.pas b/dnsasync.pas index 4efc205..01bc2ff 100644 --- a/dnsasync.pas +++ b/dnsasync.pas @@ -11,7 +11,7 @@ unit dnsasync; interface uses - {$ifdef win32} + {$ifdef mswindows} dnswin, {$endif} lsocket,lcore, @@ -39,7 +39,7 @@ type dnsserverids : array[0..numsock-1] of integer; startts:double; - {$ifdef win32} + {$ifdef mswindows} dwas : tdnswinasync; {$endif} @@ -49,7 +49,7 @@ type procedure asyncprocess(socketno:integer); procedure receivehandler(sender:tobject;error:word); function sendquery(socketno:integer;const packet:tdnspacket;len:integer):boolean; - {$ifdef win32} + {$ifdef mswindows} procedure winrequestdone(sender:tobject;error:word); {$endif} @@ -109,6 +109,14 @@ begin setstate_request_init('',states[socketno]); end; end; + + {$ifdef mswindows} + if assigned(dwas) then begin + dwas.release; + dwas := nil; + end; + {$endif} + inherited destroy; end; @@ -153,7 +161,7 @@ end; function tdnsasync.sendquery(socketno:integer;const packet:tdnspacket;len:integer):boolean; var - destination : ansistring; + destination : tbinip; inaddr : tinetsockaddrv; trytolisten:integer; begin @@ -185,13 +193,13 @@ begin end; if addr <> '' then begin dnsserverids[socketno] := -1; - destination := addr + destination := ipstrtobinf(addr); end else begin - destination := getcurrentsystemnameserver(dnsserverids[socketno]); + destination := getcurrentsystemnameserverbin(dnsserverids[socketno]); end; - destinations[socketno] := ipstrtobinf(destination); + destinations[socketno] := destination; - {$ifdef ipv6}{$ifdef win32} + {$ifdef ipv6}{$ifdef mswindows} if destinations[socketno].family = AF_INET6 then if (requestaf = useaf_default) then requestaf := useaf_preferv6; {$endif}{$endif} @@ -255,11 +263,9 @@ begin exit; end; - if (overridednsserver <> '') and (addr = '') then addr := overridednsserver; - if overrideaf = useaf_default then begin {$ifdef ipv6} - {$ifdef win32}if not (usewindns and (addr = '')) then{$endif} + {$ifdef mswindows}if not (usewindns and (addr = '')) then{$endif} initpreferredmode; {$endif} requestaf := useaf; @@ -267,7 +273,7 @@ begin requestaf := overrideaf; end; - {$ifdef win32} + {$ifdef mswindows} if usewindns and (addr = '') then begin dwas := tdnswinasync.create; dwas.onrequestdone := winrequestdone; @@ -299,8 +305,7 @@ end; procedure tdnsasync.reverselookup; begin - if (overridednsserver <> '') and (addr = '') then addr := overridednsserver; - {$ifdef win32} + {$ifdef mswindows} if usewindns and (addr = '') then begin dwas := tdnswinasync.create; dwas.onrequestdone := winrequestdone; @@ -316,7 +321,6 @@ end; procedure tdnsasync.customlookup; begin - if (overridednsserver <> '') and (addr = '') then addr := overridednsserver; setstate_custom(name,querytype,states[0]); numsockused := 1; asyncprocess(0); @@ -338,7 +342,7 @@ procedure tdnsasync.cancel; var socketno : integer; begin - {$ifdef win32} + {$ifdef mswindows} if assigned(dwas) then begin dwas.release; dwas := nil; @@ -361,7 +365,7 @@ begin onrequestdone(self,0); end; -{$ifdef win32} +{$ifdef mswindows} procedure tdnsasync.winrequestdone(sender:tobject;error:word); begin