Search code examples
delphiindyindy10delphi-10.3-rio

How to use TIdWhois with SOCKS proxy


I'm getting whois information using this code:

IdWhois1.Host := 'whois.nic.tld';
ServerResultStr := IdWhois1.WhoIs('google.tld');

But I need to query the whois server (port 43) using a SOCKS proxy server.

I'm using Delphi 10.3.3. Is there any way to achieve this by using TIdWhois?


Solution

  • SOCKS is handled in Indy using the TIdSocksInfo component. You can configure it with the proxy details as needed (Host, Port, Version, Authentication, etc).

    To make TIdWhois (or any TCP client) connect to its target server through TIdSocksInfo, you need to do the following:

    • assign a TIdIOHandlerSocket-derived component (TIdIOHandlerStack, or any TIdSSLIOHandlerSocketBase-derived component, like TIdSSLIOHandlerSocketOpenSSL) to the TIdWhois.IOHandler property.

    • assign the TIdSocksInfo to the IOHandler's TransparentProxy property.