X-Git-Url: http://www.lcore.org/git/lcore.git/blobdiff_plain/9763940f8849e5c807566157829a1e6d2c9172ee..1c8b91ca0f6891a397357c7cf7d77af18c15937d:/dnsasync.pas?ds=inline diff --git a/dnsasync.pas b/dnsasync.pas index 59660d7..5e72cc0 100644 --- a/dnsasync.pas +++ b/dnsasync.pas @@ -7,18 +7,20 @@ //not seem to have any form of retry code. unit dnsasync; - +{$ifdef fpc} + {$mode delphi} +{$endif} interface +{$include lcoreconfig.inc} + uses - {$ifdef mswindows} + {$ifdef winasyncdns} dnswin, {$endif} lsocket,lcore, classes,binipstuff,dnscore,btime,lcorernd; -{$include lcoreconfig.inc} - const numsock=1{$ifdef ipv6}+1{$endif}; @@ -39,7 +41,7 @@ type dnsserverids : array[0..numsock-1] of integer; startts:double; - {$ifdef mswindows} + {$ifdef winasyncdns} dwas : tdnswinasync; {$endif} @@ -49,7 +51,7 @@ type procedure asyncprocess(socketno:integer); procedure receivehandler(sender:tobject;error:word); function sendquery(socketno:integer;const packet:tdnspacket;len:integer):boolean; - {$ifdef mswindows} + {$ifdef winasyncdns} procedure winrequestdone(sender:tobject;error:word); {$endif} @@ -110,7 +112,7 @@ begin end; end; - {$ifdef mswindows} + {$ifdef winasyncdns} if assigned(dwas) then begin dwas.release; dwas := nil; @@ -147,7 +149,7 @@ begin if states[socketno].resultaction <> action_done then begin //we ignore packets that come after we are done if dnsserverids[socketno] >= 0 then begin - reportlag(dnsserverids[socketno],trunc((unixtimefloat-startts)*1000000)); + reportlag(dnsserverids[socketno],trunc((wintimefloat-startts)*1000000)); dnsserverids[socketno] := -1; end; { writeln('received reply');} @@ -170,7 +172,7 @@ begin result := false; if len = 0 then exit; {no packet} if sockets[socketno].state <> wsconnected then begin - startts := unixtimefloat; + startts := wintimefloat; if port = '' then port := '53'; sockets[socketno].Proto := 'udp'; sockets[socketno].ondataavailable := receivehandler; @@ -265,7 +267,7 @@ begin if overrideaf = useaf_default then begin {$ifdef ipv6} - {$ifdef mswindows}if not (usewindns and (addr = '')) then{$endif} + {$ifdef winasyncdns}if not (usewindns and (addr = '') and (overridednsserver = '')) then{$endif} initpreferredmode; {$endif} requestaf := useaf; @@ -273,8 +275,8 @@ begin requestaf := overrideaf; end; - {$ifdef mswindows} - if usewindns and (addr = '') then begin + {$ifdef winasyncdns} + if usewindns and (addr = '') and (overridednsserver = '') then begin dwas := tdnswinasync.create; dwas.onrequestdone := winrequestdone; @@ -305,7 +307,7 @@ end; procedure tdnsasync.reverselookup; begin - {$ifdef mswindows} + {$ifdef winasyncdns} if usewindns and (addr = '') then begin dwas := tdnswinasync.create; dwas.onrequestdone := winrequestdone; @@ -342,7 +344,7 @@ procedure tdnsasync.cancel; var socketno : integer; begin - {$ifdef mswindows} + {$ifdef winasyncdns} if assigned(dwas) then begin dwas.release; dwas := nil; @@ -365,7 +367,7 @@ begin onrequestdone(self,0); end; -{$ifdef mswindows} +{$ifdef winasyncdns} procedure tdnsasync.winrequestdone(sender:tobject;error:word); begin