mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-13 15:39:29 +02:00
* Handle recursion for address queries, CNames are also possible (bug ID 34480)
git-svn-id: trunk@42934 -
This commit is contained in:
parent
aee20cd54d
commit
560c0b228e
@ -1033,7 +1033,7 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
Function ResolveAddressAt(Resolver : Integer; Address : String; Var Names : Array of String) : Integer;
|
||||
Function ResolveAddressAt(Resolver : Integer; Address : String; Var Names : Array of String; Recurse: Integer) : Integer;
|
||||
|
||||
|
||||
Var
|
||||
@ -1056,13 +1056,29 @@ begin
|
||||
I:=0;
|
||||
While (I<=MaxAnswer) and NextRR(Ans.Payload,AnsStart,AnsLen,RR) do
|
||||
begin
|
||||
if (Ntohs(RR.AType)=DNSQRY_PTR) and (1=NtoHS(RR.AClass)) then
|
||||
begin
|
||||
Names[i]:=BuildName(Ans.Payload,AnsStart,AnsLen);
|
||||
inc(Result);
|
||||
RR.RDLength := ntohs(RR.RDLength);
|
||||
Inc(AnsStart,RR.RDLength);
|
||||
end;
|
||||
Case Ntohs(RR.AType) of
|
||||
DNSQRY_PTR:
|
||||
if (1=NtoHS(RR.AClass)) then
|
||||
begin
|
||||
Names[i]:=BuildName(Ans.Payload,AnsStart,AnsLen);
|
||||
inc(Result);
|
||||
RR.RDLength := ntohs(RR.RDLength);
|
||||
Inc(AnsStart,RR.RDLength);
|
||||
end;
|
||||
DNSQRY_CNAME:
|
||||
begin
|
||||
if Recurse >= MaxRecursion then
|
||||
begin
|
||||
Result := -1;
|
||||
exit;
|
||||
end;
|
||||
rr.rdlength := ntohs(rr.rdlength);
|
||||
setlength(Address, rr.rdlength);
|
||||
address := stringfromlabel(ans.payload, ansstart);
|
||||
Result := ResolveAddressAt(Resolver, Address, Names, Recurse+1);
|
||||
exit;
|
||||
end;
|
||||
end;
|
||||
Inc(I);
|
||||
end;
|
||||
end;
|
||||
@ -1084,7 +1100,7 @@ begin
|
||||
S:=Format('%d.%d.%d.%d.in-addr.arpa',[nt.s_bytes[4],nt.s_bytes[3],nt.s_bytes[2],nt.s_bytes[1]]);
|
||||
While (Result=0) and (I<=high(DNSServers)) do
|
||||
begin
|
||||
Result:=ResolveAddressAt(I,S,Addresses);
|
||||
Result:=ResolveAddressAt(I,S,Addresses,1);
|
||||
Inc(I);
|
||||
end;
|
||||
end;
|
||||
@ -1111,7 +1127,7 @@ begin
|
||||
I := 0;
|
||||
While (Result=0) and (I<=high(DNSServers)) do
|
||||
begin
|
||||
Result:=ResolveAddressAt(I,S,Addresses);
|
||||
Result:=ResolveAddressAt(I,S,Addresses,1);
|
||||
Inc(I);
|
||||
end;
|
||||
end;
|
||||
|
Loading…
Reference in New Issue
Block a user