Tor's stem module (python) loading but not unloading config

wayzard

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...

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')

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

stem not recognizing tor's path

From Dev

TOR with python stem (basic) - 'tor' not in PATH

From Dev

stem - can't get new ip with python via tor

From Dev

stem - can't get new ip with python via tor

From Dev

Unloading a module in Python 3.x

From Dev

Unloading a module in Python 3.x

From Dev

Selenium WebDriver + Tor as proxy with Stem?

From Dev

Javascript Controller Loading/unloading

From Dev

safe unloading of kernel module

From Dev

GWT Module is unloading randomly

From Dev

Tor Stem - To Russia With Love Connection Issues

From Dev

Authenticating a Controller with a Tor subprocess using Stem

From Dev

Loading/unloading external JS dynamically

From Dev

Static methods loading/unloading and memory area in java?

From Dev

setCenter position resetting when loading/unloading subviews

From Dev

Loading and unloading ISO files in Windows 8

From Dev

Dynamic Streaming, Loading, Unloading and Sharing of Game Assets

From Dev

How read the bandwidth limit parameter from Tor with Stem

From Dev

Unexpected behavior with loading a module in Python

From Dev

Linux kernel module hangs during unloading

From Dev

Loading DLL's in Python

From Dev

python plot stem with datetime base

From Dev

Unloading from redshift to s3 with headers

From Dev

Python Ghost module not loading page properly

From Dev

Python ImportError loading module within subfolder

From Dev

Python Ghost module not loading page properly

From Dev

AttributeError when loading pptx module in Python

From Dev

Assemblies in SQL Server keep unloading and loading again periodically

From Dev

Python `logging` module + YAML config file