Tor 的茎模块 (python) 加载但不卸载配置 [英] Tor's stem module (python) loading but not unloading config

查看:37
本文介绍了Tor 的茎模块 (python) 加载但不卸载配置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以在 Tor 的 Python 模块 Stem 中,我可以添加隐藏服务、替换隐藏服务等.但是!我无法删除所有隐藏的服务.我不知道这样做的魔力……我试过将 'HiddenServiceDir/HiddenServicePort' 和 'HiddenServiceOptions' 设置为空字符串、空列表和 None.唯一能做任何事情的是将 'HiddenServiceOptions' 设置为 None ......这只是带回了最后一次成功的隐藏服务设置......意味着这之间的一切可能只是一个铺位设置,我神奇地从 Tor 控件中翻转了一个重置...

例如,这里我从一个隐藏的服务开始,然后再用一两个替换它......

<预><代码>>>>controller.is_authenticated()真的>>>controller.get_conf_map('HiddenServiceOptions'){'HiddenServiceDir': ['/tmp/hiddenservice1/'],'隐藏服务端口':['1234 127.0.0.1:1234']}>>>controller.set_options([('HiddenServiceDir','/tmp/hiddenservice2/'),('HiddenServicePort','1235 127.0.0.1:1235'),('HiddenServiceDir','/tmp/hiddenservice3/'),('HiddenServicePort','1236 127.0.0.1:1236')])>>>controller.get_conf_map('HiddenServiceOptions'){'HiddenServiceDir': ['/tmp/hiddenservice2/', '/tmp/hiddenservice3/'],'HiddenServicePort': ['1235 127.0.0.1:1235', '1236 127.0.0.1:1236']}>>>controller.set_options([('HiddenServiceDir','/tmp/hiddenservice3/'),('HiddenServicePort','1236 127.0.0.1:1236')])>>>controller.get_conf_map('HiddenServiceOptions'){'HiddenServiceDir': ['/tmp/hiddenservice3/'],'隐藏服务端口':['1236 127.0.0.1:1236']}

...现在的乐趣...我试图摆脱所有隐藏的服务...

<预><代码>>>>controller.set_options([('HiddenServiceDir',None),('HiddenServicePort',None)])### *或者*>>>controller.set_options([('HiddenServiceDir',''),('HiddenServicePort','')])### .... 结果是....>>>controller.get_conf_map('HiddenServiceOptions'){'HiddenServiceOptions':[]}### ...没有,正如预期的那样......但是......>>>controller.set_options([('HiddenServiceDir','/tmp/hiddenservice3/'),('HiddenServicePort','1236 127.0.0.1:1236')])>>>controller.get_conf_map('HiddenServiceOptions'){'HiddenServiceOptions':[]}### ...隐藏的服务不再显示...直到...>>>controller.set_options([('HiddenServiceOptions',None)])>>>controller.get_conf_map('HiddenServiceOptions'){'HiddenServiceDir': ['/tmp/hiddenservice3/'],'隐藏服务端口':['1236 127.0.0.1:1236']}### ......惊喜!回来了!

不过,有趣的是...通过以其他方式检查我的 TOR 连接,我可以看出我的服务从未被全部删除.他们只是停留在我设置的最后一个隐藏服务......

...所以我可以继续旋转我的轮子或在源代码中搜索瓦尔哈拉...或者也许一些开明的灵魂可以告诉我...我如何摆脱我在词干中隐藏的服务?!

更新

问题似乎是HiddenServiceOptions"如何自我更新的错误.

启用隐藏服务后,当我将 HiddenServiceDir 和 HiddenServicePort 都设置为 None(或设置为空字符串;两者都具有完全相同的效果)时,它会显示在我的 conf_map 中,并且我看到发送了一个 conf 事件(从侦听器我的控制器)与配置 {'HiddenServiceOptions':None} (或作为 parsed_content,只是 'HiddenServiceOptions' 没有等号或任何东西).这符合预期.

...现在,如果我设置另一个隐藏服务,我会收到一个新的配置事件,显示正确的隐藏服务信息.此时,隐藏服务有效,但如果我用get_conf_map"询问它,它仍然不会显示.

然后我运行 reset_conf,它再次显示正常.

要点:如果您设置了新服务,请先检查是否没有.如果是,设置隐藏服务,然后运行reset_conf...

或者对于只依赖 event_listeners 的人来说,这根本不会影响他们......

谢谢,达米安...

解决方案

这当然很奇怪.我希望 set_options() 的行为符合您的预期,但 Tor 的 HiddenServiceOptions 肯定是非常规的,所以如果这里有错误,我不会感到惊讶.如果您确定了此问题的根本原因,请让我们知道

出于好奇,发出 RESETCONF 而不是 SETCONF 能解决问题吗?你可以通过...来做到这一点

<预><代码>>>>controller.reset_conf('HiddenServiceOptions')

So in Tor's python module, Stem, I can add hidden services, replace hidden services, etc. However! I cannot remove ALL hidden services. I do not know the magic magicness that does this... I've tried setting 'HiddenServiceDir/HiddenServicePort' and 'HiddenServiceOptions' to empty strings, empty lists and None. The only thing that does anything is setting 'HiddenServiceOptions' to None... which just brings back the last successful hidden service setting.... meaning that probably everything in between was just a bunk setting and I magically flipped a reset from tor control...

For example, here I start with a hidden service, then replace it with one or two more...

>>> controller.is_authenticated()
True

>>> controller.get_conf_map('HiddenServiceOptions')
{'HiddenServiceDir': ['/tmp/hiddenservice1/'],
 'HiddenServicePort': ['1234 127.0.0.1:1234']}

>>> controller.set_options([('HiddenServiceDir','/tmp/hiddenservice2/'),('HiddenServicePort','1235 127.0.0.1:1235'),('HiddenServiceDir','/tmp/hiddenservice3/'),('HiddenServicePort','1236 127.0.0.1:1236')])

>>> controller.get_conf_map('HiddenServiceOptions')
{'HiddenServiceDir': ['/tmp/hiddenservice2/', '/tmp/hiddenservice3/'],
 'HiddenServicePort': ['1235 127.0.0.1:1235', '1236 127.0.0.1:1236']}

>>> controller.set_options([('HiddenServiceDir','/tmp/hiddenservice3/'),('HiddenServicePort','1236 127.0.0.1:1236')])

>>> controller.get_conf_map('HiddenServiceOptions')
{'HiddenServiceDir': ['/tmp/hiddenservice3/'],
 'HiddenServicePort': ['1236 127.0.0.1:1236']}

...and now the fun... I try to get rid of ALL hidden services...

>>> controller.set_options([('HiddenServiceDir',None),('HiddenServicePort',None)])
### *OR*
>>> controller.set_options([('HiddenServiceDir',''),('HiddenServicePort','')])

### .... and the result is....
>>> controller.get_conf_map('HiddenServiceOptions')
{'HiddenServiceOptions': []}
### ... nothing, as expected... but then...

>>> controller.set_options([('HiddenServiceDir','/tmp/hiddenservice3/'),('HiddenServicePort','1236 127.0.0.1:1236')])
>>> controller.get_conf_map('HiddenServiceOptions')
{'HiddenServiceOptions': []}
### ... hidden service not showing again... until...

>>> controller.set_options([('HiddenServiceOptions',None)])
>>> controller.get_conf_map('HiddenServiceOptions')
{'HiddenServiceDir': ['/tmp/hiddenservice3/'],
 'HiddenServicePort': ['1236 127.0.0.1:1236']}
### ... suprise! It's back!

Funny thing, though... From checking my TOR connection in other ways, I can tell that my services were never all removed. They just stayed at whatever the last hidden service(s) I set...

... so I could keep spinning my wheels or search for valhalla in the source code... or maybe some enlightened soul can inform me... how do I get rid of my hidden services in stem?!

UPDATE

The problem seems to be a bug in how "HiddenServiceOptions" updates itself.

With a hidden service enabled, when I set both HiddenServiceDir and HiddenServicePort to None (or to empty strings; both have the exact same effect), it shows in my conf_map and I see a conf event sent out (from a listener on my controller) with configuration {'HiddenServiceOptions':None} (or as parsed_content, just 'HiddenServiceOptions' with no equal sign or anything). This is as expected.

...NOW, if I set another hidden service, I get a new configuration event sent to me showing the correct hidden service info. At this point, the hidden service WORKS, BUT it still won't show if I ask it with "get_conf_map".

Then I run reset_conf and it shows fine again.

The takeaway: if you setup a new service, first check if there are none. If so, set the hidden service, then run reset_conf...

Or for people who only rely on event_listeners, this doesn't affect them at all...

Thanks, Damian...

解决方案

That's certainly odd. I'd expect set_options() to behave the way you expect but tor's HiddenServiceOptions is certainly unconventional so I wouldn't be surprised if there's a bug here. If you determine the root cause of this then please let us know!

Out of curiosity, does issuing a RESETCONF rather than SETCONF do the trick? You can do this via...

>>> controller.reset_conf('HiddenServiceOptions')

这篇关于Tor 的茎模块 (python) 加载但不卸载配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆