Repository is archived
No commit activity in last 3 years
No release in over 3 years
Automatically set up and tear down a Tor hidden service
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

>= 0
 Project Readme

Tor::HiddenService

Bring up a Tor hidden service from within your Ruby app.

You might find this useful to run a hidden service in your Heroku/Dokku or other containerised infrastructure.

Example Sinatra app: heroku-sinatra-hidden-service

Usage

Add the gem to your Gemfile:

gem 'ruby-hidden-service'

and start the hidden service during startup of your web backend, probably in config.ru, for example:

require 'tor/hidden-service'

hidden_service = Tor::HiddenService.new(
  private_key: ENV['HIDDEN_SERVICE_PRIVATE_KEY'],
  server_port: ENV['PORT'] || 5000
)

hidden_service.start

Options

All configuration options and their defaults:

tor_executable:      (Tor.available? ? Tor.program_path : nil),
temp_dir:            "#{ENV['PWD']}/tmp" || nil,
private_key:         nil,
server_host:         'localhost',
server_port:         ENV['PORT'],
hidden_service_port: 80,
tor_control_port:    rand(10000..65000)

Tor executable

This relies on Tor being in your path, or otherwise having the path to the Tor binary specified in the options hash. If you're running on Heroku or Dokku, you can use the heroku-buildpack-apt and heroku-buildpack-multi buildpacks to install the tor package. This will place the Tor binary in the path where this library can discover it.

License

MIT license. See LICENSE.

Author

Warren Guy warren@guy.net.au

https://warrenguy.me