7

I want to host multiple hidden services on the same Tor instance and have the ability to add/remove "programmaticaly" hidden services while Tor is running. As of now I would update a Torrc file and send a "RELOAD" signal on the instance's control port in order to apply the addition/deletion of a hidden service.

I initially thought that when I do "RELOAD", Tor would be smart by killing open "client" circuits and rebuild new ones + update HS circuits that need to be updated (ie, add a new circuit, or kill one, depending on what has changed in the HS part of the config). I recently discovered (edit: from what I understood by reading the control spec and the source code) that it's doesn't seem to be the case : since Tor clears its internal state, all open circuits (HS or not) will be killed.

I've looked again into the Tor control protocol spec to see how I could set hidden services while Tor is running. I've found how to do it (SETCONF with the list of HiddenService* lines you would put in the torrc file, in the correct order). Example:

SETCONF HiddenServiceDir="/path/to/key1" HiddenServicePort="80 127.0.0.1:80" HiddenServiceDir="/path/to/key2" HiddenServicePort="80 127.0.0.1:80" [more hidden services here]\r\n

However, I haven't found a way to apply these new settings without doing a SIGNAL RELOAD again. Is there an other way to have those new hidden services be taken into account?

Edit : this question applies actually to adding/removing hidden services or modifying a service's port bindings

1 Answers1

3

It is now possible to create ephemeral onion services via the control port using the ADD_ONION and DEL_ONION commands (added in Tor 0.2.7.1-alpha).

To create a new onion service (the address and private key are returned to you):

ADD_ONION NEW:BEST Port=80

This will return the address (as exampleonion1234 without the trailing .onion) and private key (as a string).

To shut down a currently-running onion service:

DEL_ONION exampleonion1234

To restart a previously-created onion service:

ADD_ONION [PrivateKeyString] Port=80

See sections 3.27 and 3.28 of control-spec.txt for all options.

str4d
  • 177
  • 10