Indy 9
TIdSocksInfo
Hierarchy, Properties, Methods, Events, See Also, Unit: IdSocks
Implements SOCKS protocol support for Indy clients.
TIdSocksInfo = class(TIdComponent)
Unit
IdSocks
Description
TIdSocksInfo is a TIdComponent descendant that implements support for the SOCKS protocol, as described in the Internet Standards document:

  • RFC 1928 - SOCKS Protocol Version 5 (http://www.rfc-editor.org/rfc/rfc1928.txt)

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:


TIdSocksInfo.Authentication
TIdSocksInfo
Indicates the authentication type required for SOCKS client connection.
property Authentication: TSocksAuthentication;
Description
Authentication is a TSocksAuthentication property that represents the authentication mechanism required for the client Connection, and can include one of the following values or meanings:

  • saNoAuthentication - No authentication required.

  • saUsernamePassword - Username and Password authentication required.

The default value for Authentication is ID_SOCKS_AUTH, as assigned in the Create constructor.


TIdSocksInfo.Host
TIdSocksInfo, See Also
Represents the host name or numeric IP address for a SOCKS proxy connection.
property Host: string;
Description
Host is a String property that represents the host name or numeric IP address for a SOCKS proxy server. Use Port for the numeric port number for the connection.

TIdSocksInfo.IOHandler
TIdSocksInfo, See Also
Input/output mechanism used for the proxied connection.
property IOHandler: TIdIOHandler;
Description
IOHandler is a TIdIOHandler property that represents the input/output mechanism used for reading and writing value to or from the connection that is the endpoint for the Socks proxy. IOHandler is used when MakeSocks4Connection and MakeSocks5Connection are called to establish the proxy connection to Host and Port using the Authentication for the Username and Password values.

TIdSocksInfo.Password
TIdSocksInfo
Represents the authentication credentials used for the SOCKS proxy connection.
property Password: string;
Description
Password is a String property that represents the authentication credentials used for a SOCKS Version 5 proxy connection. Username and Password are used in the MakeSocks5Connection method when Authentication contains the value saUsernamePassword and MakeSocksConnection is called.

TIdSocksInfo.Port
TIdSocksInfo
Represents the port number used for a SOCKS proxy connection.
property Port: Integer;
Description
Port is an Integer property that represents the port number used for the connection to a SOCKS proxy server. The default value for Port is ID_SOCKS_PORT, as assigned in the Create constructor.

Use Host to specify the server name or IP address for the connection.


TIdSocksInfo.Username
TIdSocksInfo
Represents the authentication identity used for the SOCKS proxy connection.
property Username: string;
Description
Username is a String property that represents the authentication identity used for a SOCKS proxy connection. Username and Password are used in the MakeSocks4Connection and MakeSocks5Connection methods when MakeSocksConnection is called.

TIdSocksInfo.Version
TIdSocksInfo
Specifies the SOCKS version required for the proxied client connection.
property Version: TSocksVersion;
Description
Version is a TSocksVersion property that indicates the version of the SOCKS protocol to be used for the client connection to a proxy server. There are currently two versions of the SOCKS protocol: SOCKS Version 4 and SOCKS Version 5.

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.


TIdSocksInfo.Create
TIdSocksInfo
Constructor for the object instance.
constructor Create(AOwner: TComponent); override;
Parameters
AOwner: TComponent
Owner of the object instance.
Description
Create is the constructor for the object instance. Create calls the inherited Create method using the value specified in AOwner. Create also assigns the default values for properties, including:


TIdSocksInfo.MakeSocks4Connection
TIdSocksInfo
Establishes the socket connection used for a SOCKS proxy connection.
procedure MakeSocks4Connection(const AHost: string; const APort: Integer);
Parameters
const AHost: string
Host name or IP address for a socks connection request.
const APort: Integer
Port number for a socks connection request.
Description
MakeSocks4Connection is a procedure that establishes the TIdTCPConnection used for a SOCKS proxy connection. MakeSocks4Connection is called from MakeSocksConnection when the value in Version is svSocks4 or svSocks4A.

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:


TIdSocksInfo.MakeSocks5Connection
TIdSocksInfo, See Also
Establishes the socket connection used for a SOCKS proxy connection.
procedure MakeSocks5Connection(const AHost: string; const APort: Integer);
Parameters
const AHost: string
Host name or IP address for a socks connection request.
const APort: Integer
Port number for a socks connection request.
Description
MakeSocks5Connection is a procedure that establishes the TIdTCPConnection used for a SOCKS proxy connection. MakeSocks5Connection is called from MakeSocksConnection when the value in Version is svSocks5.

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.


TIdSocksInfo.MakeSocksConnection
TIdSocksInfo
Opens a SOCKS connection using version-specific connection handling.
procedure MakeSocksConnection(const AHost: string; const APort: Integer);
Parameters
const AHost: string
Host name or IP address for a socks connection request.
const APort: Integer
Port number for a socks connection request.
Description
MakeSocksConnection is a procedure that allows the client to establish a socket connection to the proxy server for the destination address identified in AHost and APort. MakeSocksConnection insures that the correct connection processing is performed for the SOCKS Version required for the client connection.

MakeSocksConnection calls MakeSocks4Connection when Version contains the value svSocks4 or svSocks4A. MakeSocksConnection calls MakeSocks5Connection when Version contains the value svSocks5.


Created with Doc-O-Matic 2 donated to Project JEDI. Commercial license available from the Doc-O-Matic site.