Question

I'm using TIdHTTP a lot in my applications and users of mine requested a Socks4/5 feature with a specific timeout. I use my application to communicate with a SSL Website and I only worked with the regular ProxyParams before. How can I add Socks4 and/or Socks5 support to my TIdHTTP Component with a specific timeout?

Edit:

Since I don't have any Socks4/Socks5 proxies, I created my own with a new application to test. I added TIdSocksServer and assigned a TIdServerIOHandlerSSLOpenSSL to it. To make sure it connections I added a Messagebox to the OnConnect. The server listens on Port 8080 and is set to Active:=True;

Here is my code to with my TIdHTTP Component:

procedure NewQuery;
var
 IDHTTP                                : TIdHTTP;
 SSL                                   : TIdSSLIOHandlerSocketOpenSSL;
 Socks                                 : TIdSocksInfo;
begin
 Socks                                 := TidSocksInfo.Create (NIL);
 IDHTTP                                := TIdHTTP.Create(NIL);
 SSL                                   := TIdSSLIOHandlerSocketOpenSSL.Create(NIL);
 IDHTTP.IOHandler                      := SSL;
 SSL.TransparentProxy                  := Socks;
 Socks.Host                            := 'localhost';
 Socks.Port                            := 8080;
 Socks.Authentication                  := saNoAuthentication;
 Socks.Version                         := svSocks4; // or svSocks5
 IDHTTP.ConnectTimeout                 := 5000; // 5 seconds
 IDHTTP.Get ('www.google.com');
end;

Not sure if I used this the right way but it seems like that the GET request works without having it connected to the socks server. Am I using it wrong?

Was it helpful?

Solution

Assign a TIdSocksInfo component to the IOHandler's TransparentProxy property.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top