TCP ======
For Indy 8.0
In Delphi, do the following:
IdTCPClient1.SocksInfo.Host := [the DNS name of the proxy server or its IP address] IdTCPClient1.SocksInfo.Protocol := [svNoSocks for no SOCKS support, svSocks4 for SOCKS 4, svSocks4A for SOCKS 4 with protocol extension, and svSocks5 for SOCKS 5 protocol] IdTCPClient1.SocksInfo.Authentication := [saNoAuthentication for no SOCKS authentication or saUsernamePassword for username and password authentication]
In C++Builder, do the following:
IdTCPClient1->SocksInfo->Host = [the DNS name of the proxy server or its IP address] IdTCPClient1->SocksInfo->Protocol = [svNoSocks for no SOCKS support, svSocks4 for SOCKS 4, svSocks4A for SOCKS 4 with protocol extension, and svSocks5 for SOCKS 5 protocol] IdTCPClient1->SocksInfo->Authentication = [saNoAuthentication for no SOCKS authentication or saUsernamePassword for username and password authentication]
For Indy 9.0
1. Create an IOHandler such as TIdIOHandlerSocket or TIdSSLIOHandlerSocket and assign the TCPClient.IOHandler property this. 2. Create a TIdSocksInfo object and assign it to the IOHandler's SocksInfo property. 3. Set the TIdSocksInfo properties as required.
For Indy 10
1. Create an IOHandler such as TIdIOHandlerStack or SSL IOHandler and assign the TCPClient.IOHandler property this. 2. Create a TIdSocksInfo object and assign it to the IOHandler's TransparentProxy property. 3. Set the TIdSocksInfo properties as required. 4. If there is another proxy that the SOCKS Proxy itself needs to use, you have to use, set the Chained Proxy to a TIdCustomTransparentProxy such as TIdSocksInfo for another socks Proxy or a TIdConnectThroughHttpProxy for a HTTP Tunneling proxy.
UDP ======
Starting with Indy 10 build 51, we introduced the ability to use a SOCKS with UDP. However, this will only work with SOCKS protocol version 5 and the proxy server must support the UDP Associate method described in RFC 1928 - SOCKS Protocol Version 5.
1. Create a TIdSocksInfo object and assign it to the TIdUDPClient.TransparentProxy property. 2. Set the TIdSocksInfo properties as required. 3. Call TIdUDPClient.OpenProxy just before you use any receive or send calls. 4. After completing all of your receive and send calls, call TIdUDPClient.CloseProxy.
or if you are using the optional TIdUDPClient.Connect and TIdUDPClient.Disconnect methods, you can simply:
1. Create a TIdSocksInfo object and assign it to the TIdUDPClient.TransparentProxy property. 2. Set the TIdSocksInfo properties as required. 3. Call the TIdUDPClient.Connect method and it will open a connection to your proxy and call TIdUDPClient.Disconnect to close the connection to the proxy.
|
请发表评论