X-Git-Url: http://www.lcore.org/git/lcore.git/blobdiff_plain/968c333d05db5d5ecf3599f8e304c67e64f21159..HEAD:/dnscore.pas diff --git a/dnscore.pas b/dnscore.pas index 6864398..08f99d1 100644 --- a/dnscore.pas +++ b/dnscore.pas @@ -6,12 +6,12 @@ { code wanting to use this dns system should act as follows (note: app - developers will probablly want to use dnsasync or dnssync or write a similar - wrapper unit of thier own). + developers will probably want to use dnsasync or dnssync or write a similar + wrapper unit of their own). for normal lookups call setstate_forward or setstate_reverse to set up the state, for more obscure lookups use setstate_request_init and fill in other - relavent state manually. + relevant state manually. call state_process which will do processing on the information in the state and return an action @@ -20,7 +20,7 @@ action_sendpacket means that dnscore wants the code that calls it to send the packet in sendpacket/sendpacketlen and then start (or go back to) listening for - action_done means the request has completed (either suceeded or failed) + action_done means the request has completed (either succeeded or failed) callers should resend the last packet they tried to send if they have not been asked to send a new packet for more than some timeout value they choose. @@ -32,23 +32,23 @@ following ways. on failure state.resultstr will be an empty string and state.resultbin will - be zeroed out (easilly detected by the fact that it will have a family of 0) + be zeroed out (easily detected by the fact that it will have a family of 0) on success for a A or AAAA lookup state.resultstr will be an empty string - and state.resultbin will contain the result (note: AAAA lookups require IPV6 + and state.resultbin will contain the result (note: AAAA lookups require IPv6 enabled). - if an A lookup fails and the code is built with ipv6 enabled then the code + if an A lookup fails and the code is built with IPv6 enabled then the code will return any AAAA records with the same name. The reverse does not apply - so if an application preffers IPV6 but wants IPV4 results as well it must - check them seperately. + so if an application prefers IPv6 but wants IPv4 results as well it must + check them separately. on success for any other type of lookup state.resultstr will be an empty note the state contains ansistrings, setstate_init with a null name parameter - can be used to clean theese up if required. + can be used to clean these up if required. - callers may use setstate_failure to mark the state as failed themseleves + callers may use setstate_failure to mark the state as failed themselves before passing it on to other code, for example this may be done in the event of a timeout. } @@ -162,7 +162,7 @@ type end; //commenting out functions from interface that do not have documented semantics -//and probablly should not be called from outside this unit, reenable them +//and probably should not be called from outside this unit, reenable them //if you must but please document them at the same time --plugwash //function buildrequest(const name:string;var packet:tdnspacket;requesttype:word):integer; @@ -172,7 +172,7 @@ function makereversename(const binip:tbinip):ansistring; procedure setstate_request_init(const name:ansistring;var state:tdnsstate); -//set up state for a foward lookup. A family value of AF_INET6 will give only +//set up state for a forward lookup. A family value of AF_INET6 will give only //ipv6 results. Any other value will give only ipv4 results procedure setstate_forward(const name:ansistring;var state:tdnsstate;family:integer); @@ -597,7 +597,7 @@ recursed: goto failure; end; - {do /ets/hosts lookup here} + {do /etc/hosts lookup here} state.sendpacketlen := buildrequest(state.queryname,state.sendpacket,state.requesttype); if state.sendpacketlen = 0 then begin failurereason := 'building request packet failed'; @@ -639,7 +639,7 @@ function getcurrentsystemnameserverbin(var id:integer):tbinip; var counter : integer; begin - {override the name server choice here, instead of overriding it whereever it's called + {override the name server choice here, instead of overriding it wherever it's called setting ID to -1 causes it to be ignored in reportlag} if (overridednsserver <> '') then begin result := ipstrtobinf(overridednsserver); @@ -650,7 +650,7 @@ begin end; if not assigned(dnsserverlag) then populatednsserverlist; - if dnsserverlag.count=0 then raise exception.create('no dns servers availible'); + if dnsserverlag.count=0 then raise exception.create('no dns servers available'); id := 0; if dnsserverlag.count >1 then begin for counter := dnsserverlag.count-1 downto 1 do begin @@ -684,31 +684,16 @@ end; {$ifdef ipv6} procedure initpreferredmode; -var - l:tbiniplist; - a:integer; - ip:tbinip; - ipmask_global,ipmask_6to4,ipmask_teredo:tbinip; - begin if preferredmodeinited then exit; if useaf <> useaf_default then exit; - l := getv6localips; - if biniplist_getcount(l) = 0 then exit; - useaf := useaf_preferv4; - ipstrtobin('2000::',ipmask_global); - ipstrtobin('2001::',ipmask_teredo); - ipstrtobin('2002::',ipmask_6to4); - {if there is any v6 IP which is globally routable and not 6to4 and not teredo, prefer v6} - for a := biniplist_getcount(l)-1 downto 0 do begin - ip := biniplist_get(l,a); - if not comparebinipmask(ip,ipmask_global,3) then continue; - if comparebinipmask(ip,ipmask_teredo,32) then continue; - if comparebinipmask(ip,ipmask_6to4,16) then continue; - useaf := useaf_preferv6; - preferredmodeinited := true; - exit; - end; + + if (have_ipv6_connectivity) then + useaf := useaf_preferv6 + else + useaf := useaf_preferv4; + + preferredmodeinited := true; end; {$endif}