#include <torcontrol.h>
Public Slots | |
bool | closeCircuit (const CircuitId &circId, bool ifUnused=false, QString *errmsg=0) |
bool | closeStream (const StreamId &streamId, QString *errmsg=0) |
Signals | |
void | started () |
void | startFailed (QString errmsg) |
void | stopped (int exitCode, QProcess::ExitStatus exitStatus) |
void | stopped () |
void | connected () |
void | connectFailed (QString errmsg) |
void | disconnected () |
void | authenticated () |
void | authenticationFailed (QString errmsg) |
Public Member Functions | |
TorControl () | |
~TorControl () | |
void | start (const QString &tor, const QStringList &args) |
bool | stop (QString *errmsg=0) |
bool | isRunning () |
bool | isVidaliaRunningTor () |
void | closeTorStdout () |
void | connect (const QHostAddress &address, quint16 port) |
void | disconnect () |
bool | isConnected () |
bool | authenticate (const QByteArray cookie, QString *errmsg=0) |
bool | authenticate (const QString password=QString(), QString *errmsg=0) |
ProtocolInfo | protocolInfo (QString *errmsg=0) |
BootstrapStatus | bootstrapStatus (QString *errmsg=0) |
bool | circuitEstablished () |
bool | getInfo (QHash< QString, QString > &map, QString *errmsg=0) |
bool | getInfo (QString key, QString &val, QString *errmsg=0) |
QVariantMap | getInfo (const QStringList &keys, QString *errmsg=0) |
QVariant | getInfo (const QString &key, QString *errmsg=0) |
bool | signal (TorSignal::Signal sig, QString *errmsg=0) |
QHostAddress | getSocksAddress (QString *errmsg=0) |
QStringList | getSocksAddressList (QString *errmsg=0) |
quint16 | getSocksPort (QString *errmsg=0) |
QList< quint16 > | getSocksPortList (QString *errmsg=0) |
QString | getTorVersionString () |
quint32 | getTorVersion () |
bool | setEvent (TorEvents::TorEvent e, QObject *obj, bool add, bool set=true, QString *errmsg=0) |
bool | setLogEvents (uint filter, QObject *obj, QString *errmsg=0) |
bool | setEvents (QString *errmsg=0) |
bool | setConf (QHash< QString, QString > map, QString *errmsg=0) |
bool | setConf (QString key, QString value, QString *errmsg=0) |
bool | setConf (QString keyAndValue, QString *errmsg=0) |
bool | getConf (QHash< QString, QString > &map, QString *errmsg=0) |
bool | getConf (QHash< QString, QStringList > &map, QString *errmsg=0) |
bool | getConf (QString key, QString &value, QString *errmsg=0) |
bool | getConf (QString key, QStringList &value, QString *errmsg=0) |
QVariantMap | getConf (const QStringList &keys, QString *errmsg=0) |
QVariant | getConf (const QString &key, QString *errmsg=0) |
QString | getHiddenServiceConf (const QString &key, QString *errmsg=0) |
bool | saveConf (QString *errmsg=0) |
bool | resetConf (QStringList keys, QString *errmsg=0) |
bool | resetConf (QString key, QString *errmsg=0) |
RouterDescriptor | getRouterDescriptor (const QString &id, QString *errmsg=0) |
RouterStatus | getRouterStatus (const QString &id, QString *errmsg=0) |
NetworkStatus | getNetworkStatus (QString *errmsg=0) |
DescriptorAnnotations | getDescriptorAnnotations (const QString &id, QString *errmsg=0) |
CircuitList | getCircuits (QString *errmsg=0) |
StreamList | getStreams (QString *errmsg=0) |
AddressMap | getAddressMap (AddressMap::AddressMapType type=AddressMap::AddressMapAll, QString *errmsg=0) |
Private Slots | |
void | onStarted () |
void | onStartFailed (QString errmsg) |
void | onStopped (int exitCode, QProcess::ExitStatus exitStatus) |
void | onConnected () |
void | onConnectFailed (QString errmsg) |
void | onDisconnected () |
void | onLogStdout (QString severity, QString message) |
void | onAuthenticated () |
Private Member Functions | |
bool | send (ControlCommand cmd, ControlReply &reply, QString *errmsg=0) |
bool | send (ControlCommand cmd, QString *errmsg=0) |
bool | useFeature (const QString &feature, QString *errmsg=0) |
Private Attributes | |
ControlConnection * | _controlConn |
TorProcess * | _torProcess |
TorEvents | _torEvents |
QString | _torVersion |
Definition at line 46 of file torcontrol.h.
TorControl::TorControl | ( | ) |
Default constructor
Definition at line 24 of file torcontrol.cpp.
References _controlConn, _torEvents, _torProcess, connect(), connected(), connectFailed(), disconnected(), onConnected(), onConnectFailed(), onDisconnected(), onLogStdout(), onStarted(), onStartFailed(), onStopped(), started(), and startFailed().
TorControl::~TorControl | ( | ) |
Default destructor
Definition at line 58 of file torcontrol.cpp.
References _controlConn, disconnect(), isConnected(), isVidaliaRunningTor(), and stop().
bool TorControl::authenticate | ( | const QString | password = QString() , |
|
QString * | errmsg = 0 | |||
) |
Sends an authentication password to Tor.
Sends an authentication password to Tor. The syntax is:
"AUTHENTICATE" SP QuotedString CRLF
Definition at line 270 of file torcontrol.cpp.
References authenticationFailed(), err(), onAuthenticated(), send(), and string_escape().
bool TorControl::authenticate | ( | const QByteArray | cookie, | |
QString * | errmsg = 0 | |||
) |
Sends an authentication cookie to Tor.
Sends an authentication cookie to Tor. The syntax is:
"AUTHENTICATE" SP 1*HEXDIG CRLF
Definition at line 251 of file torcontrol.cpp.
References authenticationFailed(), base16_encode(), err(), onAuthenticated(), and send().
Referenced by MainWindow::authenticate().
void TorControl::authenticated | ( | ) | [signal] |
Emitted when the control socket is connected and authenticated.
Referenced by onAuthenticated().
void TorControl::authenticationFailed | ( | QString | errmsg | ) | [signal] |
Emitted when Tor rejects our authentication attempt.
Referenced by authenticate().
BootstrapStatus TorControl::bootstrapStatus | ( | QString * | errmsg = 0 |
) |
Returns the Tor software's current bootstrap phase and status.
Definition at line 353 of file torcontrol.cpp.
References BootstrapStatus::actionFromString(), getInfo(), BootstrapStatus::statusFromString(), string_parse_keyvals(), tc::toConnectionStatusReason(), and tc::toSeverity().
Referenced by MainWindow::authenticated().
bool TorControl::circuitEstablished | ( | ) |
Returns true if Tor either has an open circuit or (on Tor >= 0.2.0.1-alpha) has previously decided it's able to establish a circuit.
Definition at line 374 of file torcontrol.cpp.
References Circuit::Built, getCircuits(), getInfo(), getTorVersion(), and Circuit::status().
Referenced by MainWindow::authenticated().
bool TorControl::closeCircuit | ( | const CircuitId & | circId, | |
bool | ifUnused = false , |
|||
QString * | errmsg = 0 | |||
) | [slot] |
Closes the circuit specified by circId. If ifUnused is true, then the circuit will not be closed unless it is unused.
Definition at line 994 of file torcontrol.cpp.
References ControlCommand::addArgument(), and send().
bool TorControl::closeStream | ( | const StreamId & | streamId, | |
QString * | errmsg = 0 | |||
) | [slot] |
Closes the stream specified by streamId.
Definition at line 1031 of file torcontrol.cpp.
References ControlCommand::addArgument(), and send().
void TorControl::closeTorStdout | ( | ) |
Stops reading log messages from the Tor process's stdout. This has no effect if isVidaliaRunningTor() is false.
Definition at line 150 of file torcontrol.cpp.
References _torProcess, and TorProcess::closeStdout().
Referenced by MainWindow::authenticated().
void TorControl::connect | ( | const QHostAddress & | address, | |
quint16 | port | |||
) |
Connect to Tor's control socket
Connect to Tor's control port. The control port to use is determined by Vidalia's configuration file.
Definition at line 167 of file torcontrol.cpp.
References _controlConn, and ControlConnection::connect().
Referenced by MainWindow::connectFailed(), MainWindow::started(), and TorControl().
void TorControl::connected | ( | ) | [signal] |
Emitted when the controller has connected to Tor
Referenced by onConnected(), and TorControl().
void TorControl::connectFailed | ( | QString | errmsg | ) | [signal] |
Emitted when the controller failed to connect to Tor.
Referenced by onConnectFailed(), and TorControl().
void TorControl::disconnect | ( | ) |
Disconnect from Tor's control socket
Disconnect from Tor's control port
Definition at line 190 of file torcontrol.cpp.
References _controlConn, ControlConnection::disconnect(), and isConnected().
Referenced by MainWindow::disconnect(), and ~TorControl().
void TorControl::disconnected | ( | ) | [signal] |
Emitted when the controller has disconnected from Tor
Referenced by onDisconnected(), and TorControl().
AddressMap TorControl::getAddressMap | ( | AddressMap::AddressMapType | type = AddressMap::AddressMapAll , |
|
QString * | errmsg = 0 | |||
) |
Gets a list of address mappings of the type specified by type (defaults to AddressMapAll.
Definition at line 1041 of file torcontrol.cpp.
References AddressMap::add(), AddressMap::AddressMapCache, AddressMap::AddressMapConfig, AddressMap::AddressMapControl, and getInfo().
Referenced by NetViewer::loadAddressMap().
QList< Circuit > TorControl::getCircuits | ( | QString * | errmsg = 0 |
) |
Gets a list of current circuits.
Definition at line 973 of file torcontrol.cpp.
References ControlReply::getData(), Circuit::isValid(), and send().
Referenced by circuitEstablished(), and NetViewer::loadConnections().
QVariant TorControl::getConf | ( | const QString & | key, | |
QString * | errmsg = 0 | |||
) |
Sends a GETCONF message to Tor with a single key and returns a QVariant containing the value returned by Tor. Returns a default constructed QVariant on failure.
Definition at line 845 of file torcontrol.cpp.
References getConf().
QVariantMap TorControl::getConf | ( | const QStringList & | keys, | |
QString * | errmsg = 0 | |||
) |
Sends a GETCONF message to Tor using the given list of keys and returns a QVariantMap containing the specified keys and their values as returned by Tor. Returns a default constructed QVariantMap on failure.
Sends a GETICONF message to Tor using the given list of keys and returns a QVariantMap containing the specified keys and their values as returned by Tor. Returns a default constructed QVariantMap on failure.
Definition at line 811 of file torcontrol.cpp.
References ControlCommand::addArguments(), ControlReply::getLines(), ReplyLine::getMessage(), and send().
bool TorControl::getConf | ( | QString | key, | |
QStringList & | value, | |||
QString * | errmsg = 0 | |||
) |
Gets a list of configuration values for key.
Definition at line 795 of file torcontrol.cpp.
References getConf().
bool TorControl::getConf | ( | QString | key, | |
QString & | value, | |||
QString * | errmsg = 0 | |||
) |
Gets a single configuration value for key.
Definition at line 783 of file torcontrol.cpp.
References getConf().
bool TorControl::getConf | ( | QHash< QString, QStringList > & | map, | |
QString * | errmsg = 0 | |||
) |
Gets a set of configuration keyvalues and stores them in map.
Definition at line 746 of file torcontrol.cpp.
References ControlCommand::addArgument(), ControlReply::getLines(), ReplyLine::getMessage(), and send().
bool TorControl::getConf | ( | QHash< QString, QString > & | map, | |
QString * | errmsg = 0 | |||
) |
Gets values for a set of configuration keys, each of which has a single value.
Definition at line 728 of file torcontrol.cpp.
Referenced by TorSettings::getAuthenticationMethod(), getConf(), getSocksAddressList(), getSocksPortList(), ServerPage::loadBridgeIdentity(), and AbstractTorSettings::torValue().
DescriptorAnnotations TorControl::getDescriptorAnnotations | ( | const QString & | id, | |
QString * | errmsg = 0 | |||
) |
Returns the annotations for the router whose fingerprint matches id. If id is invalid or the router's descriptor cannot be parsed, then an empty DescriptorAnnotations is returned and errmsg is set if it's not NULL. (Tor >= 0.2.0.13-alpha only)
Returns the annotations for the router whose fingerprint matches id. If id is invalid or the router's annotations cannot be parsed, then an empty DescriptorAnnotations is returned and errmsg is set if it's not NULL. (Tor >= 0.2.0.13-alpha only)
Definition at line 948 of file torcontrol.cpp.
References getInfo().
Referenced by NetViewer::addRouter().
QString TorControl::getHiddenServiceConf | ( | const QString & | key, | |
QString * | errmsg = 0 | |||
) |
Sends a GETCONF message to Tor with the single key and returns a QString containing the value returned by Tor
Definition at line 854 of file torcontrol.cpp.
References ControlCommand::addArgument(), send(), and ControlReply::toString().
Referenced by ServiceSettings::getHiddenServiceDirectories().
QVariant TorControl::getInfo | ( | const QString & | key, | |
QString * | errmsg = 0 | |||
) |
Sends a GETINFO message to Tor with a single key and returns a QVariant containing the value returned by Tor. Returns a default constructed QVariant on failure.
Definition at line 465 of file torcontrol.cpp.
References getInfo().
QVariantMap TorControl::getInfo | ( | const QStringList & | keys, | |
QString * | errmsg = 0 | |||
) |
Sends a GETINFO message to Tor using the given list of keys and returns a QVariantMap containing the specified keys and their values as returned by Tor. Returns a default constructed QVariantMap on failure.
Definition at line 429 of file torcontrol.cpp.
References ControlCommand::addArguments(), ReplyLine::getData(), ControlReply::getLines(), ReplyLine::getMessage(), ReplyLine::hasData(), and send().
bool TorControl::getInfo | ( | QString | key, | |
QString & | val, | |||
QString * | errmsg = 0 | |||
) |
Sends a GETINFO message for a single info value to Tor
Overloaded method to send a GETINFO command for a single info value
Definition at line 473 of file torcontrol.cpp.
References getInfo().
bool TorControl::getInfo | ( | QHash< QString, QString > & | map, | |
QString * | errmsg = 0 | |||
) |
Sends a GETINFO message to Tor based on the given keys
Sends a GETINFO message to Tor based on the given map of keyvals. The syntax is:
"GETINFO" 1*(SP keyword) CRLF
Definition at line 400 of file torcontrol.cpp.
References ControlCommand::addArgument(), ControlReply::getLines(), ReplyLine::getMessage(), and send().
Referenced by bootstrapStatus(), MainWindow::checkTorVersion(), circuitEstablished(), getAddressMap(), getDescriptorAnnotations(), getInfo(), getNetworkStatus(), getRouterDescriptor(), getRouterStatus(), TorSettings::getTorrc(), ServerPage::loadBridgeIdentity(), and onAuthenticated().
NetworkStatus TorControl::getNetworkStatus | ( | QString * | errmsg = 0 |
) |
Returns a RouterStatus object for every known router in the network. If the network status document cannot be parsed, then an empty NetworkStatus is returned.
Definition at line 920 of file torcontrol.cpp.
References getInfo(), i(), and RouterStatus::isValid().
Referenced by NetViewer::loadNetworkStatus().
RouterDescriptor TorControl::getRouterDescriptor | ( | const QString & | id, | |
QString * | errmsg = 0 | |||
) |
Returns the descriptor for the router whose fingerprint matches id. If id is invalid or the router's descriptor cannot be parsed, then an invalid RouterDescriptor is returned.
Definition at line 900 of file torcontrol.cpp.
References getInfo().
Referenced by NetViewer::loadNetworkStatus(), and NetViewer::newDescriptors().
RouterStatus TorControl::getRouterStatus | ( | const QString & | id, | |
QString * | errmsg = 0 | |||
) |
Returns the status of the router whose fingerprint matches id. If id is invalid or the router's status cannot be parsed, then an invalid RouterStatus is returned.
Definition at line 910 of file torcontrol.cpp.
References getInfo().
QHostAddress TorControl::getSocksAddress | ( | QString * | errmsg = 0 |
) |
Returns an address on which Tor is listening for application requests. If none are available, a null QHostAddress is returned.
Definition at line 503 of file torcontrol.cpp.
References getSocksAddressList(), and getSocksPort().
Referenced by NetViewer::onAuthenticated().
QStringList TorControl::getSocksAddressList | ( | QString * | errmsg = 0 |
) |
Returns a (possibly empty) list of all currently configured SocksListenAddress entries.
Definition at line 528 of file torcontrol.cpp.
References getConf().
Referenced by getSocksAddress(), and getSocksPortList().
quint16 TorControl::getSocksPort | ( | QString * | errmsg = 0 |
) |
Returns a valid SOCKS port for Tor, or 0 if Tor is not accepting application requests.
Definition at line 540 of file torcontrol.cpp.
References getSocksPortList().
Referenced by getSocksAddress(), and NetViewer::onAuthenticated().
QList< quint16 > TorControl::getSocksPortList | ( | QString * | errmsg = 0 |
) |
Returns a list of all currently configured SOCKS ports. If Tor is not accepting any application connections, an empty list will be returned.
Definition at line 552 of file torcontrol.cpp.
References getConf(), and getSocksAddressList().
Referenced by getSocksPort().
QList< Stream > TorControl::getStreams | ( | QString * | errmsg = 0 |
) |
Gets a list of current streams.
Definition at line 1005 of file torcontrol.cpp.
References Stream::fromString(), ControlReply::getData(), ControlReply::getMessage(), Stream::isValid(), and send().
Referenced by NetViewer::loadConnections().
quint32 TorControl::getTorVersion | ( | ) |
Returns Tor's version as a numeric value.
Returns Tor's version as a numeric value. Note that this discards any version status flag, such as "-alpha" or "-rc".
Definition at line 599 of file torcontrol.cpp.
References _torVersion.
Referenced by NetViewer::addRouter(), ServerSettings::apply(), NetworkSettings::apply(), MainWindow::authenticated(), circuitEstablished(), ServerSettings::confValues(), ServerPage::onAuthenticated(), NetworkPage::onAuthenticated(), and setEvents().
QString TorControl::getTorVersionString | ( | ) |
Returns Tor's version as a string.
Reeturns Tor's version as a string.
Definition at line 591 of file torcontrol.cpp.
References _torVersion.
Referenced by AboutDialog::showWindow().
bool TorControl::isConnected | ( | ) |
Check if we're connected to Tor's control socket
Check if the control socket is connected
Definition at line 215 of file torcontrol.cpp.
References _controlConn, and ControlConnection::isConnected().
Referenced by MainWindow::close(), disconnect(), MainWindow::enableNewIdentity(), TorSettings::getAuthenticationMethod(), TorSettings::getTorrc(), ServerPage::loadBridgeIdentity(), ConfigDialog::saveChanges(), setEvent(), setLogEvents(), AbstractTorSettings::value(), and ~TorControl().
bool TorControl::isRunning | ( | ) |
Detect if the Tor process is running
Detect if the Tor process is running.
Definition at line 141 of file torcontrol.cpp.
References _controlConn, _torProcess, and ControlConnection::isConnected().
Referenced by MainWindow::authenticationFailed(), AboutDialog::showWindow(), and start().
bool TorControl::isVidaliaRunningTor | ( | ) |
Detects if the Tor process is running under Vidalia.
Detects if the Tor process is running under Vidalia. Returns true if Vidalia owns the Tor process, or false if it was an independent Tor.
Definition at line 134 of file torcontrol.cpp.
References _torProcess.
Referenced by MainWindow::close(), MainWindow::shutdown(), MainWindow::started(), and ~TorControl().
void TorControl::onAuthenticated | ( | ) | [private, slot] |
Called when the controller has successfully authenticated to Tor.
Definition at line 287 of file torcontrol.cpp.
References _torVersion, authenticated(), getInfo(), and useFeature().
Referenced by authenticate().
void TorControl::onConnected | ( | ) | [private, slot] |
Emits a signal that the control socket successfully established a connection to Tor.
Definition at line 175 of file torcontrol.cpp.
References connected().
Referenced by TorControl().
void TorControl::onConnectFailed | ( | QString | errmsg | ) | [private, slot] |
Emits a signal that the control connection to Tor failed.
Definition at line 183 of file torcontrol.cpp.
References connectFailed().
Referenced by TorControl().
void TorControl::onDisconnected | ( | ) | [private, slot] |
Emits a signal that the control socket disconnected from Tor
Definition at line 198 of file torcontrol.cpp.
References _torProcess, _torVersion, disconnected(), and TorProcess::openStdout().
Referenced by TorControl().
void TorControl::onLogStdout | ( | QString | severity, | |
QString | message | |||
) | [private, slot] |
Called when Tor has printed a log message to stdout.
Definition at line 158 of file torcontrol.cpp.
References _torEvents, TorEvents::dispatch(), CustomEventType::LogEvent, tc::toSeverity(), and TorEvents::toTorEvent().
Referenced by TorControl().
void TorControl::onStarted | ( | ) | [private, slot] |
Emits a signal that the Tor process started
Definition at line 95 of file torcontrol.cpp.
References started().
Referenced by TorControl().
void TorControl::onStartFailed | ( | QString | errmsg | ) | [private, slot] |
Emits a signal that the Tor process failed to start and includes an error message (hopefully) indicating why.
Definition at line 103 of file torcontrol.cpp.
References startFailed().
Referenced by TorControl().
void TorControl::onStopped | ( | int | exitCode, | |
QProcess::ExitStatus | exitStatus | |||
) | [private, slot] |
Emits a signal that the Tor process stopped
Definition at line 122 of file torcontrol.cpp.
References _controlConn, ControlConnection::cancelConnect(), ControlConnection::Connecting, ControlConnection::status(), and stopped().
Referenced by TorControl().
ProtocolInfo TorControl::protocolInfo | ( | QString * | errmsg = 0 |
) |
Sends a PROTOCOLINFO command to Tor and parses the response.
Definition at line 300 of file torcontrol.cpp.
References ControlReply::getLines(), ReplyLine::getMessage(), ReplyLine::getStatus(), send(), ProtocolInfo::setAuthMethods(), ProtocolInfo::setCookieAuthFile(), ProtocolInfo::setTorVersion(), and string_parse_keyvals().
Referenced by MainWindow::authenticate().
bool TorControl::resetConf | ( | QString | key, | |
QString * | errmsg = 0 | |||
) |
Tells Tor to reset a configuration key back to its default value.
Tells Tor to reset a single given configuration key back to its default value.
Definition at line 891 of file torcontrol.cpp.
References resetConf().
bool TorControl::resetConf | ( | QStringList | keys, | |
QString * | errmsg = 0 | |||
) |
Tells Tor to reset the given configuration keys back to defaults.
Definition at line 877 of file torcontrol.cpp.
References ControlCommand::addArgument(), and send().
Referenced by ServerSettings::apply(), resetConf(), and ServiceSettings::unpublishAllServices().
bool TorControl::saveConf | ( | QString * | errmsg = 0 |
) |
Asks Tor to save the current configuration to its torrc
Asks Tor to save the current configuration to its torrc.
Definition at line 869 of file torcontrol.cpp.
References send().
Referenced by ServiceSettings::applyServices(), ConfigDialog::saveConf(), and ServiceSettings::unpublishAllServices().
bool TorControl::send | ( | ControlCommand | cmd, | |
QString * | errmsg = 0 | |||
) | [private] |
Send a message to Tor and discard the response
Sends a message to Tor and discards the response.
Definition at line 240 of file torcontrol.cpp.
References send().
bool TorControl::send | ( | ControlCommand | cmd, | |
ControlReply & | reply, | |||
QString * | errmsg = 0 | |||
) | [private] |
Send a message to Tor and read the response
Send a message to Tor and reads the response. If Vidalia was unable to send the command to Tor or read its response, false is returned. If the response was read and the status code is not 250 OK, false is also returned.
Definition at line 225 of file torcontrol.cpp.
References _controlConn, ControlReply::getMessage(), ControlReply::getStatus(), and ControlConnection::send().
Referenced by authenticate(), closeCircuit(), closeStream(), getCircuits(), getConf(), getHiddenServiceConf(), getInfo(), getStreams(), protocolInfo(), resetConf(), saveConf(), send(), setConf(), setEvents(), signal(), and useFeature().
bool TorControl::setConf | ( | QString | keyAndValue, | |
QString * | errmsg = 0 | |||
) |
Sets a single configuration string that is formatted <key=escaped value>.
Definition at line 718 of file torcontrol.cpp.
References setConf().
bool TorControl::setConf | ( | QString | key, | |
QString | value, | |||
QString * | errmsg = 0 | |||
) |
Sets a single configuration key to the given value.
Definition at line 709 of file torcontrol.cpp.
References setConf().
bool TorControl::setConf | ( | QHash< QString, QString > | map, | |
QString * | errmsg = 0 | |||
) |
Sets each configuration key in map to the value associated with its key.
Definition at line 691 of file torcontrol.cpp.
References ControlCommand::addArgument(), send(), and string_escape().
Referenced by TorSettings::apply(), ServerSettings::apply(), NetworkSettings::apply(), ServiceSettings::applyServices(), and setConf().
bool TorControl::setEvent | ( | TorEvents::TorEvent | e, | |
QObject * | obj, | |||
bool | add, | |||
bool | set = true , |
|||
QString * | errmsg = 0 | |||
) |
Sets an event and its handler. If add is true, then the event is added, otherwise it is removed. If set is true, then the given event will be registered with Tor.
Definition at line 629 of file torcontrol.cpp.
References _torEvents, TorEvents::add(), isConnected(), TorEvents::remove(), and setEvents().
Referenced by BandwidthGraph::BandwidthGraph(), MainWindow::MainWindow(), NetViewer::NetViewer(), and setLogEvents().
bool TorControl::setEvents | ( | QString * | errmsg = 0 |
) |
Register events of interest with Tor
Register for the events currently in the event list
Definition at line 668 of file torcontrol.cpp.
References _torEvents, ControlCommand::addArgument(), TorEvents::ClientStatus, TorEvents::eventList(), TorEvents::GeneralStatus, getTorVersion(), send(), TorEvents::ServerStatus, and TorEvents::toString().
Referenced by MainWindow::authenticated(), setEvent(), and setLogEvents().
bool TorControl::setLogEvents | ( | uint | filter, | |
QObject * | obj, | |||
QString * | errmsg = 0 | |||
) |
Registers for a set of logging events according to the given filter.
Registers for a set of logging events according to the given filter. If the control socket is currently connected, this method will try to register the log events with Tor, otherwise it will simply return true.
Definition at line 647 of file torcontrol.cpp.
References _torProcess, TorProcess::closeStdout(), LogEvent::Debug, LogEvent::Error, LogEvent::Info, isConnected(), TorEvents::LogDebug, TorEvents::LogError, TorEvents::LogInfo, TorEvents::LogNotice, TorEvents::LogWarn, LogEvent::Notice, setEvent(), setEvents(), and LogEvent::Warn.
Referenced by MessageLog::registerLogEvents(), and MessageLog::~MessageLog().
bool TorControl::signal | ( | TorSignal::Signal | sig, | |
QString * | errmsg = 0 | |||
) |
Sends a signal to Tor
Definition at line 487 of file torcontrol.cpp.
References _controlConn, ControlCommand::addArgument(), TorSignal::Halt, send(), ControlConnection::send(), TorSignal::Shutdown, and TorSignal::toString().
Referenced by MainWindow::newIdentity(), stop(), and MainWindow::stop().
void TorControl::start | ( | const QString & | tor, | |
const QStringList & | args | |||
) |
Start the Tor process
Start the Tor process using the executable tor and the list of arguments in args.
Definition at line 74 of file torcontrol.cpp.
References _torProcess, expand_filename(), isRunning(), TorService::isSupported(), TorProcess::start(), and started().
Referenced by MainWindow::start().
void TorControl::started | ( | ) | [signal] |
Emitted when the Tor process has started
Referenced by onStarted(), start(), and TorControl().
void TorControl::startFailed | ( | QString | errmsg | ) | [signal] |
Emitted when the Tor process fails to start.
Referenced by onStartFailed(), and TorControl().
bool TorControl::stop | ( | QString * | errmsg = 0 |
) |
Stop the Tor process
Stop the Tor process.
Definition at line 110 of file torcontrol.cpp.
References _controlConn, _torProcess, TorSignal::Halt, ControlConnection::isConnected(), signal(), and TorProcess::stop().
Referenced by MainWindow::connectFailed(), MainWindow::shutdown(), MainWindow::stop(), and ~TorControl().
void TorControl::stopped | ( | ) | [signal] |
Emitted when the Tor process has stopped.
Referenced by onStopped().
void TorControl::stopped | ( | int | exitCode, | |
QProcess::ExitStatus | exitStatus | |||
) | [signal] |
Emitted when the Tor process has stopped
bool TorControl::useFeature | ( | const QString & | feature, | |
QString * | errmsg = 0 | |||
) | [private] |
Tells Tor the controller wants to enable feature via the USEFEATURE control command. Returns true if the given feature was successfully enabled.
Definition at line 346 of file torcontrol.cpp.
References send().
Referenced by onAuthenticated().
ControlConnection* TorControl::_controlConn [private] |
Instantiates a connection used to talk to Tor's control port
Definition at line 231 of file torcontrol.h.
Referenced by connect(), disconnect(), isConnected(), isRunning(), onStopped(), send(), signal(), stop(), TorControl(), and ~TorControl().
TorEvents TorControl::_torEvents [private] |
Keep track of which events we're interested in
Definition at line 235 of file torcontrol.h.
Referenced by onLogStdout(), setEvent(), setEvents(), and TorControl().
TorProcess* TorControl::_torProcess [private] |
Manages and monitors the Tor process
Definition at line 233 of file torcontrol.h.
Referenced by closeTorStdout(), isRunning(), isVidaliaRunningTor(), onDisconnected(), setLogEvents(), start(), stop(), and TorControl().
QString TorControl::_torVersion [private] |
The version of Tor we're currently talking to.
Definition at line 237 of file torcontrol.h.
Referenced by getTorVersion(), getTorVersionString(), onAuthenticated(), and onDisconnected().