https://github.com/theckman/tunnelbroker
Ruby TunnelBroker API client
https://github.com/theckman/tunnelbroker
Last synced: 3 months ago
JSON representation
Ruby TunnelBroker API client
- Host: GitHub
- URL: https://github.com/theckman/tunnelbroker
- Owner: theckman
- License: mit
- Created: 2014-04-05T05:44:03.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2014-05-25T10:46:44.000Z (about 11 years ago)
- Last Synced: 2025-02-25T22:47:19.327Z (4 months ago)
- Language: Ruby
- Size: 809 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
tunnelbroker
============
[](https://travis-ci.org/theckman/tunnelbroker)
[](https://tldrlegal.com/license/mit-license)
[](https://rubygems.org/gems/tunnelbroker)
[](https://coveralls.io/r/theckman/tunnelbroker)
[](https://codeclimate.com/github/theckman/tunnelbroker)
[](https://gemnasium.com/theckman/tunnelbroker)Ruby TunnelBroker API client
LICENSE
-------
[tunnelbroker](https://github.com/theckman/tunnelbroker) is released under
the [MIT](http://opensource.org/licenses/MIT) license. The full license has
been provided in the
[LICENSE](https://github.com/theckman/tunnelbroker/blob/master/LICENSE) file.CONTRIBUTING
------------
See [CONTRIBUTION.md](https://github.com/theckman/tunnelbroker/blob/master/CONTRIBUTING.md)
for information on contributing back to this project.INSTALLATION
------------
To install on the commandline using `gem`:```Bash
gem install tunnelbroker
```If you are including this in your project's `Gemfile`:
```Ruby
gem 'tunnelbroker'
```USAGE
-----
### Nitty-gritty overview
```Ruby
# require the gem
require 'tunnelbroker'
=> true# instantiate a new client
client = TunnelBroker::Client.new
=> ## configure the client
client.configure do |c|
c.tunnelid = 42
c.username = 'theckman'
c.update_key = 'YourUpdateKey'
end# check your config options
client.config.username
=> "theckman"# update the API, assign the response object
response = client.submit_update
=> #"nochg", :data=>{:ip=>"50.161.84.35"}}># was it successful?
response.success?
=> true# did the IP address change?
response.changed?
=> false# configure the client, specifying an ip4addr this time
client.configure do |c|
c.ip4addr = '127.0.0.1'
end# update the API, assign the response object
response = client.submit_update
=> #"good", :data=>{:ip=>"127.0.0.1"}}># was it successful?
response.success?
=> true# did the IP address change?
response.changed?
=> true
```### Configuration
The configuration of the client is done by sending a Ruby block to the client's
`configure` method:```Ruby
# henceforth, any refences to client will be this:
client = TunnelBroker::Client.newclient.configure do |cfg|
cfg.username = 'theckman'
end
```Here are the available configuration items:
| Option | Explanation |
| ------------ | ----------- |
| `ip4addr` | Specify the ipv4 address that will connect to the tunnel. If not specified, the IP address of which the request came from is specified. |
| `username` | This is your [tunnelbroker.net](https://www.tunnelbroker.net/) username |
| `update_key` | This is the update_key for your tunnel, you can set this on the 'Advanced' tab for your tunnel. |
| `tunnelid` | The tunnelid from the 'IPv6 Tunnel' tab of your tunnel. |
| `url` | If you want to use a custom endpoint URL, you can specify it here. Defaults to the TunnelBroker API endpoint. |### Updating the API
There is a simple method to update the API. It returns a `TunnelBroker::APIResponse` object.
```Ruby
client.submit_update
```### Checking the response object
The response object has two primary methods for telling what happened:* `.success?` - returns true/false as to whether this was successful or not
* `.changed?` - returns true/false as to whether IP had changed.
* `.response` - Hash containing the response from the server split in to sections.