我正在尝试按照 tor 的 website 上的指示使用 python 的 stem 库在 ubuntu linux 上控制 tor .但是,当我运行建议的 python 代码时
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)
我得到错误:
Traceback (most recent call last):
File "littleRelay.py", line 5, in module
bytes_read = controller.get_info("traffic/read")
File "/usr/local/lib/python2.7/dist-packages/stem/control.py", line 852, in get_info
raise exc
stem.InvalidArguments: GETINFO request contained unrecognized keywords: traffic/read
那么如何在 linux 上通过 python+stem 获取 Tor 中继信息呢? 我认为 Tor 运行良好,因为我从终端启动了 tor,它说
[notice] Tor has successfully opened a circuit. Looks like client functionality is working.
[notice] Bootstrapped 100%: Done.
此外,当我运行上面的 python 代码时,终端显示
[notice] New control connection opened.
附言我还在 Windows PC 上尝试过代码并且它有效。我现在真的很困惑。
最佳答案
该错误表明 Tor 不支持“GETINFO traffic/read”查询。这很奇怪 - 这是我在 2011 年添加到 Tor 的功能。也许您的 Tor 副本已经非常非常过时了?
关于python - 如何在 linux 上通过 python + stem 获取 Tor 中继信息?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22746974/