#include <torevents.h>
Definition at line 46 of file torevents.h.
enum TorEvents::TorEvent |
Asynchronous events sent from Tor to the controller
Unknown | |
Bandwidth | |
LogDebug | |
LogInfo | |
LogNotice | |
LogWarn | |
LogError | |
CircuitStatus | |
StreamStatus | |
OrConnStatus | |
NewDescriptor | |
AddressMap |
Definition at line 52 of file torevents.h.
TorEvents::TorEvents | ( | ) |
void TorEvents::add | ( | TorEvent | e, | |
QObject * | obj | |||
) |
Adds an event and interested object to the event list
Adds an event and interested object to the list
Definition at line 47 of file torevents.cpp.
References _eventList.
Referenced by TorControl::setEvent().
void TorEvents::remove | ( | TorEvent | e, | |
QObject * | obj | |||
) |
Removes obj from the list of target objects for event e.
Removes obj from the list of target objects for event e.
Definition at line 56 of file torevents.cpp.
References _eventList, and i().
Referenced by TorControl::setEvent().
bool TorEvents::contains | ( | TorEvent | event | ) |
Returns true if an event has any registered handlers
Definition at line 70 of file torevents.cpp.
References _eventList.
QList< TorEvents::TorEvent > TorEvents::eventList | ( | ) |
Returns the list of events in which we're interested
Definition at line 80 of file torevents.cpp.
References _eventList.
Referenced by TorControl::setEvents().
void TorEvents::handleEvent | ( | 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 180 of file torevents.cpp.
References Bandwidth, CircuitStatus, ControlReply::getLines(), handleAddressMap(), handleBandwidthUpdate(), handleCircuitStatus(), handleLogMessage(), handleNewDescriptor(), handleOrConnStatus(), handleStreamStatus(), LogDebug, LogError, LogInfo, LogNotice, LogWarn, NewDescriptor, OrConnStatus, parseEventType(), and StreamStatus.
Referenced by ControlConnection::onReadyRead().
void TorEvents::dispatch | ( | TorEvent | e, | |
QEvent * | event | |||
) |
Dispatches a given event to all its handler targets.
Definition at line 87 of file torevents.cpp.
References _eventList.
Referenced by handleAddressMap(), handleBandwidthUpdate(), handleCircuitStatus(), handleLogMessage(), handleNewDescriptor(), handleOrConnStatus(), handleStreamStatus(), and TorControl::onLogStdout().
QString TorEvents::toString | ( | TorEvents::TorEvent | e | ) | [static] |
Converts an Event to a string
Converts an event type to a string Tor understands
Definition at line 96 of file torevents.cpp.
References Bandwidth, CircuitStatus, LogDebug, LogError, LogInfo, LogNotice, LogWarn, NewDescriptor, OrConnStatus, and StreamStatus.
Referenced by TorControl::setEvents().
TorEvents::TorEvent TorEvents::toTorEvent | ( | LogEvent::Severity | severity | ) | [static] |
Converts a log severity to an event
Converts a log severity to its related Tor event
Definition at line 118 of file torevents.cpp.
References LogEvent::Debug, LogEvent::Error, LogEvent::Info, LogDebug, LogError, LogInfo, LogNotice, LogWarn, LogEvent::Notice, Unknown, and LogEvent::Warn.
Referenced by handleLogMessage(), TorControl::onLogStdout(), and parseEventType().
TorEvents::TorEvent TorEvents::parseEventType | ( | ReplyLine | line | ) | [static, private] |
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 169 of file torevents.cpp.
References ReplyLine::getMessage(), i(), and toTorEvent().
Referenced by handleEvent().
TorEvents::TorEvent TorEvents::toTorEvent | ( | QString | event | ) | [static, private] |
Converts a string to an Event
Converts an event in the string form sent by Tor to its enum value
Definition at line 134 of file torevents.cpp.
References Bandwidth, CircuitStatus, LogDebug, LogError, LogInfo, LogNotice, LogWarn, NewDescriptor, OrConnStatus, StreamStatus, and Unknown.
void TorEvents::handleBandwidthUpdate | ( | 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 210 of file torevents.cpp.
References Bandwidth, CustomEventType::BandwidthEvent, dispatch(), and ReplyLine::getMessage().
Referenced by handleEvent().
void TorEvents::handleCircuitStatus | ( | 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 234 of file torevents.cpp.
References CustomEventType::CircuitEvent, CircuitStatus, dispatch(), Circuit::fromString(), ReplyLine::getMessage(), and i().
Referenced by handleEvent().
void TorEvents::handleStreamStatus | ( | 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 261 of file torevents.cpp.
References dispatch(), Stream::fromString(), ReplyLine::getMessage(), i(), CustomEventType::StreamEvent, and StreamStatus.
Referenced by handleEvent().
void TorEvents::handleLogMessage | ( | 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 280 of file torevents.cpp.
References dispatch(), ReplyLine::getData(), ReplyLine::getMessage(), i(), CustomEventType::LogEvent, LogEvent::toSeverity(), and toTorEvent().
Referenced by handleEvent().
void TorEvents::handleOrConnStatus | ( | ReplyLine | line | ) | [private] |
Handle an OR connection status event.
Handle an OR Connection Status event. The syntax is: "650" SP "ORCONN" SP (ServerID / Target) SP ORStatus
ORStatus = "NEW" / "LAUNCHED" / "CONNECTED" / "FAILED" / "CLOSED"
NEW is for incoming connections, and LAUNCHED is for outgoing connections. CONNECTED means the TLS handshake has finished (in either direction). FAILED means a connection is being closed that hasn't finished its handshake, and CLOSED is for connections that have handshaked.
A ServerID is specified unless it's a NEW connection, in which case we don't know what server it is yet, so we use Address:Port.
Definition at line 306 of file torevents.cpp.
References dispatch(), ReplyLine::getMessage(), CustomEventType::OrConnEvent, OrConnStatus, and OrConnEvent::toStatus().
Referenced by handleEvent().
void TorEvents::handleNewDescriptor | ( | 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 321 of file torevents.cpp.
References dispatch(), ReplyLine::getMessage(), NewDescriptor, and CustomEventType::NewDescriptorEvent.
Referenced by handleEvent().
void TorEvents::handleAddressMap | ( | 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 339 of file torevents.cpp.
References CustomEventType::AddressMapEvent, DATE_FMT, dispatch(), and ReplyLine::getMessage().
Referenced by handleEvent().
QMultiHash<TorEvent, QObject*> TorEvents::_eventList [private] |
Stores a mapping of Tor events to a list of the objects interested in hearing about those events.
Definition at line 91 of file torevents.h.
Referenced by add(), contains(), dispatch(), eventList(), and remove().