| | |
- AddrMapEvent
- BWEvent
- CircuitEvent
- Connection
- EventHandler
-
- DebugEventHandler
- ExitPolicyLine
- LogEvent
- NetworkStatus
- NetworkStatusEvent
- NewDescEvent
- ORConnEvent
- Router
- RouterVersion
- StreamBwEvent
- StreamEvent
- UnknownEvent
- exceptions.Exception(exceptions.BaseException)
-
- TorCtlError
-
- ErrorReply
- ProtocolError
- TorCtlClosed
class Connection |
| |
A Connection represents a connection to the Tor process via the
control port. |
| |
Methods defined here:
- __init__(self, sock)
- Create a Connection to communicate with the Tor process over the
socket 'sock'.
- attach_stream(self, streamid, circid, hop=None)
- Attach a stream to a circuit, specify both by IDs. If hop is given,
try to use the specified hop in the circuit as the exit node for
this stream.
- authenticate(self, secret='')
- Send an authenticating secret to Tor. You'll need to call this
method before Tor can start.
- close(self)
- Shut down this controller connection
- close_circuit(self, circid, reason=0, flags=())
- DOCDOC
- close_stream(self, streamid, reason=0, flags=())
- DOCDOC
- debug(self, f)
- DOCDOC
- extend_circuit(self, circid, hops)
- Tell Tor to extend the circuit identified by 'circid' through the
servers named in the list 'hops'.
- get_info(self, name)
- Return the value of the internal information field named 'name'.
Refer to section 3.9 of control-spec.txt for a list of valid names.
DOCDOC
- get_network_status(self, who='all')
- Get the entire network status list. Returns a list of
TorCtl.NetworkStatus instances.
- get_option(self, name)
- Get the value of the configuration option named 'name'. To
retrieve multiple values, pass a list for 'name' instead of
a string. Returns a list of (key,value) pairs.
Refer to section 3.3 of control-spec.txt for a list of valid names.
- get_router(self, ns)
- Fill in a Router class corresponding to a given NS class
- launch_thread(self, daemon=1)
- Launch a background thread to handle messages from the Tor process.
- map_address(self, kvList)
- Sends the MAPADDRESS command for each of the tuples in kvList
- post_descriptor(self, desc)
- read_routers(self, nslist)
- Given a list a NetworkStatuses in 'nslist', this function will
return a list of new Router instances.
- redirect_stream(self, streamid, newaddr, newport='')
- DOCDOC
- reset_options(self, keylist)
- Reset the options listed in 'keylist' to their default values.
Tor started implementing this command in version 0.1.1.7-alpha;
previous versions wanted you to set configuration keys to "".
That no longer works.
- resolve(self, host)
- Launch a remote hostname lookup request:
'host' may be a hostname or IPv4 address
- save_conf(self)
- Flush all configuration changes to disk.
- sendAndRecv(self, msg='', expectedTypes=('250', '251'))
- Helper: Send a command 'msg' to Tor, and wait for a command
in response. If the response type is in expectedTypes,
return a list of (tp,body,extra) tuples. If it is an
error, raise ErrorReply. Otherwise, raise ProtocolError.
- send_signal(self, sig)
- Send the signal 'sig' to the Tor process; The allowed values for
'sig' are listed in section 3.6 of control-spec.
- set_close_handler(self, handler)
- Call 'handler' when the Tor process has closed its connection or
given us an exception. If we close normally, no arguments are
provided; otherwise, it will be called with an exception as its
argument.
- set_event_handler(self, handler)
- Cause future events from the Tor process to be sent to 'handler'.
- set_events(self, events, extended=False)
- Change the list of events that the event handler is interested
in to those in 'events', which is a list of event names.
Recognized event names are listed in section 3.3 of the control-spec
- set_option(self, key, value)
- Set the value of the configuration option 'key' to the value 'value'.
- set_options(self, kvlist)
- Given a list of (key,value) pairs, set them as configuration
options.
|
class DebugEventHandler(EventHandler) |
| |
Trivial debug event handler: reassembles all parsed events to stdout. |
| |
Methods defined here:
- bandwidth_event(self, bw_event)
- circ_status_event(self, circ_event)
- msg_event(self, log_event)
- new_desc_event(self, newdesc_event)
- ns_event(self, ns_event)
- or_conn_status_event(self, orconn_event)
- stream_status_event(self, strm_event)
Methods inherited from EventHandler:
- __init__(self)
- Create a new EventHandler.
- address_mapped_event(self, event)
- Called when Tor adds a mapping for an address if listening
to ADDRESSMAPPED events.
- heartbeat_event(self, event)
- Called before any event is recieved. Convenience function
for any cleanup/setup/reconfiguration you may need to do.
- stream_bw_event(self, event)
- unknown_event(self, event)
- Called when we get an event type we don't recognize. This
is almost alwyas an error.
|
class EventHandler |
| |
An 'EventHandler' wraps callbacks for the events Tor can return.
Each event argument is an instance of the corresponding event
class. |
| |
Methods defined here:
- __init__(self)
- Create a new EventHandler.
- address_mapped_event(self, event)
- Called when Tor adds a mapping for an address if listening
to ADDRESSMAPPED events.
- bandwidth_event(self, event)
- Called once a second if listening to BANDWIDTH events.
- circ_status_event(self, event)
- Called when a circuit status changes if listening to CIRCSTATUS
events.
- heartbeat_event(self, event)
- Called before any event is recieved. Convenience function
for any cleanup/setup/reconfiguration you may need to do.
- msg_event(self, event)
- Called when a log message of a given severity arrives if listening
to INFO_MSG, NOTICE_MSG, WARN_MSG, or ERR_MSG events.
- new_desc_event(self, event)
- Called when Tor learns a new server descriptor if listenting to
NEWDESC events.
- ns_event(self, event)
- or_conn_status_event(self, event)
- Called when an OR connection's status changes if listening to
ORCONNSTATUS events.
- stream_bw_event(self, event)
- stream_status_event(self, event)
- Called when a stream status changes if listening to STREAMSTATUS
events.
- unknown_event(self, event)
- Called when we get an event type we don't recognize. This
is almost alwyas an error.
|
class ExitPolicyLine |
| |
Class to represent a line in a Router's exit policy in a way
that can be easily checked. |
| |
Methods defined here:
- __init__(self, match, ip_mask, port_low, port_high)
- check(self, ip, port)
- Check to see if an ip and port is matched by this line.
Returns true if the line is an Accept, and False if it is a Reject.
|
class NetworkStatus |
| |
Filled in during NS events |
| |
Methods defined here:
- __init__(self, nickname, idhash, orhash, updated, ip, orport, dirport, flags)
|
class ORConnEvent |
| | |
Methods defined here:
- __init__(self, event_name, status, endpoint, age, read_bytes, wrote_bytes, reason, ncircs)
|
class Router |
| |
Class to represent a router from a descriptor. Can either be
created from the parsed fields, or can be built from a
descriptor+NetworkStatus |
| |
Methods defined here:
- __init__(self, idhex, name, bw, down, exitpolicy, flags, ip, version, os, uptime)
- __str__(self)
- update_to(self, new)
- Somewhat hackish method to update this router to be a copy of
'new'
- will_exit_to(self, ip, port)
- Check the entire exitpolicy to see if the router will allow
connections to 'ip':'port'
Data and other attributes defined here:
- build_from_desc = <TorCtl.TorUtil.Callable instance at 0xb7c561ac>
|
class StreamEvent |
| | |
Methods defined here:
- __init__(self, event_name, strm_id, status, circ_id, target_host, target_port, reason, remote_reason, source, source_addr, purpose)
|
|