Bring up a Tor hidden service from within your Ruby app
Ruby
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib/tor
Gemfile
LICENSE
README.md
ruby-hidden-service.gemspec

README.md

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