0

I'm running a Tor relay on Linux which has the HSDir flag, meaning that it can host hidden service descriptors. I've been wondering, just out of curiosity whether it is possible to get some info about the queries received by the HS directory from Tor clients, for example the number of requests for each hidden service descriptor. I tried to do that in Python using the Stem library but I couldn't find anything helpful in the Stem documentation.

Does anyone have any idea how to do that?

  • I think stem do not support this feature,it only support some operation about current relay status as far as i am concerned . – yin.shuai Dec 20 '16 at 2:09
  • What the exact task you want to solve? I think I can help you with this, because directly there's no such stats, but some workarounds are possible – Alexey Vesnin Dec 20 '16 at 7:30
1

There is a tutorial on retrieving the number of bytes a relay has written and read here (run the code after installing stem):

from stem.control import Controller

with Controller.from_port(port = 9051) as controller:
  controller.authenticate()  # provide the password here if you set one

  bytes_read = controller.get_info("traffic/read")
  bytes_written = controller.get_info("traffic/written")

  print("My Tor relay has read %s bytes and written %s." % (bytes_read, bytes_written))

The control password is stored the torrc file. For example:

# This provides a port for our script to talk with. If you set this then be
# sure to also set either CookieAuthentication *or* HashedControlPassword!
#
# You could also use ControlSocket instead of ControlPort, which provides a
# file based socket. You don't need to have authentication if you use
# ControlSocket. For this example however we'll use a port.

ControlPort 9051

# Setting this will make Tor write an authentication cookie. Anything with
# permission to read this file can connect to Tor. If you're going to run
# your script with the same user or permission group as Tor then this is the
# easiest method of authentication to use.

CookieAuthentication 1

# Alternatively 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

A tutorial on how to configure hidden services using stem can be found here.You can use arm to retrieve all statistics.

  • 1
    Sorry but it doesn't answer my question. Maybe I wasn't clear enough. My question is: How to count the number of HS descriptor requests sent to my relay? – Ashley Dec 27 '15 at 21:57
  • @Ashley. Have you tried using arm? – Sebi Dec 28 '15 at 12:30
  • I just had a look at arm and it doesn't provide any information about the HSDir, or maybe I didn't find it. – Ashley Dec 28 '15 at 21:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.