[tor-talk] Get relay information from the "Network Status Consensuses" file?

Matthew Finkel matthew.finkel at gmail.com
Sun Nov 25 16:07:21 UTC 2018


On Sun, Nov 25, 2018 at 03:57:34PM +0800, Lucon Yang wrote:
> The "Network Status Consensuses" file contains some relay information I
> need. Now I have a relay's fingerprint, but I did't find a fingerprint
> field in this file.
> How can I get a relay's information from the file by the relay's
> fingerprint?

You'll probably be interested in reading the official consensus document
specification [0].

The short answer is: if you have the relay's fingerprint encoded in
base16 (hex), then you'll need to convert it to base64. The result is on
the r-line in the field next to the relay's name. The section from
the specification says:

   "Identity" is a hash of its identity key, encoded in base64, with
   trailing equals sign(s) removed."

I usually use python for this, because it's relatively easy, but there
may be an even easier methods.

If I want to look at maatuska [1] and I know it's fingerprint encoded in hex
is BD6A829255CB08E66FBE7D3748363586E46B3810, then I convert the encoding
into base64 with:

""""""""""""
$ python
Python 2.7.15 (default, May  9 2018, 11:32:33) 
[GCC 7.3.1 20180130 (Red Hat 7.3.1-2)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import binascii
>>> binascii.b2a_base64(binascii.a2b_hex('BD6A829255CB08E66FBE7D3748363586E46B3810'))
'vWqCklXLCOZvvn03SDY1huRrOBA=\n'
""""""""""""

This takes the hex string and converts it into binary, and then takes
the binary and converts it into base64. You'll want the result not
including any '=' and new line at the end - vWqCklXLCOZvvn03SDY1huRrOBA.

So, looking at the current consensus:

$ torsocks wget https://collector.torproject.org/recent/relay-descriptors/consensuses/2018-11-25-15-00-00-consensus

We can see Maatuska has this r-line:

   r maatuska vWqCklXLCOZvvn03SDY1huRrOBA 8Ws9cPzBQWrlqtTZJWKFEixvz1Y 2018-11-25 09:42:37 171.25.193.9 80 443


Hope this helps,


[0] https://gitweb.torproject.org/torspec.git/tree/dir-spec.txt#n2258
[1]
https://metrics.torproject.org/rs.html#details/BD6A829255CB08E66FBE7D3748363586E46B3810


More information about the tor-talk mailing list