Indy 9
|
TIdSocksInfo = class(TIdComponent)
The SOCKS protocol is used to isolate the internal network structure of an organization from from an exterior network, such as the Internet, through the use of network firewalls. These firewalls typically act as an application-layer gateway between networks, and usually offer controlled access using common Internet protocol clients such as TELNET, FTP, HTTP, and SMTP.
The SOCKS protocol is designed as a framework for transparent and secure traversal of firewall implementations using both the TCP and UDP domains. SOCKS Version 4 is supported, and provides unsecured firewall traversal for TCP-based clients and servers. SOCKS Version 5 is also supported, and provides strong authentication for the SOCKS protocol.
TIdSocksInfo implements properties required for the SOCKS protocol, including:
TIdSocksInfo implements methods required for the SOCKS protocol, including:
property Authentication: TSocksAuthentication;
The default value for Authentication is ID_SOCKS_AUTH, as assigned in the Create constructor.
property Host: string;
property IOHandler: TIdIOHandler;
property Password: string;
property Port: Integer;
Use Host to specify the server name or IP address for the connection.
property Username: string;
property Version: TSocksVersion;
SOCKS Version 4 provides for unsecured firewall traversal for TCP-based client-server applications.
SOCKS Version 5 provides additional support for UDP-based clients and servers, and a generalized strong authentication scheme.
Version allows the SOCKS client to perform the specifics for establishing a client connection that are required for the differing versions in MakeSocksConnection.
The default value for Version is ID_SOCKS_VER as assigned in the Create constructor.
constructor Create(AOwner: TComponent); override;
procedure MakeSocks4Connection(const AHost: string; const APort: Integer);
MakeSocks4Connection sets the OpCode and Version number for the TIdSocksRequest sent to the proxy server at the location specified in AHost and APort. MakeSocks4Connection will use the host address '0.0.0.1' when Version contains the value svSocks4A.
MakeSocks4Connection also sets the identity for the SOCKS request to the value specified in Username.
MakeSocks4Connection writes the SOCKS request to the Connection for the proxy, and reads the SOCKS response packet. MakeSocks4Connection can raise an exception when the TIdSocksResponse.OpCode contains one of the following values:
procedure MakeSocks5Connection(const AHost: string; const APort: Integer);
MakeSocks5Connection establishes the socket connection for the client, and performs authentication method negotiation as required by the SOCKS version 5 protocol. An EIdSocksAuthMethodError exception will be raised if an unsupported authentication method is returned on the Connection to the proxy server.
MakeSocks5Connection performs client Authentication using the values in Username and Password when authentication method is saUsernamePassword. An EIdSocksServerRespondError exception will be raised when the client is unable to read the authentication status results from the Connection to the proxy server. An EIdSocksAuthError will be raised when an invalid authentication status value is returned on the Connection to the proxy server.
If authentication is required, and successful, MakeSocks5Connection will send the SOCKS connection request packet that specifies the details for the proxied connection. The request packet includes the SOCKS version number, command opcode, address type, destination host name or IP address, and destination port number for the proxied Connection. The destination address and port contain the values specified in AHost and APort.
MakeSocks5Connection will raise an EIdSocksServerRespondError exception when a response cannot be read from the Connection to the proxy server. Other exceptions can be raised when specific values are returned in the result code for the SOCKS reply, and include the following:
An EIdSocksUnknownError exception will be raised if the result code in the SOCKS reply contains an unknown value.
procedure MakeSocksConnection(const AHost: string; const APort: Integer);
MakeSocksConnection calls MakeSocks4Connection when Version contains the value svSocks4 or svSocks4A. MakeSocksConnection calls MakeSocks5Connection when Version contains the value svSocks5.