X-Git-Url: http://www.lcore.org/git/lcore.git/blobdiff_plain/095083d60a366c89e8bf240e35bd8315c5772c41..560d0547386a23a8fb79d1919d60dfdd04b49f62:/dnssync.pas diff --git a/dnssync.pas b/dnssync.pas index 66d9802..c2b7456 100644 --- a/dnssync.pas +++ b/dnssync.pas @@ -46,6 +46,8 @@ function forwardlookuplist(name:ansistring;timeout:integer):tbiniplist; //details as above function reverselookup(ip:tbinip;timeout:integer):ansistring; +//function that the app can use to know whether the builtin or system resolver is being used +function willusebuiltindns_sync:boolean; const @@ -73,6 +75,24 @@ implementation type tdnsstatearr=array[0..numsock-1] of tdnsstate; + +function willusebuiltindns_sync:boolean; +begin + result := false; + {$ifdef mswindows} + if usewindns and (overridednsserver = '') and not (hostsfile_disabled or hostsfile_onlylocalhost) then begin + // + end else + {$endif} + begin + {$ifdef syncdnscore} + result := true; + {$endif} + end; +end; + + + {$ifdef syncdnscore} @@ -328,7 +348,7 @@ begin end; {$ifdef mswindows} - if usewindns and (overridednsserver = '') then begin + if usewindns and (overridednsserver = '') and not (hostsfile_disabled or hostsfile_onlylocalhost) then begin if (useaf = useaf_v4) then a := af_inet else if (useaf = useaf_v6) then a := af_inet6 else a := 0; result := winforwardlookuplist(name,a,dummy); {$ifdef ipv6} @@ -353,6 +373,15 @@ begin {$ifdef syncdnscore} {$ifdef ipv6}initpreferredmode;{$endif} + if ((overridednsserver = '') or hostsfile_alsocustomserver) and (not hostsfile_disabled) then begin + //try a hosts file lookup + l := hostsfile_forwardlookuplist(name); + if (biniplist_getcount(l) > 0) then begin + result := l; + exit; + end; + end; + numsockused := 0; result := biniplist_new; @@ -380,7 +409,9 @@ begin biniplist_addlist(result,state[1].resultlist); {$endif} end; - {$endif} + {$else} + result := biniplist_new; + {$endif} end; end; @@ -399,16 +430,25 @@ var state:tdnsstatearr; begin {$ifdef mswindows} - if usewindns and (overridednsserver = '') then begin + if usewindns and (overridednsserver = '') and not (hostsfile_disabled or hostsfile_onlylocalhost) then begin result := winreverselookup(ip,dummy); exit; end; {$endif} {$ifdef syncdnscore} + + if ((overridednsserver = '') or hostsfile_alsocustomserver) and (not hostsfile_disabled) then begin + //try a hosts file lookup + result := hostsfile_reverselookup(ip); + if (result <> '') then exit; + end; + setstate_reverse(ip,state[0]); numsockused := 1; resolveloop(timeout,state,numsockused); result := state[0].resultstr; + {$else} + result := ''; {$endif} end;