Skip to content
This repository has been archived by the owner on Feb 26, 2023. It is now read-only.

warrenguy/ruby-hidden-service

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 [email protected]

https://warrenguy.me

About

Bring up a Tor hidden service from within your Ruby app

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages