如何从带有Stem的Tor读取带宽限制参数

时间:2014-10-10 19:45:13

标签: python tor

如何使用Stem读取Tor参数的带宽限制?我查看了API,无法为此类任务找到方法或GETINFO参数。

1 个答案:

答案 0 :(得分:0)

假设您的意思是您已为其配置继电器的最大带宽......

from stem.control import Controller

from stem.util.str_tools import get_size_label

with Controller.from_port() as controller:
  controller.authenticate()

  bw_rate = get_size_label(int(controller.get_conf('BandwidthRate', '0')))
  bw_burst = get_size_label(int(controller.get_conf('BandwidthBurst', '0')))
  print "you're configured to relay at most %s/s, with bursts up to %s/s" % (bw_rate, bw_burst)

...例如......

% python scrap.py 
you're configured to relay at most 1 GB/s, with bursts up to 1 GB/s

git存储库还有一个新的get_effective_rate() method,它考虑了其他配置属性。