Project

tor2

0.0
No commit activity in last 3 years
No release in over 3 years
Tor.rb is a Ruby library for interacting with the Tor anonymity network.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 1.3.0
>= 0.6.0
 Project Readme

Tor.rb: Onion Routing for Ruby (tor2)

This is a Ruby library for interacting with the Tor anonymity network.

/ ! \ This repository were created to keep an updated version of this lib on the gem store. I am not the author or the maintainer even if PR are welcomed. The original project can be found at https://github.com/dryruby/tor.rb (previously http://github.com/bendiken/tor-ruby).

The name of this alternative gem is tor2 to avoid confusion with the original.

Features

  • Supports checking whether Tor is installed in the user's current PATH, and if it is, returning the version number.
  • Supports parsing Tor configuration files and looking up the values of particular options.
  • Supports querying and controlling a locally-running Tor process using the Tor Control Protocol (TC) over a socket connection.
  • Supports querying the Tor DNS Exit List (DNSEL) to determine whether a particular host is a Tor exit node or not.
  • Compatible with Ruby 1.8.7+, Ruby 1.9.x, and JRuby 1.4/1.5.

Examples

require 'rubygems'
require 'tor2'

Checking whether Tor is installed and which version it is

Tor.available?                                     #=> true
Tor.version                                        #=> "0.2.1.25"

Parsing the Tor configuration file (1)

torrc = Tor::Config.load("/etc/tor/torrc")

Parsing the Tor configuration file (2)

Tor::Config.open("/etc/tor/torrc") do |torrc|
  puts "Tor SOCKS port: #{torrc['SocksPort']}"
  puts "Tor control port: #{torrc['ControlPort']}"
  puts "Tor exit policy:"
  torrc.each('ExitPolicy') do |key, value|
    puts "  #{value}"
  end
end

Communicating with a running Tor process

Tor::Controller.connect(:port => 9051) do |tor|
  puts "Tor version: #{tor.version}"
  puts "Tor config file: #{tor.config_file}"
end

Checking whether a particular host is a Tor exit node

Tor::DNSEL.include?("208.75.57.100")               #=> true
Tor::DNSEL.include?("1.2.3.4")                     #=> false

Documentation

Dependencies

Installation

The recommended installation method is via RubyGems. To install the latest official release of Tor.rb, do:

% [sudo] gem install tor2                 # Ruby 1.8.7+ or 1.9.x
% [sudo] gem install backports tor2       # Ruby 1.8.1+

Download

To get a local working copy of the development repository, do:

% git clone git://github.com/alexmili/tor.rb.git

Alternatively, you can download the latest development version as a tarball as follows:

% wget http://github.com/alexmili/tor.rb/tarball/master

Author

License

Tor.rb is free and unencumbered public domain software. For more information, see http://unlicense.org/ or the accompanying UNLICENSE file.