X-Git-Url: http://www.lcore.org/git/lcore.git/blobdiff_plain/6cb6b7ede2d178e03fa817bc28474c175f5a93b9..0ac6b47e810e6efaebcdbf3075b633e9b4109341:/dnswin.pas diff --git a/dnswin.pas b/dnswin.pas index ffe472b..e9c2a16 100755 --- a/dnswin.pas +++ b/dnswin.pas @@ -20,7 +20,6 @@ type //release should only be called from the main thread tdnswinasync=class(tthread) private - ipv6preffered : boolean; freverse : boolean; error : integer; freewhendone : boolean; @@ -30,9 +29,9 @@ type public onrequestdone:tsocketevent; name : string; - ip : tbinip; + iplist : tbiniplist; - procedure forwardlookup(name:string;ipv6preffered:boolean); + procedure forwardlookup(name:string); procedure reverselookup(ip:tbinip); destructor destroy; override; procedure release; @@ -234,17 +233,7 @@ var getnameinforesult : integer; begin - if ip.family = AF_INET then begin - sa.InAddr.family := AF_INET; - sa.InAddr.port := 1; - sa.InAddr.addr := ip.ip; - end else {$ifdef ipv6}if ip.family = AF_INET6 then begin - sa.InAddr6.sin6_family := AF_INET6; - sa.InAddr6.sin6_port := 1; - sa.InAddr6.sin6_addr := ip.ip6; - end else{$endif} begin - raise exception.create('unrecognised address family'); - end; + makeinaddrv(ip,'1',sa); populateprocvars; setlength(result,1025); getnameinforesult := getnameinfo(@sa,sizeof(tinetsockaddrv),pchar(result),length(result),nil,0,0); @@ -281,16 +270,16 @@ begin end; end; -procedure tdnswinasync.forwardlookup(name:string;ipv6preffered:boolean); +procedure tdnswinasync.forwardlookup(name:string); begin self.name := name; - self.ipv6preffered := ipv6preffered; freverse := false; resume; end; procedure tdnswinasync.reverselookup(ip:tbinip); begin - self.ip := ip; + iplist := biniplist_new; + biniplist_add(iplist,ip); freverse := true; resume; end; @@ -298,14 +287,14 @@ end; procedure tdnswinasync.execute; var error : integer; - l:tbiniplist; + begin error := 0; if reverse then begin - name := winreverselookup(ip,error); + name := winreverselookup(biniplist_get(iplist,0),error); end else begin - l := winforwardlookuplist(name,0,error); - ip := biniplist_get(l,0); + iplist := winforwardlookuplist(name,0,error); + end; postmessage(hwnddnswin,wm_user,error,taddrint(self)); end;