New port, new onion script

Wanted to link to this little script that interfaces with the tor control port. It allows the app to check for an onion at the PORT and create a new one if it doesn’t exist.
$ export PORT=<XOX>
$ npm start

Will start on port XOX and a new onion will be created and persisted in torrc.

I had some troubles with permissions and ended up moving the torrc to .tor to make it work.

Was wondering if something like this exists somewhere or might it be useful to pull it out make a library / interface / executable / ?

tor could have a option to change ports time by time followed by a command option to generate a torrc config file.

Sorry it’s javascript ;/ - it comes down to 4 rounds of communication with tor controller:

  1. GETCONF HiddenServicePort
  2. GETCONF HiddenServiceDir
  3. SETCONF <>