update
This commit is contained in:
@@ -3,28 +3,74 @@
|
||||
== stem_examples tor testing ==
|
||||
|
||||
This is a Python doctest file that is executable documentation.
|
||||
stem_examples is a set of small scripts that tell you about your
|
||||
running tor instance.
|
||||
|
||||
Pass the controller password if needed as an environment variable:
|
||||
Onionoo is a web-based protocol to learn about currently running Tor
|
||||
relays and bridges. Onionoo itself was not designed as a service for
|
||||
human beings---at least not directly. Onionoo provides the data for
|
||||
other applications and websites which in turn present Tor network
|
||||
status information to humans: https://metrics.torproject.org/onionoo.html
|
||||
|
||||
You can see the status of tor relays at https://torstatus.rueckgr.at/
|
||||
The code for that site is at https://github.com/paulchen/torstatus
|
||||
You can get a list of exit relays that are marked bad with:
|
||||
wget --post-data='SR=FBadExit&SO=Asc&FBadExit=1' 'https://torstatus.rueckgr.at/'
|
||||
|
||||
It is assumed that you are running a tor that has its torrc configured with:
|
||||
|
||||
ControlPort 127.0.0.1:9051
|
||||
|
||||
and/or
|
||||
|
||||
ControlSocket /run/tor/control
|
||||
ControlSocketsGroupWritable 1
|
||||
|
||||
We can authenticate with a password. To set a password first get its hash...
|
||||
|
||||
% tor --hash-password "my_password"
|
||||
16:E600ADC1B52C80BB6022A0E999A7734571A451EB6AE50FED489B72E3DF
|
||||
|
||||
and use that for the HashedControlPassword in your torrc.
|
||||
|
||||
HashedControlPassword 16:E600ADC1B52C80BB6022A0E999A7734571A451EB6AE50FED489B72E3DF
|
||||
|
||||
so that you have some security on the Control connection.
|
||||
Pass the controller password to these scripts as an environment variable:
|
||||
|
||||
>>> import os
|
||||
>>> assert os.environ['TOR_CONTROLLER_PASSWORD']
|
||||
|
||||
If you are using /run/tor/control you will also need to run the scripts as the user
|
||||
that has rw access to that socket, usually tor or debian-tor.
|
||||
|
||||
Add our code to the PYTHONPATH
|
||||
>>> import sys
|
||||
>>> sys.path.append(os.path.join(os.getcwd(), 'src', 'stem_examples'))
|
||||
|
||||
We'll need the settings defined in {{{/usr/local/etc/testforge/testforge.yml}}}
|
||||
We'll used the settings defined in {{{/usr/local/etc/testforge/testforge.yml}}}
|
||||
If you don't have one, make it with the settings from your torrc:
|
||||
|
||||
>>> print("yaml", file=sys.stderr)
|
||||
>>> import yaml
|
||||
>>> sFacts = open('/usr/local/etc/testforge/testforge.yml').read()
|
||||
>>> assert sFacts
|
||||
>>> dFacts = yaml.safe_load(sFacts)
|
||||
>>> try:
|
||||
... sFacts = open('/usr/local/etc/testforge/testforge.yml').read()
|
||||
... except:
|
||||
... dFacts = {
|
||||
... HTTPS_PROXYHOST: "127.0.0.1",
|
||||
... HTTPS_PROXYPORT: 9128,
|
||||
... HTTPS_PROXYTYPE: "http",
|
||||
... SOCKS_PROXYHOST: "127.0.0.1",
|
||||
... SOCKS_PROXYPORT: 9050,
|
||||
... SOCKS_PROXYTYPE: "socks5",
|
||||
... }
|
||||
... else:
|
||||
... assert sFacts
|
||||
... dFacts = yaml.safe_load(sFacts)
|
||||
|
||||
FixMe: use the settings for the ports and directories below.
|
||||
|
||||
>>> import os
|
||||
>>> os.environ['http_proxy'] = 'http://'+dFacts['HTTP_PROXYHOST']+':'+str(dFacts['HTTP_PROXYPORT'])
|
||||
>>> os.environ['https_proxy'] = 'http://'+dFacts['HTTPS_PROXYHOST']+':'+str(dFacts['HTTPS_PROXYPORT'])
|
||||
>>> os.environ['socks_proxy'] = 'socks5://'+dFacts['SOCKS_PROXYHOST']+':'+str(dFacts['SOCKS_PROXYPORT'])
|
||||
|
||||
@@ -40,16 +86,17 @@ We test 3 known hidden services: Facebook, DuckDuckGo and .
|
||||
>>> lKNOWN_ONIONS = [
|
||||
... 'facebookwkhpilnemxj7asaniu7vnjjbiltxjqhye3mhbshg7kx5tfyd', # facebook
|
||||
... 'duckduckgogg42xjoc72x3sjasowoarfbgcmvfimaftt6twagswzczad', # ddg
|
||||
... 'zkaan2xfbuxia2wpf7ofnkbz6r5zdbbvxbunvp5g2iebopbfc4iqmbad', # hks
|
||||
... ]
|
||||
|
||||
We wil expect to get back the hidden service version, the descriptor-lifetime
|
||||
and then the descriptor-signing-key-cert:
|
||||
|
||||
>>> introduction_points.iMain(lKNOWN_ONIONS) #doctest: +ELLIPSIS +NORMALIZE_WHITESPACE
|
||||
hs-descriptor 3
|
||||
0
|
||||
|
||||
hs-descriptor 3
|
||||
descriptor-lifetime ...
|
||||
<BLANKLINE>
|
||||
<BLANKLINE>
|
||||
|
||||
### exit_used Determine The Exit You're Using
|
||||
|
||||
@@ -69,11 +116,31 @@ The following provides a summary of your relay's inbound and outbound connection
|
||||
You must be root or tor to run this:
|
||||
relay_connections.iMain(["--ctrlport", "9051"])
|
||||
|
||||
## outdated_relays
|
||||
## connection_resolution Connection Resolution
|
||||
|
||||
Connection information is a useful tool for learning more about network
|
||||
applications like Tor. Our stem.util.connection.get_connections() function
|
||||
provides an easy method for accessing this information.
|
||||
|
||||
>>> print("connection_resolution", file=sys.stderr)
|
||||
>>> import connection_resolution
|
||||
>>> connection_resolution.iMain() #doctest: +ELLIPSIS +NORMALIZE_WHITESPACE
|
||||
0
|
||||
|
||||
INFO Our platform supports connection resolution via: ...
|
||||
<BLANKLINE>
|
||||
|
||||
## outdated_relays List Outdated Relays
|
||||
|
||||
Time marches on. Tor makes new releases, and at some point needs to drop
|
||||
support for old ones. Below is the script we used on ticket 9476 to reach out
|
||||
to relay operators that needed to upgrade.
|
||||
|
||||
>>> print("outdated_relays", file=sys.stderr)
|
||||
>>> import outdated_relays
|
||||
>>> outdated_relays.iMain() #doctest: +ELLIPSIS +NORMALIZE_WHITESPACE
|
||||
0
|
||||
|
||||
Checking for outdated relays ...
|
||||
<BLANKLINE>
|
||||
|
||||
@@ -85,18 +152,9 @@ relay_connections.iMain(["--ctrlport", "9051"])
|
||||
A script by adrelanos@riseup.net to check what percentage of boostrapping
|
||||
tor is at. This fails under doctest but not from the cmdline
|
||||
|
||||
>> tor_bootstrap_check.iMain() #doctest: +ELLIPSIS +NORMALIZE_WHITESPACE
|
||||
NOTICE ...
|
||||
<BLANKLINE>
|
||||
|
||||
control_port = stem.socket.ControlPort(address, port)
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
File "/usr/local/lib/python3.11/site-packages/stem/socket.py", line 503, in __init__
|
||||
self.connect()
|
||||
File "/usr/local/lib/python3.11/site-packages/stem/socket.py", line 172, in connect
|
||||
self._socket = self._make_socket()
|
||||
^^^^^^^^^^^^^^^^^^^
|
||||
File "/usr/local/lib/python3.11/site-packages/stem/socket.py", line 538, in _make_socket
|
||||
raise stem.SocketError(exc)
|
||||
stem.SocketError: Socket error: 0x01: General SOCKS server failure
|
||||
>>> tor_bootstrap_check.iMain() #doctest: +ELLIPSIS +NORMALIZE_WHITESPACE
|
||||
0
|
||||
|
||||
NOTICE ...
|
||||
<BLANKLINE>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user