Search code examples
delphiindyindy10delphi-10.2-tokyo

How to use proxies with Indy TIdWhois?


I cannot figure out how to use proxies with TIdWhois. Does anybody have a clue for me?

Following Remy's description, I use the following code:

w:=TIdWhois.Create(nil);
p:=TIdConnectThroughHttpProxy.Create(nil);
io:=TIdIOHandlerStack.Create(nil);
p.Host:=<proxy-ip>
p.port:=<proxy-port>
io.TransparentProxy:=p;
w.io:=io;
w.host:=<whois-server>
w.port:=43;
w.WHoIs(<domain>);

Monitoring the ports, it still use my real IP for the request.

What am I doing wrong?


Solution

  • Indy 10 natively supports two types of proxies:

    • HTTP, via the TIdConnectThroughHttpProxy component.

    • SOCKS 4/4a/5, via the TIdSocksInfo component.

    To use either one of them, you need to:

    1. Assign a TIdIOHandlerSocket-derived component, such as TIdIOHandlerStack, to the client's IOHandler property.

    2. Assign the desired proxy component to the TIdIOHandlerSocket.TransparentProxy property, set its Host and Port properties to the Host/Port of the desired proxy server, and enable it accordingly (via the TIdConnectThroughHttpProxy.Enabled or TIdSocksInfo.Version property).

    3. Set the client's Host and Port properties to the Host/Port of the target server, and then Connect() and use the client normally.