onbasca.onbasca package

Subpackages

Submodules

onbasca.onbasca.apps module

class onbasca.onbasca.apps.OnBaScaConfig(app_name, app_module)[source]

Bases: AppConfig

default_auto_field = 'django.db.models.BigAutoField'
name = 'onbasca.onbasca'

onbasca.onbasca.constants module

onbasca.onbasca.defaults module

onbasca.onbasca.http_session module

class onbasca.onbasca.http_session.TimedSession(socks_address, timeout=10, verify=False, **kwargs)[source]

Bases: Session

Requests Session that sends timeout in the head and get methods.

get(url, **kwargs)[source]

Sends a GET request. Returns Response object.

Parameters:
  • url – URL for the new Request object.

  • **kwargs – Optional arguments that request takes.

Return type:

requests.Response

head(url, **kwargs)[source]

Sends a HEAD request. Returns Response object.

Parameters:
  • url – URL for the new Request object.

  • **kwargs – Optional arguments that request takes.

Return type:

requests.Response

onbasca.onbasca.torcontrol module

class onbasca.onbasca.torcontrol.TorControl(tor_config=None, controller=None)[source]

Bases: object

attach_stream_to_circuit(circuit_id, stream_event)[source]
fetch_http_head(circuit_id, session, url)[source]
get_socks_address()[source]
handle_new_consensus_event(event)[source]

dict_keys([‘arrived_at’, ‘_parsed_content’, ‘_raw_content’, ‘_str’, ‘_hash’, ‘type’, ‘positional_args’, ‘keyword_args’, ‘consensus_content’, ‘desc’])

handle_new_descriptor_event(event)[source]
launch_or_connect_tor(port=None, socket=None, pw=None, tor_config={'ControlSocket': '/home/docs/.onbasca/tor/control', 'CookieAuthentication': '1', 'DataDirectory': '/home/docs/.onbasca/tor', 'FetchDirInfoEarly': '1', 'FetchDirInfoExtraEarly': '1', 'FetchUselessDescriptors': '1', 'LearnCircuitBuildTimeout': '0', 'Log': ['NOTICE file /home/docs/.onbasca/tor/notices.log'], 'PidFile': '/home/docs/.onbasca/tor/pid', 'SocksPort': 'auto', 'UseMicrodescriptors': '0'})[source]
measure_bw(circuit_id, session, url, bytes_range, size=16384)[source]
measure_relay(relay, session_kwargs, socks_address)[source]

https://gitlab.torproject.org/tpo/network-health/sbws/-/issues/40048: It’s being stored in which position a relay is being measured and whether it is an exit.

https://gitlab.torproject.org/tpo/network-health/sbws/-/issues/40027: Building circuits just use stem’s API, not any special class.

obtain_consensus(path=None)[source]
obtain_consensus_params()[source]

Obtain current consensus params fields and store them as an attr.

It is not possible to obtain them from get_network_statuses via control port, only via a cached file.

obtain_latest_relays(latest_consensus)[source]
obtain_relays()[source]
obtain_tor_controller(port=None, socket=None, pw=None)[source]
set_config(tor_config_dict)[source]

Set torrc options at runtime.

set_config_can_fail(tor_config_dict)[source]

onbasca.onbasca.util module

onbasca.onbasca.util.bytes_range_from_head(head=None, content_length=1073741824, size=16384)[source]

Returns a random range of bytes of length size taking either the head content-length header or content_length argument into account.

For example, for content_length of 100 and size 10, this function will return one of the following: ‘0-9’, ‘1-10’, ‘2-11’, […] ‘89-98’, ‘90-99’

onbasca.onbasca.util.modify_logging(config, scan=True, generate=False, log_level=None)[source]
onbasca.onbasca.util.validate_recent_log(key1, value1, key2, value2)[source]