This is a Ruby library for interacting with the I2P anonymity network.
- Supports checking whether I2P is installed in the user's current
PATH
and whether the I2P router is currently running. - Supports starting, restarting and stopping the I2P router daemon.
- Implements the I2P Basic Open Bridge (BOB) protocol in full.
- Implements the I2P Simple Anonymous Messaging (SAM) protocol basics.
- Supports I2P name resolution using both
hosts.txt
as well as SAM. - Provides I2P tunnel creation and management using BOB.
- Provides a standard socket class for easily connecting to I2P destinations and eepsites without any need for manual tunnel setup.
- Compatible with Ruby 1.8.7+, Ruby 1.9.x, and JRuby 1.4/1.5.
- Bundles the I2P 0.8 SDK and Streaming libraries for use with JRuby,
require 'rubygems'
require 'i2p'
I2P.available? #=> true, if the I2P router is installed
I2P.running? #=> true, if the I2P router is running
I2P.start! #=> executes `i2prouter start`
I2P.restart! #=> executes `i2prouter restart`
I2P.stop! #=> executes `i2prouter stop`
puts I2P::Hosts["forum.i2p"].to_base64
I2P::SAM::Client.open(:port => 7656) do |sam|
puts sam.lookup_name("forum.i2p").to_base64
end
I2P::SAM::Client.open(:port => 7656) do |sam|
key_pair = sam.generate_destination
puts key_pair.destination.to_base64
end
I2P::BOB::Socket.open("forum.i2p") do |socket|
socket.write "HEAD / HTTP/1.1\r\n\r\n"
socket.flush
until (line = socket.readline).chomp.empty?
puts line
end
socket.close
end
tunnel = I2P::BOB::Tunnel.start({
:nickname => :myssh,
:outhost => "127.0.0.1",
:outport => 22, # SSH port
:quiet => true,
})
puts tunnel.destination.to_base64
I2P.rb bundles the public-domain I2P SDK (i2p/sdk.jar
) and
Streaming Library (i2p/streaming.jar
) archives, which means
that to script the I2P Java client implementation from
JRuby, you need only require these two files as follows:
require 'i2p/sdk.jar'
require 'i2p/streaming.jar'
The recommended installation method is via RubyGems. To install the latest official release of I2P.rb, do:
% [sudo] gem install i2p # Ruby 1.8.7+ or 1.9.x
% [sudo] gem install backports i2p # Ruby 1.8.1+
The following are the default values for environment variables that let you customize I2P.rb's implicit configuration:
$ export I2P_PATH=$PATH
$ export I2P_BOB_HOST=127.0.0.1
$ export I2P_BOB_PORT=2827
$ export I2P_SAM_HOST=127.0.0.1
$ export I2P_SAM_PORT=7656
To get a local working copy of the development repository, do:
% git clone git://github.com/bendiken/i2p-ruby.git
Alternatively, you can download the latest development version as a tarball as follows:
% wget http://github.com/bendiken/i2p-ruby/tarball/master
I2P.rb is free and unencumbered public domain software. For more information, see http://unlicense.org/ or the accompanying UNLICENSE file.