Vidalia  0.3.1
Public Types | Signals | Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Member Functions | Static Private Member Functions | List of all members
TorEvents Class Reference

#include <TorEvents.h>

Inheritance diagram for TorEvents:

Public Types

enum  Event {
  Unknown = 0, Bandwidth = (1u << 0), LogDebug = (1u << 1), LogInfo = (1u << 2),
  LogNotice = (1u << 3), LogWarn = (1u << 4), LogError = (1u << 5), CircuitStatus = (1u << 6),
  StreamStatus = (1u << 7), OrConnStatus = (1u << 8), NewDescriptor = (1u << 9), AddressMap = (1u << 10),
  GeneralStatus = (1u << 11), ClientStatus = (1u << 12), ServerStatus = (1u << 13)
}
 

Signals

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 error, const QString &destination)
 
void bug (const QString &reason)
 
void externalAddressChanged (const QHostAddress &ip, const QString &hostname)
 
void clockSkewed (int skew, const QString &source)
 
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

 Q_DECLARE_FLAGS (Events, Event)
 
 TorEvents (QObject *parent=0)
 
void handleEvent (const ControlReply &reply)
 

Static Public Member Functions

static QString toString (TorEvents::Event e)
 

Static Public Attributes

static const Event EVENT_MIN = TorEvents::Bandwidth
 
static const Event EVENT_MAX = TorEvents::ServerStatus
 

Private Member Functions

void handleBandwidthUpdate (const ReplyLine &line)
 
void handleCircuitStatus (const ReplyLine &line)
 
void handleStreamStatus (const ReplyLine &line)
 
void handleLogMessage (const ReplyLine &line)
 
void handleOrConnStatus (const ReplyLine &line)
 
void handleNewDescriptor (const ReplyLine &line)
 
void handleAddressMap (const ReplyLine &line)
 
void handleStatusEvent (Event type, const ReplyLine &line)
 
void handleGeneralStatusEvent (tc::Severity severity, const QString &action, const QHash< QString, QString > &args)
 
void handleClientStatusEvent (tc::Severity severity, const QString &action, const QHash< QString, QString > &args)
 
void handleServerStatusEvent (tc::Severity severity, const QString &action, const QHash< QString, QString > &args)
 

Static Private Member Functions

static Event parseEventType (const ReplyLine &line)
 
static Event toTorEvent (const QString &event)
 
static QPair< QHostAddress,
quint16 > 
splitAddress (const QString &address)
 

Detailed Description

Definition at line 37 of file TorEvents.h.

Member Enumeration Documentation

Asynchronous events sent from Tor to the controller

Enumerator
Unknown 
Bandwidth 
LogDebug 
LogInfo 
LogNotice 
LogWarn 
LogError 
CircuitStatus 
StreamStatus 
OrConnStatus 
NewDescriptor 
AddressMap 
GeneralStatus 
ClientStatus 
ServerStatus 

Definition at line 43 of file TorEvents.h.

Constructor & Destructor Documentation

TorEvents::TorEvents ( QObject *  parent = 0)

Default Constructor

Default constructor

Definition at line 34 of file TorEvents.cpp.

Member Function Documentation

void TorEvents::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 handleAddressMap().

void TorEvents::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 handleBandwidthUpdate().

void TorEvents::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 handleClientStatusEvent().

void TorEvents::bug ( const QString &  reason)
signal

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

Referenced by handleGeneralStatusEvent().

void TorEvents::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 handleServerStatusEvent().

void TorEvents::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 handleServerStatusEvent().

void TorEvents::circuitEstablished ( )
signal

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

Referenced by handleClientStatusEvent().

void TorEvents::circuitStatusChanged ( const Circuit circuit)
signal

Emitted when the circuit status of circuit has changed.

Referenced by handleCircuitStatus().

void TorEvents::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 handleGeneralStatusEvent().

void TorEvents::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 handleClientStatusEvent().

void TorEvents::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 handleGeneralStatusEvent().

void TorEvents::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 handleServerStatusEvent().

void TorEvents::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 handleServerStatusEvent().

void TorEvents::dnsUseless ( )
signal

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

Referenced by handleServerStatusEvent().

void TorEvents::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 handleServerStatusEvent().

void TorEvents::handleAddressMap ( const ReplyLine line)
private

Handles a new or updated address map event.

Handles a new or updated address mapping event. The format for event messages of this type is:

"650" SP "ADDRMAP" SP Address SP Address SP Expiry Expiry = DQUOTE ISOTime DQUOTE / "NEVER"

Expiry is expressed as the local time (rather than GMT).

Definition at line 266 of file TorEvents.cpp.

References addressMapped(), DATE_FMT, and ReplyLine::getMessage().

Referenced by handleEvent().

void TorEvents::handleBandwidthUpdate ( const ReplyLine line)
private

Handle a bandwidth update event

Handle a bandwidth update event, to inform the controller of the bandwidth used in the last second. The format of this message is:

"650" SP "BW" SP BytesRead SP BytesWritten
BytesRead = 1*DIGIT
BytesWritten = 1*DIGIT

Definition at line 160 of file TorEvents.cpp.

References bandwidthUpdate(), and ReplyLine::getMessage().

Referenced by handleEvent().

void TorEvents::handleCircuitStatus ( const ReplyLine line)
private

Handle a circuit status event

Handle a circuit status event. The format of this message is:

"650" SP "CIRC" SP CircuitID SP CircStatus SP Path CircStatus = "LAUNCHED" / ; circuit ID assigned to new circuit "BUILT" / ; all hops finished, can now accept streams "EXTENDED" / ; one more hop has been completed "FAILED" / ; circuit closed (was not built) "CLOSED" ; circuit closed (was built) Path = ServerID *("," ServerID)

Definition at line 184 of file TorEvents.cpp.

References circuitStatusChanged(), ReplyLine::getMessage(), and i().

Referenced by handleEvent().

void TorEvents::handleClientStatusEvent ( tc::Severity  severity,
const QString &  action,
const QHash< QString, QString > &  args 
)
private
void TorEvents::handleEvent ( const ControlReply reply)

Parses an event message and emits the proper signal

Handles an event message from Tor. An event message can potentially have more than one line, so we will iterate through them all and dispatch the necessary events.

Definition at line 124 of file TorEvents.cpp.

References Bandwidth, CircuitStatus, ClientStatus, GeneralStatus, ControlReply::getLines(), handleAddressMap(), handleBandwidthUpdate(), handleCircuitStatus(), handleLogMessage(), handleNewDescriptor(), handleStatusEvent(), handleStreamStatus(), LogDebug, LogError, LogInfo, LogNotice, LogWarn, NewDescriptor, parseEventType(), ServerStatus, and StreamStatus.

Referenced by ControlConnection::onReadyRead().

void TorEvents::handleGeneralStatusEvent ( tc::Severity  severity,
const QString &  action,
const QHash< QString, QString > &  args 
)
private

Parses and posts a general Tor status event.

Parses and emits a general Tor status event.

Definition at line 321 of file TorEvents.cpp.

References bug(), clockSkewed(), dangerousTorVersion(), tc::NewTorVersion, tc::ObsoleteTorVersion, and tc::UnrecommendedTorVersion.

Referenced by handleStatusEvent().

void TorEvents::handleLogMessage ( const ReplyLine line)
private

Handle a log message event

Handle a log message event. The format of this message is: The syntax is:

"650" SP Severity SP ReplyText or "650+" Severity CRLF Data Severity = "DEBUG" / "INFO" / "NOTICE" / "WARN"/ "ERR"

Definition at line 233 of file TorEvents.cpp.

References ReplyLine::getData(), ReplyLine::getMessage(), i(), logMessage(), and tc::severityFromString().

Referenced by handleEvent().

void TorEvents::handleNewDescriptor ( const ReplyLine line)
private

Handles a new list of descriptors event.

Handles a new descriptor event. The format for event messages of this type is:

"650" SP "NEWDESC" 1*(SP ServerID)

Definition at line 250 of file TorEvents.cpp.

References ReplyLine::getMessage(), and newDescriptors().

Referenced by handleEvent().

void TorEvents::handleOrConnStatus ( const ReplyLine line)
private

Handle an OR connection status event.

void TorEvents::handleServerStatusEvent ( tc::Severity  severity,
const QString &  action,
const QHash< QString, QString > &  args 
)
private
void TorEvents::handleStatusEvent ( Event  e,
const ReplyLine line 
)
private

Handles a Tor status event.

Handles a Tor status event. The format for event messages of this type is:

"650" SP StatusType SP StatusSeverity SP StatusAction [SP StatusArguments] CRLF

StatusType = "STATUS_GENERAL" / "STATUS_CLIENT" / "STATUS_SERVER" StatusSeverity = "NOTICE" / "WARN" / "ERR" StatusAction = 1*ALPHA StatusArguments = StatusArgument *(SP StatusArgument) StatusArgument = StatusKeyword '=' StatusValue StatusKeyword = 1*(ALNUM / "_") StatusValue = 1*(ALNUM / '_') / QuotedString

Definition at line 291 of file TorEvents.cpp.

References ClientStatus, GeneralStatus, ReplyLine::getMessage(), handleClientStatusEvent(), handleGeneralStatusEvent(), handleServerStatusEvent(), ServerStatus, tc::severityFromString(), and string_parse_keyvals().

Referenced by handleEvent().

void TorEvents::handleStreamStatus ( const ReplyLine line)
private

Handle a stream status event

Handle a stream status event. The format of this message is:

"650" SP "STREAM" SP StreamID SP StreamStatus SP CircID SP Target SP StreamStatus = "NEW" / ; New request to connect "NEWRESOLVE" / ; New request to resolve an address "SENTCONNECT" / ; Sent a connect cell along a circuit "SENTRESOLVE" / ; Sent a resolve cell along a circuit "SUCCEEDED" / ; Received a reply; stream established "FAILED" / ; Stream failed and not retriable. "CLOSED" / ; Stream closed "DETACHED" ; Detached from circuit; still retriable. Target = Address ":" Port

If the circuit ID is 0, then the stream is unattached.

Definition at line 213 of file TorEvents.cpp.

References Stream::fromString(), ReplyLine::getMessage(), i(), Stream::isValid(), and streamStatusChanged().

Referenced by handleEvent().

void TorEvents::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 handleLogMessage().

void TorEvents::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 handleNewDescriptor().

void TorEvents::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 handleServerStatusEvent().

TorEvents::Event TorEvents::parseEventType ( const ReplyLine line)
staticprivate

Parses the event type from the event message

Parse the event type out of a message line and return the corresponding Event enum value

Definition at line 113 of file TorEvents.cpp.

References ReplyLine::getMessage(), i(), and toTorEvent().

Referenced by handleEvent().

TorEvents::Q_DECLARE_FLAGS ( Events  ,
Event   
)
void TorEvents::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 TorEvents::serverDescriptorAccepted ( )
signal

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

Referenced by handleServerStatusEvent().

void TorEvents::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 handleServerStatusEvent().

void TorEvents::socksError ( tc::SocksError  error,
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 handleClientStatusEvent().

QPair< QHostAddress, quint16 > TorEvents::splitAddress ( const QString &  address)
staticprivate

Splits a string in the form "IP:PORT" into a QHostAddress and quint16 pair. If either portion is invalid, a default-constructed QPair() is returned.

Definition at line 443 of file TorEvents.cpp.

Referenced by handleServerStatusEvent().

void TorEvents::streamStatusChanged ( const Stream stream)
signal

Emitted when the stream status of stream has changed.

Referenced by handleStreamStatus().

QString TorEvents::toString ( TorEvents::Event  e)
static

Converts an Event to a string

Converts an event type to a string Tor understands

Definition at line 51 of file TorEvents.cpp.

References Bandwidth, CircuitStatus, ClientStatus, GeneralStatus, LogDebug, LogError, LogInfo, LogNotice, LogWarn, NewDescriptor, ServerStatus, and StreamStatus.

Referenced by TorControl::setEvents().

TorEvents::Event TorEvents::toTorEvent ( const QString &  event)
staticprivate

Converts a string to an Event

Converts an event in the string form sent by Tor to its enum value

Definition at line 75 of file TorEvents.cpp.

References AddressMap, Bandwidth, CircuitStatus, ClientStatus, GeneralStatus, LogDebug, LogError, LogInfo, LogNotice, LogWarn, NewDescriptor, ServerStatus, StreamStatus, and Unknown.

Referenced by parseEventType().

Member Data Documentation

const Event TorEvents::EVENT_MAX = TorEvents::ServerStatus
static

Definition at line 61 of file TorEvents.h.

Referenced by TorControl::setEvents().

const Event TorEvents::EVENT_MIN = TorEvents::Bandwidth
static

Definition at line 60 of file TorEvents.h.

Referenced by TorControl::setEvents().


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