X-Git-Url: http://www.lcore.org/git/lcore.git/blobdiff_plain/e27ef2c6aab3a2a8051314bd37bb3b2386775f36..e9fd84c2a9f04b8d9c1bc79d70c33c8d22d85e26:/dnssync.pas?ds=sidebyside diff --git a/dnssync.pas b/dnssync.pas index 7d6631c..1a506d5 100644 --- a/dnssync.pas +++ b/dnssync.pas @@ -75,14 +75,14 @@ implementation {$i unixstuff.inc} + +{$ifdef syncdnscore} var numsockused:integer; fd:array[0..numsock-1] of integer; state:array[0..numsock-1] of tdnsstate; toaddr:array[0..numsock-1] of tbinip; -{$ifdef syncdnscore} - {$ifdef win32} const winsocket = 'wsock32.dll'; @@ -109,8 +109,7 @@ end; function sendquery(socknum:integer;const packet:tdnspacket;len:integer):boolean; var - a:integer; - addr : ansistring; + ip : tbinip; port : ansistring; inaddr : TInetSockAddrV; begin @@ -118,14 +117,14 @@ begin result := false; if len = 0 then exit; {no packet} - if overridednsserver <> '' then addr := overridednsserver else addr := getcurrentsystemnameserver(id); + ip := getcurrentsystemnameserverbin(id); {$ifdef ipv6}{$ifdef win32} if toaddr[socknum].family = AF_INET6 then if (useaf = 0) then useaf := useaf_preferv6; {$endif}{$endif} port := toport; - toaddr[socknum] := ipstrtobinf(addr); + toaddr[socknum] := ip; makeinaddrv(toaddr[socknum],port,inaddr); sendto(fd[socknum],packet,len,0,inaddr,inaddrsize(inaddr)); @@ -138,16 +137,14 @@ var inAddrtemp : TInetSockAddrV; a:integer; biniptemp:tbinip; - addr:ansistring; + begin //init both sockets smultaneously, always, so they get succesive fd's if fd[0] > 0 then exit; - if overridednsserver <> '' then addr := overridednsserver else addr := getcurrentsystemnameserver(id); + biniptemp := getcurrentsystemnameserverbin(id); //must get the DNS server here so we know to init v4 or v6 - ipstrtobin(addr,biniptemp); - if biniptemp.family = AF_INET6 then biniptemp := ipstrtobinf('::') else biniptemp := ipstrtobinf('0.0.0.0'); @@ -177,7 +174,6 @@ var currenttime : integer; lag : ttimeval; - currenttimeout : ttimeval; selecttimeout : ttimeval; socknum:integer; needprocessing:array[0..numsock-1] of boolean; @@ -257,7 +253,7 @@ begin fillchar(state[socknum].recvpacket,sizeof(state[socknum].recvpacket),0); msectotimeval(lag,(currenttime-sendquerytime[socknum]) and tsmask); - if overridednsserver = '' then reportlag(id,(lag.tv_sec*1000000)+lag.tv_usec); + reportlag(id,(lag.tv_sec*1000000)+lag.tv_usec); SrcLen := SizeOf(Src); state[socknum].recvpacketlen := recvfrom(fd[socknum],state[socknum].recvpacket, SizeOf(state[socknum].recvpacket),0,Srcx,SrcLen); @@ -280,7 +276,7 @@ begin currenttime := getts; - if overridednsserver = '' then reportlag(id,-1); + reportlag(id,-1); if (currenttime >= endtime) and ((not wrapmode) or (currenttime < starttime)) then begin exit; end else begin @@ -299,7 +295,7 @@ end; function forwardlookuplist(name:ansistring;timeout:integer):tbiniplist; var dummy : integer; - a,b:integer; + a:integer; biniptemp:tbinip; l:tbiniplist; begin