/[lcore]/trunk/dnssync.pas
ViewVC logotype

Diff of /trunk/dnssync.pas

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2 by beware, Sun Mar 30 00:16:07 2008 UTC revision 13 by plugwash, Mon Mar 31 01:26:50 2008 UTC
# Line 44  Line 44 
44  //details as above  //details as above
45  function reverselookup(ip:tbinip;timeout:integer):string;  function reverselookup(ip:tbinip;timeout:integer):string;
46    
 {$ifdef linux}{$ifdef ipv6}  
 function getv6localips:tbiniplist;  
 procedure initpreferredmode;  
47    
 var  
   preferredmodeinited:boolean;  
   
 {$endif}{$endif}  
48    
49  const  const
50    tswrap=$4000;    tswrap=$4000;
# Line 274  Line 267 
267  end;  end;
268  {$endif}  {$endif}
269    
 procedure addipsoffamily(var l:tbiniplist;const l2:tbiniplist;family:integer);  
 var  
   a:integer;  
   biniptemp:tbinip;  
 begin  
   for a := biniplist_getcount(l2)-1 downto 0 do begin  
     biniptemp := biniplist_get(l2,a);  
     if (biniptemp.family = family) then biniplist_add(l,biniptemp);  
   end;  
 end;  
270    
271    
272  function forwardlookuplist(name:string;timeout:integer):tbiniplist;  function forwardlookuplist(name:string;timeout:integer):tbiniplist;
# Line 383  Line 366 
366    {$endif}    {$endif}
367  end;  end;
368    
 {$ifdef linux}{$ifdef ipv6}{$ifdef syncdnscore}  
 function getv6localips:tbiniplist;  
 var  
   t:textfile;  
   s,s2:string;  
   ip:tbinip;  
   a:integer;  
 begin  
   result := biniplist_new;  
   
   assignfile(t,'/proc/net/if_inet6');  
   {$i-}reset(t);{$i+}  
   if ioresult <> 0 then exit; {none found, return empty list}  
   
   while not eof(t) do begin  
     readln(t,s);  
     s2 := '';  
     for a := 0 to 7 do begin  
       if (s2 <> '') then s2 := s2 + ':';  
       s2 := s2 + copy(s,(a shl 2)+1,4);  
     end;  
     ipstrtobin(s2,ip);  
     if ip.family <> 0 then biniplist_add(result,ip);  
   end;  
   closefile(t);  
 end;  
   
 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;  
   useaf := useaf_preferv4;  
   l := getv6localips;  
   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;  
 end;  
   
 {$endif}{$endif}{$endif}  
   
369  {$ifdef win32}  {$ifdef win32}
370    var    var
371      wsadata : twsadata;      wsadata : twsadata;

Legend:
Removed from v.2  
changed lines
  Added in v.13

No admin address has been configured">No admin address has been configured
ViewVC Help
Powered by ViewVC 1.1.22