utils.tor package

utils.tor.tools module

utils.tor.tools.init_tor(socks_port=None, control_port=None)

Initiates a tor connection.

Parameters:
  • socks_port (int) – local port socket where tor will listen to requests (configurable in tor.rc).
  • control_port (int) – local port where tor will listen to control requests (configurable in tor.rc).
Returns:

a tor process and a controller of the process.

Return type:

process, controller

utils.tor.tools.print_bootstrap_lines(line)

Print the bootstrap lines.

Parameters:line (str) – line to be printed.
Returns:None.
utils.tor.tools.tor_query(url, method='GET', data=None, headers=None, socks_port=None)

Performs a http query using tor.

Parameters:
  • url (str) – server address.
  • method (str) – request method (GET, POST, ...).
  • data – data to be sent to the server.
  • data – JSON dumped object
  • headers (str array) – headers of the request.
  • socks_port (int) – local socket port where tor is listening to requests (configurable in tor.rc).
Returns:

response code and some server response data.

Return type:

str, str