TODO: Write a gem description


Add this line to your application's Gemfile:

gem 'reverse-tunnel'

And then execute:

$ bundle

Or install it yourself as:

$ gem install reverse-tunnel


reverse-tunnel server --public= --api= --range=

reverse-tunnel client --server= --local-port=22 6B833D3F561369156820B4240C7C2657

reverse-tunnel rt://
reverse-tunnel cnQ6Ly9jb25zb2xlLnRyeXBob24uZXU6NDg5My82QjgzM0QzRjU2MTM2OTE1NjgyMEI0MjQwQzdDMjY1Ny8yMg==


Create a new tunnel :

$ curl -X POST -d '{"token":"156820B4240C7C26576B833D3F561369","local_port":10001}' http://localhost:5000/tunnels.json
    "token": "156820B4240C7C26576B833D3F561369",
    "local_port": 10001

Retrieve current tunnels :

$ curl http://localhost:5000/tunnels.json
        "token": "6B833D3F561369156820B4240C7C2657",
        "local_port": 10000,
        "token": "156820B4240C7C26576B833D3F561369",
        "local_port": 10001,
        "connection": {
            "peer": "",
            "created_at": "2012-12-22 17:29:55 +0100"


Create tunnel

  • POST /tunnels on server API (with optional token and local port)
  • API returns token and local port

Open tunnel

  • client send tunnel token to server (on public ip:port)
  • server opens a tcp server on local port (associated to token)
  • client receives a confirmation message

Ping tunnel

  • every 30s (?) client sends a ping message
  • server responds a pong message

Use tunnel

  • server receives a connection on tcp server on local port
  • server creates a session (with id)
  • server sends received data to client
  • client creates local connection to local port (if not exist)
  • client send received data to local connection
  • client send back to server data received on local connection


  • OPEN_TUNNEL:tunnel_token
  • PING
  • PONG
  • OPEN_SESSION:session_id
  • DATA:session_id:data
  • CLOSE_SESSION:session_id


  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request