python - 如何在 linux 上通过 python + stem 获取 Tor 中继信息?

标签 python linux tor

我正在尝试按照 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/

相关文章:

python - 了解 Django 中的 View 评估

python - 如何在 Windows 上配置 Tor 代理?

tor - 关于Tor继电器,ORPort和DirPort有什么区别?

python - 将原始日期格式转换为 Pandas 日期对象

python - Django 部署 https + gunicorn 和 nginx

linux - 指定符号放置的绝对地址

java - Maven 连接问题

c++ - 让可执行文件在多个 Linux 操作系统的 : 上运行

TOR上的Python urllib?

python - 如何将 [2,3,4] 转换为 [0,0,1,1,1,2,2,2,2] 以利用 tf.math.segment_sum?