TorControl Class Reference

#include <TorControl.h>

List of all members.

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)
void logMessage (tc::Severity level, const QString &msg)
void bandwidthUpdate (quint64 bytesReceived, quint64 bytesSent)
void streamStatusChanged (const Stream &stream)
void circuitStatusChanged (const Circuit &circuit)
void addressMapped (const QString &from, const QString &to, const QDateTime &expires)
void newDescriptors (const QStringList &ids)
void circuitEstablished ()
void dangerousTorVersion (tc::TorVersionStatus reason, const QString &version, const QStringList &recommended)
void bootstrapStatusChanged (const BootstrapStatus &status)
void dangerousPort (quint16 port, bool rejected)
void socksError (tc::SocksError type, const QString &destination)
void externalAddressChanged (const QHostAddress &ip, const QString &hostname)
void clockSkewed (int skew, const QString &source)
void bug (const QString &reason)
void dnsHijacked ()
void dnsUseless ()
void checkingOrPortReachability (const QHostAddress &ip, quint16 port)
void orPortReachabilityFinished (const QHostAddress &ip, quint16 port, bool reachable)
void checkingDirPortReachability (const QHostAddress &ip, quint16 port)
void dirPortReachabilityFinished (const QHostAddress &ip, quint16 port, bool reachable)
void serverDescriptorRejected (const QHostAddress &ip, quint16 port, const QString &reason)
void serverDescriptorAccepted (const QHostAddress &ip, quint16 port)
void serverDescriptorAccepted ()

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 isCircuitEstablished ()
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::Event e, bool add=true, bool set=true, 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)
QStringList getRouterDescriptorText (const QString &id, 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 onStopped (int exitCode, QProcess::ExitStatus exitStatus)
void onDisconnected ()
void onLogStdout (const QString &severity, const 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_eventHandler
TorEvents::Events _events
QString _torVersion


Detailed Description

Definition at line 49 of file TorControl.h.


Constructor & Destructor Documentation

TorControl::TorControl (  ) 

TorControl::~TorControl (  ) 

Default destructor

Definition at line 98 of file TorControl.cpp.

References _controlConn, disconnect(), isConnected(), isVidaliaRunningTor(), and stop().


Member Function Documentation

void TorControl::addressMapped ( const QString &  from,
const QString &  to,
const QDateTime &  expires 
) [signal]

Emitted when Tor has mapped the address from to the address to. expires indicates the time at which when the address mapping will no longer be considered valid.

Referenced by TorControl().

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 278 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 259 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().

void TorControl::bandwidthUpdate ( quint64  bytesReceived,
quint64  bytesSent 
) [signal]

Emitted when Tor sends a bandwidth usage update (roughly once every second). bytesReceived is the number of bytes read by Tor over the previous second and bytesWritten is the number of bytes sent over the same interval.

Referenced by TorControl().

BootstrapStatus TorControl::bootstrapStatus ( QString *  errmsg = 0  ) 

void TorControl::bootstrapStatusChanged ( const BootstrapStatus status  )  [signal]

Emitted during Tor's startup process to indicate how far in its bootstrapping process it has progressed. status may indicate the current bootstrapping stage or an error during bootstrapping.

Referenced by TorControl().

void TorControl::bug ( const QString &  reason  )  [signal]

Emitted when Tor has encountered an internal bug. reason is Tor's description of the bug.

Referenced by TorControl().

void TorControl::checkingDirPortReachability ( const QHostAddress &  ip,
quint16  port 
) [signal]

Indicates Tor has started testing the reachability of its directory port using the IP address ip and port port.

Referenced by TorControl().

void TorControl::checkingOrPortReachability ( const QHostAddress &  ip,
quint16  port 
) [signal]

Indicates Tor has started testing the reachability of its OR port using the IP address ip and port port.

Referenced by TorControl().

void TorControl::circuitEstablished (  )  [signal]

Indicates Tor has been able to successfully establish one or more circuits.

Referenced by TorControl().

void TorControl::circuitStatusChanged ( const Circuit circuit  )  [signal]

Emitted when the circuit status of circuit has changed.

Referenced by TorControl().

void TorControl::clockSkewed ( int  skew,
const QString &  source 
) [signal]

Indicates that Tor has determined the client's clock is potentially skewed by skew seconds relative to source.

Referenced by TorControl().

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 982 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 1019 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 175 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 191 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 TorControl().

void TorControl::connectFailed ( QString  errmsg  )  [signal]

Emitted when the controller failed to connect to Tor.

Referenced by TorControl().

void TorControl::dangerousPort ( quint16  port,
bool  rejected 
) [signal]

Emitted when the user attempts to establish a connection to some destination on port port, which is a port known to use plaintext connections (as determined by Tor's WarnPlaintextPorts and RejectPlaintextPorts torrc options). rejected indicates whether Tor rejected the connection or permitted it to connect anyway.

Referenced by TorControl().

void TorControl::dangerousTorVersion ( tc::TorVersionStatus  reason,
const QString &  version,
const QStringList &  recommended 
) [signal]

Indicates that Tor has decided the user's Tor software version is no longer recommended for some reason. recommended is a list of Tor software versions that are considered current.

Referenced by TorControl().

void TorControl::dirPortReachabilityFinished ( const QHostAddress &  ip,
quint16  port,
bool  reachable 
) [signal]

Tor has completed testing the reachability of its directory port using the IP address ip and port port. If the user's directory port was reachable, reachable will be set to true.

Referenced by TorControl().

void TorControl::disconnect (  ) 

Disconnect from Tor's control socket

Disconnect from Tor's control port

Definition at line 198 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().

void TorControl::dnsHijacked (  )  [signal]

Emitted when Tor determines that the user's DNS provider is providing an address for non-existent domains when it should really be saying "NXDOMAIN".

Referenced by TorControl().

void TorControl::dnsUseless (  )  [signal]

Emitted when Tor determines that the user's DNS provider is providing a hijacked address even for well-known websites.

Referenced by TorControl().

void TorControl::externalAddressChanged ( const QHostAddress &  ip,
const QString &  hostname 
) [signal]

Emitted when Tor decides the client's external IP address has changed to ip. If hostname is non-empty, Tor obtained the new value for ip by resolving hostname.

Referenced by 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 1029 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 961 of file TorControl.cpp.

References ControlReply::getData(), Circuit::isValid(), and send().

Referenced by isCircuitEstablished(), 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 824 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 790 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 774 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 762 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 725 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 707 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 936 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 833 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 474 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 438 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 482 of file TorControl.cpp.

References getInfo().

bool TorControl::getInfo ( QHash< QString, QString > &  map,
QString *  errmsg = 0 
)

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 908 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 889 of file TorControl.cpp.

References getRouterDescriptorText().

Referenced by NetViewer::loadNetworkStatus(), and NetViewer::newDescriptors().

QStringList TorControl::getRouterDescriptorText ( const QString &  id,
QString *  errmsg = 0 
)

Returns an unparsed router descriptor for the router whose fingerprint matches id. The returned text can later be parsed by the RouterDescriptor class. If id is invalid, then an empty QStringList is returned.

Definition at line 880 of file TorControl.cpp.

References getInfo().

Referenced by NetViewer::displayRouterInfo(), and getRouterDescriptor().

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 898 of file TorControl.cpp.

References getInfo().

Referenced by NetViewer::displayRouterInfo().

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 512 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 537 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 549 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 561 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 993 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 608 of file TorControl.cpp.

References _torVersion.

Referenced by NetViewer::addRouter(), ServerSettings::apply(), NetworkSettings::apply(), MainWindow::authenticated(), StatusEventWidget::clockSkewed(), ServerSettings::confValues(), isCircuitEstablished(), and ServerPage::onAuthenticated().

QString TorControl::getTorVersionString (  ) 

Returns Tor's version as a string.

Reeturns Tor's version as a string.

Definition at line 600 of file TorControl.cpp.

References _torVersion.

Referenced by AboutDialog::AboutDialog(), StatusEventWidget::authenticated(), and StatusEventWidget::clockSkewed().

bool TorControl::isCircuitEstablished (  ) 

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 383 of file TorControl.cpp.

References Circuit::Built, getCircuits(), getInfo(), getTorVersion(), and Circuit::status().

Referenced by StatusEventWidget::authenticated(), MainWindow::authenticated(), and MainWindow::running().

bool TorControl::isConnected (  ) 

bool TorControl::isRunning (  ) 

Detect if the Tor process is running

Detect if the Tor process is running.

Definition at line 166 of file TorControl.cpp.

References _controlConn, _torProcess, and ControlConnection::isConnected().

Referenced by MainWindow::authenticationFailed(), 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 159 of file TorControl.cpp.

References _torProcess.

Referenced by MainWindow::aboutToQuit(), MainWindow::close(), MainWindow::started(), and ~TorControl().

void TorControl::logMessage ( tc::Severity  level,
const QString &  msg 
) [signal]

Emitted when Tor writes the message msg to the control port with message severity level.

Referenced by onLogStdout(), and TorControl().

void TorControl::newDescriptors ( const QStringList &  ids  )  [signal]

Emitted when Tor has received one or more new router descriptors. ids contains a list of digests of the new descriptors.

Referenced by TorControl().

void TorControl::onAuthenticated (  )  [private, slot]

Called when the controller has successfully authenticated to Tor.

Definition at line 294 of file TorControl.cpp.

References _torVersion, authenticated(), getInfo(), and useFeature().

Referenced by authenticate().

void TorControl::onDisconnected (  )  [private, slot]

Emits a signal that the control socket disconnected from Tor

Definition at line 206 of file TorControl.cpp.

References _torProcess, _torVersion, disconnected(), and TorProcess::openStdout().

Referenced by TorControl().

void TorControl::onLogStdout ( const QString &  severity,
const QString &  message 
) [private, slot]

Called when Tor has printed a log message to stdout.

Definition at line 183 of file TorControl.cpp.

References logMessage(), and tc::severityFromString().

Referenced by TorControl().

void TorControl::onStopped ( int  exitCode,
QProcess::ExitStatus  exitStatus 
) [private, slot]

Emits a signal that the Tor process stopped

Definition at line 147 of file TorControl.cpp.

References _controlConn, ControlConnection::cancelConnect(), ControlConnection::Connecting, ControlConnection::status(), and stopped().

Referenced by TorControl().

void TorControl::orPortReachabilityFinished ( const QHostAddress &  ip,
quint16  port,
bool  reachable 
) [signal]

Tor has completed testing the reachability of its OR port using the IP address ip and port port. If the user's OR port was reachable, reachable will be set to true.

Referenced by TorControl().

ProtocolInfo TorControl::protocolInfo ( QString *  errmsg = 0  ) 

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 870 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 856 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 848 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 248 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 233 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().

void TorControl::serverDescriptorAccepted (  )  [signal]

Emitted when at least one directory authority has accepted the user's server descriptor.

Referenced by TorControl().

void TorControl::serverDescriptorAccepted ( const QHostAddress &  ip,
quint16  port 
) [signal]

Emitted when the directory authority with IP address ip and port port accepted the user's server descriptor.

void TorControl::serverDescriptorRejected ( const QHostAddress &  ip,
quint16  port,
const QString &  reason 
) [signal]

Emitted when the directory authority with IP address ip and port port rejected the user's server descriptor. reason describes why the descriptor was rejected (e.g., malformed, skewed clock, etc.).

Referenced by TorControl().

bool TorControl::setConf ( QString  keyAndValue,
QString *  errmsg = 0 
)

Sets a single configuration string that is formatted <key=escaped value>.

Definition at line 697 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 688 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 663 of file TorControl.cpp.

References ControlCommand::addArgument(), i(), send(), and string_escape().

Referenced by TorSettings::apply(), ServerSettings::apply(), NetworkSettings::apply(), ServiceSettings::applyServices(), setConf(), and MainWindow::warnDangerousPort().

bool TorControl::setEvent ( TorEvents::Event  e,
bool  add = true,
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 638 of file TorControl.cpp.

References _events, isConnected(), and setEvents().

Referenced by BandwidthGraph::BandwidthGraph(), MainWindow::MainWindow(), NetViewer::NetViewer(), MessageLog::registerLogEvents(), and StatusEventWidget::StatusEventWidget().

bool TorControl::setEvents ( QString *  errmsg = 0  ) 

Register events of interest with Tor

Register for the events currently in the event list

Definition at line 648 of file TorControl.cpp.

References _events, ControlCommand::addArgument(), TorEvents::EVENT_MAX, TorEvents::EVENT_MIN, send(), and TorEvents::toString().

Referenced by MainWindow::authenticated(), MessageLog::registerLogEvents(), and setEvent().

bool TorControl::signal ( TorSignal::Signal  sig,
QString *  errmsg = 0 
)

void TorControl::socksError ( tc::SocksError  type,
const QString &  destination 
) [signal]

Emitted when Tor detects a problem with a SOCKS connection from the user, such as a bad hostname, dangerous SOCKS protocol type, or a bad hostname. type indicates the type of error encountered and destination (if non-empty) specifies the attempted connection destination address or hostname.

Referenced by TorControl().

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 114 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 start(), and TorControl().

void TorControl::startFailed ( QString  errmsg  )  [signal]

Emitted when the Tor process fails to start.

Referenced by TorControl().

bool TorControl::stop ( QString *  errmsg = 0  ) 

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

void TorControl::streamStatusChanged ( const Stream stream  )  [signal]

Emitted when the stream status of stream has changed.

Referenced by TorControl().

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 355 of file TorControl.cpp.

References send().

Referenced by onAuthenticated().


Member Data Documentation

Instantiates a connection used to talk to Tor's control port

Definition at line 371 of file TorControl.h.

Referenced by connect(), disconnect(), isConnected(), isRunning(), onStopped(), send(), signal(), stop(), TorControl(), and ~TorControl().

Keep track of which events we're interested in

Definition at line 375 of file TorControl.h.

Referenced by TorControl().

TorEvents::Events TorControl::_events [private]

Definition at line 376 of file TorControl.h.

Referenced by setEvent(), and setEvents().

Manages and monitors the Tor process

Definition at line 373 of file TorControl.h.

Referenced by closeTorStdout(), isRunning(), isVidaliaRunningTor(), onDisconnected(), start(), stop(), and TorControl().

QString TorControl::_torVersion [private]

The version of Tor we're currently talking to.

Definition at line 378 of file TorControl.h.

Referenced by getTorVersion(), getTorVersionString(), onAuthenticated(), and onDisconnected().


The documentation for this class was generated from the following files:

Generated on Mon Aug 30 19:14:04 2010 for Vidalia by  doxygen 1.5.9