TorControl

Control a Tor server using the socket connection. The spec of the control protocol: https://gitweb.torproject.org/torspec.git/blob_plain/HEAD:/control-spec.txt

author Kévin Dunglas

 Methods

Creates a new instance of the controller

__construct(array $options) 

Parameters

$options

array

Configuration settings All settings are optional. - hostname: server to join (default: 127.0.0.1) - port: port to try (default: 9051) - authmethod: connection method (if not set will try to autodetect) Allowed values: - TorControl::AUTH_METHOD_NULL: no security - TorControl::AUTH_METHOD_HASHEDPASSWORD: password - TorControl::AUTH_METHOD_COOKIE: cookie file - password: the password (mandatory if AUTH_METHOD_HASHEDPASSWORD is used) - cookiefile: the file (if TorControl::AUTH_METHOD_COOKIE is used, if not set will autodetect) - timeout: connection timeout (default: default_socket_timeout's PHP setting)

Destructs the instance

__destruct() 

Authenticates to the Tor server

authenticate() : \TorControl\TorControl

Autodetect authentication method if not set in options

Exceptions

\Exception

Returns

Connects to the Tor server

connect() : \TorControl\TorControl

Executes a command on the Tor server

executeCommand(string $cmd) : array

Parameters

$cmd

string

Exceptions

\TorControl\Exception\IOError
\TorControl\Exception\ProtocolError

Returns

array

Gets an option

getOption(string $key) : mixed

Parameters

$key

string

Returns

mixed

Gets the controller connection status

isConnected() : boolean

Returns

boolean

Closes the connection to the Tor server

quit() 

Quotes and escapes to use in a command

quote(string $str) : string
Static

Parameters

$str

string

Returns

string

Check if connected

checkConnected() 

Detects auth method using the PROTOCOLINFO command

detectAuthMethod() 

 Properties

 

$connected : boolean
 

$defautOptions : array
 

$options : array
 

$socket : resource

 Constants

   

AUTH_METHOD_HASHEDPASSWORD

AUTH_METHOD_HASHEDPASSWORD 
 

AUTH_METHOD_NOT_SET

AUTH_METHOD_NOT_SET 
 

AUTH_METHOD_NULL

AUTH_METHOD_NULL