X-Git-Url: http://www.lcore.org/git/lcore.git/blobdiff_plain/8bc22a17b97149d69fd377f5e9f5ed617a4385db..560d0547386a23a8fb79d1919d60dfdd04b49f62:/dnsasync.pas diff --git a/dnsasync.pas b/dnsasync.pas index 5e72cc0..d387059 100644 --- a/dnsasync.pas +++ b/dnsasync.pas @@ -80,10 +80,21 @@ type end; +//function that the app can use to know whether the builtin or system resolver is being used +function willusebuiltindns_async:boolean; + implementation uses sysutils; + +function willusebuiltindns_async:boolean; +begin + result := true; + {$ifdef winasyncdns}if usewindns and (overridednsserver = '') and not (hostsfile_disabled or hostsfile_onlylocalhost) then result := false;{$endif} +end; + + constructor tdnsasync.create; begin inherited create(aowner); @@ -254,6 +265,7 @@ procedure tdnsasync.forwardlookup; var bip : tbinip; i : integer; + willusewindns:boolean; begin ipstrtobin(name,bip); @@ -265,10 +277,14 @@ begin exit; end; + willusewindns := false; + {$ifdef winasyncdns} + if usewindns and (addr = '') and (overridednsserver = '') and not (hostsfile_disabled or hostsfile_onlylocalhost) then willusewindns := true; + {$endif} + if overrideaf = useaf_default then begin {$ifdef ipv6} - {$ifdef winasyncdns}if not (usewindns and (addr = '') and (overridednsserver = '')) then{$endif} - initpreferredmode; + if not willusewindns then initpreferredmode; {$endif} requestaf := useaf; end else begin @@ -276,7 +292,7 @@ begin end; {$ifdef winasyncdns} - if usewindns and (addr = '') and (overridednsserver = '') then begin + if willusewindns then begin dwas := tdnswinasync.create; dwas.onrequestdone := winrequestdone; @@ -286,6 +302,15 @@ begin end; {$endif} + if (((overridednsserver = '') and (addr = '')) or hostsfile_alsocustomserver) and (not hostsfile_disabled) then begin + //try a hosts file lookup + fresultlist := hostsfile_forwardlookuplist(name); + if (biniplist_getcount(fresultlist) > 0) then begin + onrequestdone(self,0); + exit; + end; + end; + numsockused := 0; fresultlist := biniplist_new; if (requestaf <> useaf_v6) then begin @@ -308,7 +333,7 @@ end; procedure tdnsasync.reverselookup; begin {$ifdef winasyncdns} - if usewindns and (addr = '') then begin + if usewindns and (addr = '') and (overridednsserver = '') and not (hostsfile_disabled or hostsfile_onlylocalhost) then begin dwas := tdnswinasync.create; dwas.onrequestdone := winrequestdone; dwas.reverselookup(binip); @@ -316,6 +341,15 @@ begin end; {$endif} + if (((overridednsserver = '') and (addr = '')) or hostsfile_alsocustomserver) and (not hostsfile_disabled) then begin + //try a hosts file lookup + states[0].resultstr := hostsfile_reverselookup(binip); + if (states[0].resultstr <> '') then begin + onrequestdone(self,0); + exit; + end; + end; + setstate_reverse(binip,states[0]); numsockused := 1; asyncprocess(0);