In Indy 10, connect TIdHTTP to a SOCKS proxy through its IOHandler. Assuming the form already owns Http, SocketHandler and Socks components:

Http.IOHandler := SocketHandler;
SocketHandler.TransparentProxy := Socks;
Socks.Host := 'proxy.example';
Socks.Port := 1080;
Socks.Version := svSocks5;

Page := Http.Get('http://example.com/');

Here SocketHandler is a TIdIOHandlerStack and Socks is a TIdSocksInfo. Configure the components before the request. For this public-site example with no proxy credentials configured, choose a SOCKS5 candidate from the SOCKS5 proxy list and keep any obsolete HTTP proxy route cleared as described below. Choosing the SOCKS version matters because the default is svNoSocks.

TIdHTTP’s ProxyParams configure an HTTP proxy. A SOCKS-only route belongs on TransparentProxy instead. Retaining an HTTP proxy there as well can describe another intermediary beyond the SOCKS connection, so clear an obsolete HTTP proxy configuration when it is not part of the intended path.

For SOCKS5 username/password authentication, set Socks.Authentication to saUsernamePassword and supply its Username and Password. An existing SSL-capable IOHandler should retain its TLS role; attach SOCKS to its inherited proxy interface rather than replacing it with a plain handler.

متعلقہ مضامین