\r
function sendquery(socknum:integer;const packet:tdnspacket;len:integer):boolean;\r
var\r
- addr : ansistring;\r
+ ip : tbinip;\r
port : ansistring;\r
inaddr : TInetSockAddrV;\r
begin\r
result := false;\r
if len = 0 then exit; {no packet}\r
\r
- if overridednsserver <> '' then addr := overridednsserver else addr := getcurrentsystemnameserver(id);\r
+ ip := getcurrentsystemnameserverbin(id);\r
\r
{$ifdef ipv6}{$ifdef win32}\r
if toaddr[socknum].family = AF_INET6 then if (useaf = 0) then useaf := useaf_preferv6;\r
{$endif}{$endif}\r
\r
port := toport;\r
- toaddr[socknum] := ipstrtobinf(addr);\r
+ toaddr[socknum] := ip;\r
makeinaddrv(toaddr[socknum],port,inaddr);\r
\r
sendto(fd[socknum],packet,len,0,inaddr,inaddrsize(inaddr));\r
inAddrtemp : TInetSockAddrV;\r
a:integer;\r
biniptemp:tbinip;\r
- addr:ansistring;\r
+\r
begin\r
//init both sockets smultaneously, always, so they get succesive fd's\r
- if fd[0] > 0 then exit;\r
\r
- if overridednsserver <> '' then addr := overridednsserver else addr := getcurrentsystemnameserver(id);\r
- //must get the DNS server here so we know to init v4 or v6\r
+ {recreate sockets every time, reusing them will fail (hang) if the nameserver is changed\r
+ also changing the nameserver can't possibly work}\r
+ {if fd[0] > 0 then exit;}\r
+ for a := 0 to numsock-1 do if (fd[a] > 0) then closesocket(fd[a]);\r
\r
- ipstrtobin(addr,biniptemp);\r
+ biniptemp := getcurrentsystemnameserverbin(id);\r
+ //must get the DNS server here so we know to init v4 or v6\r
\r
if biniptemp.family = AF_INET6 then biniptemp := ipstrtobinf('::') else biniptemp := ipstrtobinf('0.0.0.0');\r
\r
fillchar(state[socknum].recvpacket,sizeof(state[socknum].recvpacket),0);\r
msectotimeval(lag,(currenttime-sendquerytime[socknum]) and tsmask);\r
\r
- if overridednsserver = '' then reportlag(id,(lag.tv_sec*1000000)+lag.tv_usec);\r
+ reportlag(id,(lag.tv_sec*1000000)+lag.tv_usec);\r
\r
SrcLen := SizeOf(Src);\r
state[socknum].recvpacketlen := recvfrom(fd[socknum],state[socknum].recvpacket, SizeOf(state[socknum].recvpacket),0,Srcx,SrcLen);\r
\r
currenttime := getts;\r
\r
- if overridednsserver = '' then reportlag(id,-1);\r
+ reportlag(id,-1);\r
if (currenttime >= endtime) and ((not wrapmode) or (currenttime < starttime)) then begin\r
exit;\r
end else begin\r