tunnlr 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
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/Manifest ADDED
@@ -0,0 +1,13 @@
1
+ MIT-LICENSE
2
+ Manifest
3
+ README
4
+ Rakefile
5
+ tunnlr.gemspec
6
+ tasks/tunnlr_connector_tasks.rake
7
+ lib/tunnlr.rb
8
+ lib/tunnlr/configurator.rb
9
+ lib/tunnlr/connector.rb
10
+ lib/tunnlr/ui.rb
11
+ lib/tunnlr/tasks.rb
12
+ test/tunnlr_connector_test.rb
13
+ tunnlr.yml
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/Rakefile ADDED
@@ -0,0 +1,39 @@
1
+ require 'rake'
2
+ require 'rake/testtask'
3
+ require 'rake/rdoctask'
4
+ require 'rubygems'
5
+ require 'echoe'
6
+
7
+ $LOAD_PATH << File.join(File.dirname(__FILE__), 'lib')
8
+ require 'tunnlr'
9
+
10
+ desc 'Default: run unit tests.'
11
+ task :default => :test
12
+
13
+ desc 'Test the tunnlr_connector plugin.'
14
+ Rake::TestTask.new(:test) do |t|
15
+ t.libs << 'lib'
16
+ t.pattern = 'test/**/*_test.rb'
17
+ t.verbose = true
18
+ end
19
+
20
+ desc 'Generate documentation for the tunnlr_connector plugin.'
21
+ Rake::RDocTask.new(:rdoc) do |rdoc|
22
+ rdoc.rdoc_dir = 'rdoc'
23
+ rdoc.title = 'TunnlrConnector'
24
+ rdoc.options << '--line-numbers' << '--inline-source'
25
+ rdoc.rdoc_files.include('README')
26
+ rdoc.rdoc_files.include('lib/**/*.rb')
27
+ end
28
+
29
+
30
+ Echoe.new('tunnlr', '0.0.2') do |p|
31
+ p.description = "A gem version of the tunnlr rails plugin"
32
+ p.url = "http://github.com/james2m/tunnlr"
33
+ p.author = "James McCarthy"
34
+ p.email = "james2mccarthy @nospam@ gmail.com"
35
+ p.ignore_pattern = ["tmp/*", "script/*"]
36
+ p.development_dependencies = []
37
+ end
38
+
39
+ Dir["#{File.dirname(__FILE__)}/tasks/*.rake"].sort.each { |ext| load ext }
@@ -0,0 +1,55 @@
1
+ require 'highline'
2
+ require 'net/ssh'
3
+ module Tunnlr
4
+ class Configurator
5
+ attr_accessor :not_configured, :email, :password, :domain
6
+ def initialize
7
+ @ui = HighLine.new
8
+ @not_configured=true
9
+ end
10
+
11
+ def fetch(username, password, domain)
12
+ url=URI.parse("http://#{domain}.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
+ res.value
19
+ @configuration = res.body
20
+ end
21
+
22
+ def add_password
23
+ @configuration.gsub!(/PASSWD/,password)
24
+ end
25
+
26
+ def write_config(path)
27
+ open(path,"w+") do |f|
28
+ f.puts(@configuration)
29
+ end
30
+ end
31
+
32
+ def get_credentials
33
+ puts "Enter the email address, password and domain you used to sign up for Tunnlr."
34
+ self.email = @ui.ask("Email: ")
35
+ self.password = @ui.ask("Password: ") { |q| q.echo = false }
36
+ self.domain = @ui.ask("Domain: ")
37
+ end
38
+
39
+ def configure(path)
40
+ while not_configured
41
+ begin
42
+ get_credentials
43
+ fetch(email, password, domain)
44
+ add_password
45
+ write_config(path)
46
+ puts "Created configuration in #{path}"
47
+ self.not_configured=false
48
+ rescue Net::HTTPNotAcceptable=>e
49
+ puts "Login failed, please try again"
50
+ end
51
+ end
52
+ end
53
+
54
+ end
55
+ 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}"
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
@@ -0,0 +1,18 @@
1
+ require File.join(File.dirname(__FILE__), "..", "tunnlr")
2
+ # desc "Explaining what the task does"
3
+ # task :tunnlr_connector do
4
+ # # Task goes here
5
+ # end
6
+ desc "Create a tunnel"
7
+ namespace :tunnlr do
8
+ task :start => :environment do
9
+ Tunnlr::Connector.new.connect!
10
+ end
11
+ task :configure => :environment do
12
+ Tunnlr::Configurator.new.configure(File.join(RAILS_ROOT,"config","tunnlr.yml"))
13
+ end
14
+ task :ui => :environment do
15
+ require 'tunnlr/ui'
16
+ Tunnlr::Ui::MainApp.new.main_loop
17
+ end
18
+ 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
@@ -0,0 +1,3 @@
1
+ require 'tunnlr/connector'
2
+ require 'tunnlr/configurator'
3
+
@@ -0,0 +1,4 @@
1
+ lib_dir = File.expand_path(File.dirname(__FILE__) + '/../lib')
2
+ $LOAD_PATH << lib_dir unless $LOAD_PATH.include?(lib_dir)
3
+
4
+ require 'tunnlr/tasks'
@@ -0,0 +1,8 @@
1
+ require 'test/unit'
2
+
3
+ class TunnlrConnectorTest < Test::Unit::TestCase
4
+ # Replace this with your real tests.
5
+ def test_this_plugin
6
+ flunk
7
+ end
8
+ end
data/tunnlr.gemspec ADDED
@@ -0,0 +1,33 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{tunnlr}
5
+ s.version = "0.0.2"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["James McCarthy"]
9
+ s.date = %q{2010-01-14}
10
+ s.description = %q{A gem version of the tunnlr rails plugin}
11
+ s.email = %q{james2mccarthy @nospam@ gmail.com}
12
+ s.extra_rdoc_files = ["README", "tasks/tunnlr_connector_tasks.rake", "lib/tunnlr.rb", "lib/tunnlr/configurator.rb", "lib/tunnlr/connector.rb", "lib/tunnlr/ui.rb", "lib/tunnlr/tasks.rb"]
13
+ s.files = ["MIT-LICENSE", "Manifest", "README", "Rakefile", "tasks/tunnlr_connector_tasks.rake", "lib/tunnlr.rb", "lib/tunnlr/configurator.rb", "lib/tunnlr/connector.rb", "lib/tunnlr/ui.rb", "lib/tunnlr/tasks.rb", "test/tunnlr_connector_test.rb", "tunnlr.yml", "tunnlr.gemspec"]
14
+ s.homepage = %q{http://github.com/james2m/tunnlr}
15
+ s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Tunnlr", "--main", "README"]
16
+ s.require_paths = ["lib"]
17
+ s.rubyforge_project = %q{tunnlr}
18
+ s.rubygems_version = %q{1.3.5}
19
+ s.summary = %q{A gem version of the tunnlr rails plugin}
20
+ s.test_files = ["test/tunnlr_connector_test.rb"]
21
+ s.add_dependency('net-ssh', ['>= 2.0.0'])
22
+ s.signing_key = '/Users/james/Secure/Certificates/gem-keys/tunnlr-gem-private_key.pem'
23
+ s.cert_chain = ['gem-public_cert.pem']
24
+ if s.respond_to? :specification_version then
25
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
26
+ s.specification_version = 3
27
+
28
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
29
+ else
30
+ end
31
+ else
32
+ end
33
+ end
data/tunnlr.yml ADDED
@@ -0,0 +1,4 @@
1
+ remote_port: 10104
2
+ local_port: 3000
3
+ user: tunnlr8
4
+ host: ssh1.tunnlr.com
data.tar.gz.sig ADDED
Binary file
metadata ADDED
@@ -0,0 +1,108 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tunnlr
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - James McCarthy
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain:
11
+ - |
12
+ -----BEGIN CERTIFICATE-----
13
+ MIIDPjCCAiagAwIBAgIBADANBg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
+ tj9UO8RHdhDQNHk4s0KDdx0XLLyScip9Cl0zrCnGlwHCtr/LAMcztldKu6MgTTmG
30
+ 592P7ckv8ZwmaiTXGc7jmehg
31
+ -----END CERTIFICATE-----
32
+
33
+ date: 2010-01-14 00:00:00 +00:00
34
+ default_executable:
35
+ dependencies:
36
+ - !ruby/object:Gem::Dependency
37
+ name: net-ssh
38
+ type: :runtime
39
+ version_requirement:
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ version: 2.0.0
45
+ version:
46
+ description: A gem version of the tunnlr rails plugin
47
+ email: james2mccarthy @nospam@ gmail.com
48
+ executables: []
49
+
50
+ extensions: []
51
+
52
+ extra_rdoc_files:
53
+ - README
54
+ - tasks/tunnlr_connector_tasks.rake
55
+ - lib/tunnlr.rb
56
+ - lib/tunnlr/configurator.rb
57
+ - lib/tunnlr/connector.rb
58
+ - lib/tunnlr/ui.rb
59
+ - lib/tunnlr/tasks.rb
60
+ files:
61
+ - MIT-LICENSE
62
+ - Manifest
63
+ - README
64
+ - Rakefile
65
+ - tasks/tunnlr_connector_tasks.rake
66
+ - lib/tunnlr.rb
67
+ - lib/tunnlr/configurator.rb
68
+ - lib/tunnlr/connector.rb
69
+ - lib/tunnlr/ui.rb
70
+ - lib/tunnlr/tasks.rb
71
+ - test/tunnlr_connector_test.rb
72
+ - tunnlr.yml
73
+ - tunnlr.gemspec
74
+ has_rdoc: true
75
+ homepage: http://github.com/james2m/tunnlr
76
+ licenses: []
77
+
78
+ post_install_message:
79
+ rdoc_options:
80
+ - --line-numbers
81
+ - --inline-source
82
+ - --title
83
+ - Tunnlr
84
+ - --main
85
+ - README
86
+ require_paths:
87
+ - lib
88
+ required_ruby_version: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: "0"
93
+ version:
94
+ required_rubygems_version: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - ">="
97
+ - !ruby/object:Gem::Version
98
+ version: "1.2"
99
+ version:
100
+ requirements: []
101
+
102
+ rubyforge_project: tunnlr
103
+ rubygems_version: 1.3.5
104
+ signing_key:
105
+ specification_version: 3
106
+ summary: A gem version of the tunnlr rails plugin
107
+ test_files:
108
+ - test/tunnlr_connector_test.rb
metadata.gz.sig ADDED
@@ -0,0 +1,3 @@
1
+ xJ���+F�BwYj
2
+ >��ե�墴��Ur*J �5��}��w��j�S����!�ޱ�ߌ�=� {�-8��rG�ȗ���ˀ����g��k��z�_��)i��ޅ'�� '�/]8>P"+�Hb[Ǖ|�Ủ���Z6�C˸�<�5V9:�xѱߞ�:@[�&��Z��rGA
3
+ �Џ��h �l��`-�e��(Q�K��٪ÀG�ps����V :�C�b&j?6