tunnlr_connector 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +20 -0
- data/README +30 -0
- data/bin/tunnlr +5 -0
- data/init.rb +1 -0
- data/lib/tunnlr/configurator.rb +54 -0
- data/lib/tunnlr/connector.rb +57 -0
- data/lib/tunnlr/ui.rb +49 -0
- data/lib/tunnlr.rb +2 -0
- data/rails/init.rb +1 -0
- metadata +73 -0
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2008 [name of plugin creator]
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
TunnlrConnector
|
2
|
+
===============
|
3
|
+
|
4
|
+
TunnlrConnector is a plugin to make connecting to the Tunnlr service easy an painless.
|
5
|
+
|
6
|
+
It requires the net::ssh v2 plugin. To install, execute
|
7
|
+
|
8
|
+
gem install --source http://gems.jamisbuck.org net-ssh
|
9
|
+
|
10
|
+
To run autoconfigure, it also requires the highline gem which is installed as part of capistrano.
|
11
|
+
|
12
|
+
Example
|
13
|
+
=======
|
14
|
+
|
15
|
+
To autoconfigure, run
|
16
|
+
|
17
|
+
rake tunnlr:configure
|
18
|
+
|
19
|
+
and enter the email address and password associated with your tunnlr account.
|
20
|
+
|
21
|
+
To create a tunnel, run
|
22
|
+
|
23
|
+
rake tunnlr:start
|
24
|
+
|
25
|
+
|
26
|
+
Questions or problems? Contact support@tunnlr.com
|
27
|
+
|
28
|
+
|
29
|
+
|
30
|
+
Copyright (c) 2008 Elevated Rails, released under the MIT license
|
data/bin/tunnlr
ADDED
data/init.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'tunnlr'
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'highline'
|
2
|
+
require 'net/ssh'
|
3
|
+
module Tunnlr
|
4
|
+
class Configurator
|
5
|
+
attr_accessor :not_configured,:email,:password
|
6
|
+
def initialize
|
7
|
+
@ui = HighLine.new
|
8
|
+
@not_configured=true
|
9
|
+
end
|
10
|
+
|
11
|
+
def fetch(username,password)
|
12
|
+
url=URI.parse('http://tunnlr.com/configuration.yml')
|
13
|
+
req = Net::HTTP::Get.new(url.path)
|
14
|
+
req.basic_auth(username,password)
|
15
|
+
res = Net::HTTP.start(url.host, url.port) {|http|
|
16
|
+
http.request(req)
|
17
|
+
}
|
18
|
+
@configuration = res.body
|
19
|
+
end
|
20
|
+
|
21
|
+
def add_password
|
22
|
+
@configuration.gsub!(/PASSWD/,password)
|
23
|
+
end
|
24
|
+
|
25
|
+
def write_config(path)
|
26
|
+
open(path,"w+") do |f|
|
27
|
+
f.puts(@configuration)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def get_credentials
|
32
|
+
puts "Enter the email address and password you used to sign up for Tunnlr."
|
33
|
+
self.email = @ui.ask("Email: ")
|
34
|
+
self.password = @ui.ask("Password: ") { |q| q.echo = false }
|
35
|
+
fetch(email,password)
|
36
|
+
end
|
37
|
+
|
38
|
+
def configure(path)
|
39
|
+
while not_configured
|
40
|
+
begin
|
41
|
+
get_credentials
|
42
|
+
fetch(email,password)
|
43
|
+
add_password
|
44
|
+
write_config(path)
|
45
|
+
puts "Created configuration in #{path}"
|
46
|
+
self.not_configured=false
|
47
|
+
rescue Net::HTTPNotAcceptable=>e
|
48
|
+
puts "Login failed, please try again"
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
require 'net/ssh'
|
3
|
+
module Tunnlr
|
4
|
+
|
5
|
+
class Connector
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
@config = read_configuration
|
9
|
+
@should_disconnect =false
|
10
|
+
end
|
11
|
+
|
12
|
+
def connect!
|
13
|
+
@should_disconnect=false
|
14
|
+
while true do
|
15
|
+
begin
|
16
|
+
Net::SSH.start(host,username,:password=>password) do |ssh|
|
17
|
+
puts "Connecting to #{username}@#{host} and sending #{remote_port}->#{local_port}"
|
18
|
+
ssh.forward.remote_to(local_port,'127.0.0.1',remote_port,'0.0.0.0')
|
19
|
+
puts "You can view your tunneled connection at http://web1.tunnlr.com:#{remote_port}/"
|
20
|
+
while true
|
21
|
+
begin
|
22
|
+
ssh.loop {!@should_disconnect}
|
23
|
+
rescue Errno::ECONNRESET=>e
|
24
|
+
raise
|
25
|
+
rescue Interrupt=>e
|
26
|
+
raise
|
27
|
+
rescue Exception=>e
|
28
|
+
puts "Swallowing: #{e.class.to_s} => #{e.to_s}"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
rescue Errno::ECONNRESET=>e
|
33
|
+
puts "Your connection was reset, trying to restart ..."
|
34
|
+
end
|
35
|
+
end
|
36
|
+
rescue Net::SSH::AuthenticationFailed=>e
|
37
|
+
puts "Unable to log in. Please check your password and try again."
|
38
|
+
end
|
39
|
+
|
40
|
+
def disconnect!
|
41
|
+
@should_disconnect=true
|
42
|
+
end
|
43
|
+
|
44
|
+
def read_configuration
|
45
|
+
path = File.join(RAILS_ROOT, "config/tunnlr.yml")
|
46
|
+
YAML.load(File.read(path))
|
47
|
+
end
|
48
|
+
|
49
|
+
def method_missing(name,*args)
|
50
|
+
if @config[name.to_s]
|
51
|
+
@config[name.to_s]
|
52
|
+
else
|
53
|
+
super
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
data/lib/tunnlr/ui.rb
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'wx'
|
2
|
+
module Tunnlr
|
3
|
+
module Ui
|
4
|
+
class MainApp < Wx::App
|
5
|
+
def on_init # we're defining what the application is going to do when it starts
|
6
|
+
t = Wx::Timer.new(self, 55)
|
7
|
+
evt_timer(55) { Thread.pass }
|
8
|
+
t.start(100)
|
9
|
+
|
10
|
+
helloframe = Wx::Frame.new(nil, -1, "Tunnlr") # it's going to make a frame entitled "Hello World"
|
11
|
+
@tunnlr=Tunnlr::Connector.new
|
12
|
+
|
13
|
+
@start = Wx::Button.new(helloframe,-1,"Start Tunnel")
|
14
|
+
@stop = Wx::Button.new(helloframe,-1,"Stop Tunnel")
|
15
|
+
@configure = Wx::Button.new(helloframe,-1,"Configure")
|
16
|
+
@start.evt_button(@start.id) do |event|
|
17
|
+
Thread.new do
|
18
|
+
begin
|
19
|
+
@tunnlr.connect!
|
20
|
+
rescue Exception => e
|
21
|
+
puts e
|
22
|
+
end
|
23
|
+
end
|
24
|
+
@start.hide()
|
25
|
+
@stop.show()
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
@stop.evt_button(@stop.id) do |event|
|
30
|
+
@tunnlr.disconnect!
|
31
|
+
@stop.hide()
|
32
|
+
@start.show()
|
33
|
+
end
|
34
|
+
@start.show()
|
35
|
+
@stop.hide()
|
36
|
+
|
37
|
+
@configure.evt_button(@configure.id) do |event|
|
38
|
+
ConfigureDialog.new.show_modal
|
39
|
+
end
|
40
|
+
helloframe.show() # and then it's going to make the window appear
|
41
|
+
end
|
42
|
+
end
|
43
|
+
class ConfigureDialog < Wx::Dialog
|
44
|
+
def initialize
|
45
|
+
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
data/lib/tunnlr.rb
ADDED
data/rails/init.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__),'../init.rb')
|
metadata
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: tunnlr_connector
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Mike Mangino
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2010-04-06 00:00:00 -04:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: net-ssh
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 2.0.15
|
24
|
+
version:
|
25
|
+
description: A simple plugin to make your local developnment environment available to the internet using the tunnlr.com service
|
26
|
+
email:
|
27
|
+
- mmangino@elevatedrails.com
|
28
|
+
executables:
|
29
|
+
- tunnlr
|
30
|
+
extensions: []
|
31
|
+
|
32
|
+
extra_rdoc_files: []
|
33
|
+
|
34
|
+
files:
|
35
|
+
- lib/tunnlr/configurator.rb
|
36
|
+
- lib/tunnlr/connector.rb
|
37
|
+
- lib/tunnlr/ui.rb
|
38
|
+
- lib/tunnlr.rb
|
39
|
+
- init.rb
|
40
|
+
- README
|
41
|
+
- MIT-LICENSE
|
42
|
+
- rails/init.rb
|
43
|
+
- bin/tunnlr
|
44
|
+
has_rdoc: true
|
45
|
+
homepage: http://tunnlr.com
|
46
|
+
licenses: []
|
47
|
+
|
48
|
+
post_install_message:
|
49
|
+
rdoc_options: []
|
50
|
+
|
51
|
+
require_paths:
|
52
|
+
- lib
|
53
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: "0"
|
58
|
+
version:
|
59
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: "0"
|
64
|
+
version:
|
65
|
+
requirements: []
|
66
|
+
|
67
|
+
rubyforge_project: tunnlr_connector
|
68
|
+
rubygems_version: 1.3.5
|
69
|
+
signing_key:
|
70
|
+
specification_version: 3
|
71
|
+
summary: Provide access to the tunnlr.com service
|
72
|
+
test_files: []
|
73
|
+
|