Vidalia  0.3.1
Public Slots | Signals | Public Member Functions | Private Slots | Private Member Functions | Private Attributes | List of all members
TorControl Class Reference

#include <TorControl.h>

Inheritance diagram for TorControl:

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 (ControlMethod::Method method=ControlMethod::Port)
 
 ~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 connect (const QString &path)
 
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)
 
QString ipToCountry (const QHostAddress &ip, QString *errmsg=0)
 
bool takeOwnership (QString *errmsg)
 

Private Slots

void onStopped (int exitCode, QProcess::ExitStatus exitStatus)
 
void getBootstrapPhase ()
 
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
 
ControlMethod::Method _method
 

Detailed Description

Definition at line 49 of file TorControl.h.

Constructor & Destructor Documentation

TorControl::TorControl ( ControlMethod::Method  method = ControlMethod::Port)
TorControl::~TorControl ( )

Default destructor

Definition at line 98 of file TorControl.cpp.

References _controlConn, 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 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 298 of file TorControl.cpp.

References authenticationFailed(), base16_encode(), err(), onAuthenticated(), and send().

Referenced by MainWindow::authenticate(), MainWindow::tryCookie(), and MainWindow::tryHashed().

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

References authenticationFailed(), err(), onAuthenticated(), send(), and string_escape().

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 getBootstrapPhase(), and 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 1055 of file TorControl.cpp.

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

Referenced by DEF_TYPE1().

bool TorControl::closeStream ( const StreamId streamId,
QString *  errmsg = 0 
)
slot

Closes the stream specified by streamId.

Definition at line 1092 of file TorControl.cpp.

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

Referenced by TorControlPrototype::closeStream().

void TorControl::closeTorStdout ( )

Stops reading log messages from the Tor process's stdout. This has no effect if isVidaliaRunningTor() is false.

Definition at line 179 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 195 of file TorControl.cpp.

References _controlConn, and ControlConnection::connect().

Referenced by MainWindow::connectFailed(), and MainWindow::started().

void TorControl::connect ( const QString &  path)

Connect to Tor's control socket. The control socket to use is determined by Vidalia's configuration file.

Definition at line 203 of file TorControl.cpp.

References _controlConn, and ControlConnection::connect().

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

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

Referenced by MainWindow::disconnect().

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

References AddressMap::add(), AddressMap::AddressMapCache, AddressMap::AddressMapConfig, AddressMap::AddressMapControl, and getInfo().

Referenced by TorControlPrototype::getAddressMap(), and NetViewer::loadAddressMap().

void TorControl::getBootstrapPhase ( )
privateslot
QList< Circuit > TorControl::getCircuits ( QString *  errmsg = 0)

Gets a list of current circuits.

Definition at line 1034 of file TorControl.cpp.

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

Referenced by TorControlPrototype::getCircuits(), isCircuitEstablished(), and NetViewer::loadConnections().

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

Referenced by DEF_TYPE2(), TorSettings::getAuthenticationMethod(), TorControlPrototype::getConf(), getConf(), getSocksAddressList(), getSocksPortList(), ServerPage::loadBridgeIdentity(), setConf(), and AbstractTorSettings::torValue().

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

Gets a set of configuration keyvalues and stores them in map.

Definition at line 784 of file TorControl.cpp.

References ControlCommand::addArgument(), ControlReply::getLines(), ReplyLine::getMessage(), and send().

bool TorControl::getConf ( QString  key,
QString &  value,
QString *  errmsg = 0 
)

Gets a single configuration value for key.

Definition at line 821 of file TorControl.cpp.

References getConf().

bool TorControl::getConf ( QString  key,
QStringList &  value,
QString *  errmsg = 0 
)

Gets a list of configuration values for key.

Definition at line 833 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 849 of file TorControl.cpp.

References ControlCommand::addArguments(), ControlReply::getLines(), ReplyLine::getMessage(), send(), and string_unescape().

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

References getConf().

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

References getInfo().

Referenced by TorControlPrototype::getDescriptorAnnotations().

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

References ControlCommand::addArgument(), send(), and ControlReply::toString().

Referenced by ServiceSettings::getHiddenServiceDirectories().

bool TorControl::getInfo ( QHash< QString, QString > &  map,
QString *  errmsg = 0 
)
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 541 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 488 of file TorControl.cpp.

References ControlCommand::addArguments(), ReplyLine::getData(), ControlReply::getLines(), ReplyLine::getMessage(), ReplyLine::hasData(), send(), and string_unescape().

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

References getInfo().

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

References getInfo(), i(), and RouterStatus::isValid().

Referenced by TorControlPrototype::getNetworkStatus(), and 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 962 of file TorControl.cpp.

References getRouterDescriptorText().

Referenced by TorControlPrototype::getRouterDescriptor(), 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 953 of file TorControl.cpp.

References getInfo().

Referenced by DEF_TYPE1(), 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 971 of file TorControl.cpp.

References getInfo().

Referenced by NetViewer::displayRouterInfo(), and TorControlPrototype::getRouterStatus().

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

References getSocksAddressList(), and getSocksPort().

QStringList TorControl::getSocksAddressList ( QString *  errmsg = 0)

Returns a (possibly empty) list of all currently configured SocksListenAddress entries.

Definition at line 596 of file TorControl.cpp.

References getConf().

Referenced by getSocksAddress(), getSocksPortList(), and signal().

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

References getSocksPortList().

Referenced by getSocksAddress().

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

References getConf(), and getSocksAddressList().

Referenced by DEF_TYPE1(), and getSocksPort().

QList< Stream > TorControl::getStreams ( QString *  errmsg = 0)
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 667 of file TorControl.cpp.

References _torVersion, and quint32.

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

QString TorControl::getTorVersionString ( )

Returns Tor's version as a string.

Reeturns Tor's version as a string.

Definition at line 659 of file TorControl.cpp.

References _torVersion.

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

QString TorControl::ipToCountry ( const QHostAddress &  ip,
QString *  errmsg = 0 
)

Gets the ISO-3166 two-letter country code for ip from Tor. Returns a default-constructed QString on failure or if a country code is not known for ip. On failure, errmsg will be set if it's not NULL.

Definition at line 1132 of file TorControl.cpp.

References getInfo(), and QVariant.

Referenced by GeoIpResolver::resolveUsingTor().

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

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

Referenced by MainWindow::authenticationFailed(), start(), and MainWindow::started().

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

References _torProcess.

Referenced by MainWindow::aboutToQuit(), MainWindow::close(), MainWindow::connected(), MainWindow::started(), stop(), 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 ( )
privateslot

Called when the controller has successfully authenticated to Tor.

Definition at line 333 of file TorControl.cpp.

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

Referenced by authenticate().

void TorControl::onDisconnected ( )
privateslot

Emits a signal that the control socket disconnected from Tor

Definition at line 245 of file TorControl.cpp.

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

Referenced by TorControl().

void TorControl::onLogStdout ( const QString &  severity,
const QString &  message 
)
privateslot

Called when Tor has printed a log message to stdout.

Definition at line 187 of file TorControl.cpp.

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

Referenced by TorControl().

void TorControl::onStopped ( int  exitCode,
QProcess::ExitStatus  exitStatus 
)
privateslot

Emits a signal that the Tor process stopped

Definition at line 151 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 ( QStringList  keys,
QString *  errmsg = 0 
)

Tells Tor to reset the given configuration keys back to defaults.

Definition at line 929 of file TorControl.cpp.

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

Referenced by ServerSettings::apply(), TorControlPrototype::resetConf(), resetConf(), and ServiceSettings::unpublishAllServices().

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

References resetConf().

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

References err(), send(), and setConf().

Referenced by ServiceSettings::applyServices(), ConfigDialog::saveConf(), and ServiceSettings::unpublishAllServices().

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

References _controlConn, ControlReply::getMessage(), ControlReply::getStatus(), and ControlConnection::send().

Referenced by authenticate(), closeCircuit(), closeStream(), getBootstrapPhase(), getCircuits(), getConf(), getHiddenServiceConf(), getInfo(), getStreams(), protocolInfo(), resetConf(), saveConf(), send(), setConf(), setEvents(), signal(), takeOwnership(), and useFeature().

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

References send().

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::serverDescriptorAccepted ( )
signal

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

Referenced by TorControl().

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 ( QHash< QString, QString >  map,
QString *  errmsg = 0 
)

Sets each configuration key in map to the value associated with its key.

Definition at line 722 of file TorControl.cpp.

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

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

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

Sets a single configuration key to the given value.

Definition at line 747 of file TorControl.cpp.

References setConf().

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

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

Definition at line 756 of file TorControl.cpp.

References setConf().

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

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

Referenced by BandwidthGraph::BandwidthGraph(), MainWindow::createConnections(), 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 707 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 110 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 ( int  exitCode,
QProcess::ExitStatus  exitStatus 
)
signal

Emitted when the Tor process has stopped

void TorControl::stopped ( )
signal

Emitted when the Tor process has stopped.

Referenced by onStopped().

void TorControl::streamStatusChanged ( const Stream stream)
signal

Emitted when the stream status of stream has changed.

Referenced by TorControl().

bool TorControl::takeOwnership ( QString *  errmsg)

Takes ownership of the tor process it's communicating to

Definition at line 1143 of file TorControl.cpp.

References send().

Referenced by MainWindow::connected().

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

References send().

Referenced by onAuthenticated().

Member Data Documentation

ControlConnection* TorControl::_controlConn
private

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

Definition at line 381 of file TorControl.h.

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

TorEvents* TorControl::_eventHandler
private

Keep track of which events we're interested in

Definition at line 385 of file TorControl.h.

Referenced by TorControl().

TorEvents::Events TorControl::_events
private

Definition at line 386 of file TorControl.h.

Referenced by setEvent(), and setEvents().

ControlMethod::Method TorControl::_method
private

Definition at line 389 of file TorControl.h.

Referenced by TorControl().

TorProcess* TorControl::_torProcess
private

Manages and monitors the Tor process

Definition at line 383 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 388 of file TorControl.h.

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


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