Class TTCPBlockSocket

DescriptionHierarchyFieldsMethodsProperties

Unit

blcksock

Declaration

type TTCPBlockSocket = class(TSocksBlockSocket)

Description

Implementation of TCP socket.

Supported features: IPv4, IPv6, SSL/TLS (SSL2, SSL3 and TLS), SOCKS5 proxy (outgoing connections and limited incomming), SOCKS4/4a proxy (outgoing connections and limited incomming), TCP through HTTP proxy tunnel.

Hierarchy

TTCPBlockSocket > TSocksBlockSocket > TBlockSocket > TObject

Methods

Overview

Public constructor Create;
Public function Accept: TSocket;
Public procedure CloseSocket; override;
Public procedure Connect(IP, Port: string); override;
Public function GetLocalSinIP: string; override;
Public function GetLocalSinPort: Integer; override;
Public function GetRemoteSinIP: string; override;
Public function GetRemoteSinPort: Integer; override;
Public function GetSocketProtocol: integer; override;
Public function GetSocketType: integer; override;
Public procedure Listen; virtual;
Public function RecvBuffer(Buffer: TMemory; Len: Integer): Integer; override;
Public function SendBuffer(Buffer: TMemory; Length: Integer): Integer; override;
Public function SSLAcceptConnection: Boolean;
Public function SSLCheck: Boolean;
Public procedure SSLDoConnect;
Public procedure SSLDoShutdown;
Public function SSLGetCertInfo: string;
Public function SSLGetCipherAlgBits: integer;
Public function SSLGetCipherBits: integer;
Public function SSLGetCipherName: string;
Public function SSLGetPeerFingerprint: string;
Public function SSLGetPeerIssuer: string;
Public function SSLGetPeerIssuerHash: Cardinal;
Public function SSLGetPeerName: string;
Public function SSLGetPeerSubject: string;
Public function SSLGetPeerSubjectHash: Cardinal;
Public function SSLGetSSLVersion: string;
Public function SSLGetVerifyCert: integer;
Public function WaitingData: Integer; override;

Description

Public function Accept: TSocket;

Waits until new incoming connection comes. After it comes a new socket is automatically created (socket handler is returned by this function as result).

If you use SOCKS, new socket is not created! In this case is used same socket as socket for listening! So, you can accept only one connection in SOCKS mode.

Public procedure CloseSocket; override;

See CloseSocket

Public procedure Connect(IP, Port: string); override;

Connects socket to remote IP address and PORT. The same rules as with Bind method are valid. The only exception is that PORT with 0 value will not be connected. After call to this method a communication channel between local and remote socket is created. Local socket is assigned automatically if not controlled by previous call to Bind method. Structures LocalSin and RemoteSin will be filled with valid values.

If you use SOCKS, activate outgoing TCP connection by SOCKS proxy specified in SocksIP. (By CONNECT method of SOCKS.)

If you use HTTP-tunnel mode, activate outgoing TCP connection by HTTP tunnel specified in HTTPTunnelIP. (By CONNECT method of HTTP protocol.)

If you additionally use SSL mode, then SSL/TLS session was started.

Note: If you call this on non-created socket, then socket is created automaticly.

Public constructor Create;

 

Public function GetLocalSinIP: string; override;

See GetLocalSinIP

Public function GetLocalSinPort: Integer; override;

See GetLocalSinPort

Public function GetRemoteSinIP: string; override;

See GetRemoteSinIP

Public function GetRemoteSinPort: Integer; override;

See GetRemoteSinPort

Public function GetSocketProtocol: integer; override;

Return value of protocol type for socket creation. For TCP return IPPROTO_TCP.

Public function GetSocketType: integer; override;

Return value of socket type. For TCP return SOCK_STREAM.

Public procedure Listen; virtual;

Sets socket to receive mode for new incoming connections. It is necessary to use Bind function call before this method to select receiving port!

If you use SOCKS, activate incoming TCP connection by this proxy. (By BIND method of SOCKS.)

Public function RecvBuffer(Buffer: TMemory; Len: Integer): Integer; override;

See RecvBuffer

Public function SendBuffer(Buffer: TMemory; Length: Integer): Integer; override;

See SendBuffer

Public function SSLAcceptConnection: Boolean;

If you need use this component as SSL/TLS TCP server, then after accepting of inbound connection you need start SSL/TLS session by this method. Before call this function, you must have assigned all neeeded certificates and keys!

Public function SSLCheck: Boolean;

Test last SSL operation for errors. If error occured, then is filled SSLLastError and SSLLastErrorDesc properties.

Public procedure SSLDoConnect;

If you need upgrade existing TCP connection to SSL/TLS mode, then call this method. This method switch this class to SSL mode and do SSL/TSL handshake.

Public procedure SSLDoShutdown;

By this method you can downgrade existing SSL/TLS connection to normal TCP connection.

Public function SSLGetCertInfo: string;

Return all detailed information about certificate from remote side of SSL/TLS connection. Result string is multilined!

Public function SSLGetCipherAlgBits: integer;

Return number of bits in current Cipher algorythm.

Public function SSLGetCipherBits: integer;

Return currently used number of bits in current Cipher algorythm.

Public function SSLGetCipherName: string;

Return currently used Cipher.

Public function SSLGetPeerFingerprint: string;

Return fingerprint of remote SSL peer.

Public function SSLGetPeerIssuer: string;

Return issuer certificate of remote SSL peer.

Public function SSLGetPeerIssuerHash: Cardinal;

Return issuer's certificate hash of remote SSL peer.

Public function SSLGetPeerName: string;

Return peer name from remote side certificate. This is good for verify, if certificate is generated for remote side IP name.

Public function SSLGetPeerSubject: string;

Return subject of remote SSL peer.

Public function SSLGetPeerSubjectHash: Cardinal;

Return subject's hash of remote SSL peer.

Public function SSLGetSSLVersion: string;

Return string with identificator of SSL/TLS version of existing connection.

Public function SSLGetVerifyCert: integer;

Return result value of verify remote side certificate. Look to OpenSSL documentation for possible values. For example 0 is successfuly verified certificate, or 18 is self-signed certificate.

Public function WaitingData: Integer; override;

See WaitingData

Properties

Overview

Public property HTTPTunnel: Boolean;
Published property HTTPTunnelIP: string;
Published property HTTPTunnelPass: string;
Published property HTTPTunnelPort: string;
Published property HTTPTunnelTimeout: integer;
Published property HTTPTunnelUser: string;
Published property SSLBypass: Boolean;
Published property SSLCertCAFile: string;
Published property SSLCertificateFile: string;
Published property SSLCiphers: string;
Public property SSLEnabled: Boolean;
Public property SSLLastError: integer;
Public property SSLLastErrorDesc: string;
Public property SSLLoaded: Boolean;
Published property SSLPassword: string;
Published property SSLPrivateKeyFile: string;
Published property SSLType: TSSLType;
Published property SSLverifyCert: Boolean;

Description

Public property HTTPTunnel: Boolean;

True if is used HTTP tunnel mode.

Published property HTTPTunnelIP: string;

Specify IP address of HTTP proxy. Assingning non-empty value to this property enable HTTP-tunnel mode. This mode is for tunnelling any outgoing TCP connection through HTTP proxy server. (If policy on HTTP proxy server allow this!) Warning: You cannot combine this mode with SOCK5 mode!

Published property HTTPTunnelPass: string;

Specify authorisation password for access to HTTP proxy in HTTP-tunnel mode.

Published property HTTPTunnelPort: string;

Specify port of HTTP proxy for HTTP-tunneling.

Published property HTTPTunnelTimeout: integer;

Specify timeout for communication with HTTP proxy in HTTPtunnel mode.

Published property HTTPTunnelUser: string;

Specify authorisation username for access to HTTP proxy in HTTP-tunnel mode. If you not need authorisation, then let this property empty.

Published property SSLBypass: Boolean;

If is SSL mode enabled and this property is True, then all data (read and write) will not be encrypted/decrypted.

Published property SSLCertCAFile: string;

filename and path to file with bundle of CA certificates. (you may use ca-bundle.crt file from SynaCert.zip)

Published property SSLCertificateFile: string;

Filename and path to PEM file with your certificate. If certificate need password for decrypt, you can assign this password to SSLPassword property.

Published property SSLCiphers: string;

By this property you can modify default set of SSL/TLS ciphers.

Public property SSLEnabled: Boolean;

By this property you can enable or disable SSL mode. Enabling loads needed OpenSSL or SSLeay libraries. Libraries is loaded to memory only once for all Synapse's objects.

Note: when you enable SSL mode, all keys and certificates are loaded (if needed property is unempty)

Public property SSLLastError: integer;

Contains last SSL error code.

Public property SSLLastErrorDesc: string;

If some SSL error is occured, then contains human readable description of this error.

Public property SSLLoaded: Boolean;

Is SSL interface loaded or not?

Published property SSLPassword: string;

Password for decrypting of encoded certificate.

Note: This not work with delphi8. You cannot use password protected certificates with .NET!

Published property SSLPrivateKeyFile: string;

Filename and path to PEM file with your private key.

Published property SSLType: TSSLType;

Here you can specify requested SSL/TLS mode. Default is autodetection, but on some servers autodetection not working properly. In this case you must specify requested SSL/TLS mode by your hand!

Published property SSLverifyCert: Boolean;

If True, then is verified client certificate. (it is good for writing SSL/TLS servers.) When you are not server, but you are client, then if this property is True, verify servers certificate.


Generated by PasDoc 0.8.8.2 on 2005-01-19 20:01:17