hsume2-localtunnel 0.3.beta.5 → 0.3

Sign up to get free protection for your applications and to get access to all the features.
data/Manifest CHANGED
@@ -2,6 +2,7 @@ Manifest
2
2
  README.rdoc
3
3
  Rakefile
4
4
  bin/localtunnel
5
+ hsume2-localtunnel.gemspec
5
6
  lib/localtunnel.rb
6
7
  lib/localtunnel/net_ssh_gateway_patch.rb
7
8
  lib/localtunnel/tunnel.rb
data/Rakefile CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
2
2
  require 'rake'
3
3
  require 'echoe'
4
4
 
5
- Echoe.new('hsume2-localtunnel', '0.3.beta.5') do |p|
5
+ Echoe.new('hsume2-localtunnel', '0.3') do |p|
6
6
  p.description = "instant public tunnel to your local web server"
7
7
  p.url = "http://github.com/hsume2/localtunnel"
8
8
  p.author = "Jeff Lindsay"
@@ -12,6 +12,6 @@ Echoe.new('hsume2-localtunnel', '0.3.beta.5') do |p|
12
12
  p.rdoc_options = []
13
13
  p.ignore_pattern = ["tmp/*", "script/*"]
14
14
  p.executable_pattern = ["bin/*"]
15
- p.runtime_dependencies = ["json >=1.2.4", "net-ssh >=2.0.22", "net-ssh-gateway >=1.0.1", "sinatra >=1.2.6", "POpen4 >=0.1.4", "twilio-ruby >=3.2.0"]
15
+ p.runtime_dependencies = ["json >=1.2.4", "net-ssh >=2.0.22", "net-ssh-gateway >=1.0.1", "sinatra >=1.3.2"]
16
16
  p.development_dependencies = []
17
17
  end
@@ -24,32 +24,15 @@
24
24
 
25
25
  require 'rubygems'
26
26
  require 'optparse'
27
- require 'yaml'
28
27
  require 'localtunnel'
29
28
 
30
- key, config = nil, nil
29
+ key = nil
31
30
  options = OptionParser.new do |o|
32
31
  o.banner = "Usage: localtunnel [options] <localport>"
33
32
  o.on("-k", "--key FILE", "upload a public key for authentication") do |k|
34
33
  key = File.exist?(k.to_s) ? File.open(k).read : nil
35
34
  end
36
35
  o.on('-h', "--help", "show this help") { puts o; exit }
37
- o.on('-c', "--config FILE", "configure Twilio phone numbers for localtunnel from config file",
38
- "Example (YAML):",
39
- " ---",
40
- " - account_sid: AC...",
41
- " auth_token: ...",
42
- " phone_number_sid: PN...",
43
- " urls:",
44
- " voice_url: /voice/calls/...",
45
- " status_callback: /voice/calls/...",
46
- " voice_fallback_url: /voice/calls/...",
47
- " sms_url: /voice/calls/...") do |k|
48
- config = File.exist?(k.to_s) ? YAML::load(File.open(k)) : nil
49
- end
50
- o.on('-e', "--evaluate YAML", "configure Twilio phone numbers for localtunnel from YAML string") do |k|
51
- config = YAML::load(k.gsub("\\n", "\n"))
52
- end
53
36
  end
54
37
 
55
38
  args = options.parse!
@@ -59,6 +42,6 @@ unless local_port.to_i.between?(1, 65535)
59
42
  exit
60
43
  end
61
44
 
62
- t = LocalTunnel::Tunnel.new(local_port, key, config)
45
+ t = LocalTunnel::Tunnel.new(local_port, key)
63
46
  t.register_tunnel
64
- t.start_tunnel
47
+ t.start_tunnel
@@ -2,17 +2,17 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{hsume2-localtunnel}
5
- s.version = "0.3.beta.5"
5
+ s.version = "0.3"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Jeff Lindsay"]
9
- s.date = %q{2012-02-22}
9
+ s.date = %q{2012-01-24}
10
10
  s.default_executable = %q{localtunnel}
11
11
  s.description = %q{instant public tunnel to your local web server}
12
12
  s.email = %q{jeff.lindsay@twilio.com}
13
13
  s.executables = ["localtunnel"]
14
- s.extra_rdoc_files = ["README.rdoc", "Rakefile", "bin/localtunnel", "lib/localtunnel.rb", "lib/localtunnel/net_ssh_gateway_patch.rb", "lib/localtunnel/tunnel.rb", "lib/localtunnel/tunnel_app.rb", "server.py", "hsume2-localtunnel.gemspec"]
15
- s.files = ["Manifest", "README.rdoc", "Rakefile", "bin/localtunnel", "lib/localtunnel.rb", "lib/localtunnel/net_ssh_gateway_patch.rb", "lib/localtunnel/tunnel.rb", "lib/localtunnel/tunnel_app.rb", "server.py", "hsume2-localtunnel.gemspec"]
14
+ s.extra_rdoc_files = ["README.rdoc", "Rakefile", "bin/localtunnel", "hsume2-localtunnel.gemspec", "lib/localtunnel.rb", "lib/localtunnel/net_ssh_gateway_patch.rb", "lib/localtunnel/tunnel.rb", "lib/localtunnel/tunnel_app.rb", "server.py"]
15
+ s.files = ["Manifest", "README.rdoc", "Rakefile", "bin/localtunnel", "hsume2-localtunnel.gemspec", "lib/localtunnel.rb", "lib/localtunnel/net_ssh_gateway_patch.rb", "lib/localtunnel/tunnel.rb", "lib/localtunnel/tunnel_app.rb", "server.py"]
16
16
  s.homepage = %q{http://github.com/hsume2/localtunnel}
17
17
  s.require_paths = ["lib"]
18
18
  s.rubyforge_project = %q{hsume2-localtunnel}
@@ -26,23 +26,17 @@ Gem::Specification.new do |s|
26
26
  s.add_runtime_dependency(%q<json>, [">= 1.2.4"])
27
27
  s.add_runtime_dependency(%q<net-ssh>, [">= 2.0.22"])
28
28
  s.add_runtime_dependency(%q<net-ssh-gateway>, [">= 1.0.1"])
29
- s.add_runtime_dependency(%q<sinatra>, [">= 1.2.6"])
30
- s.add_runtime_dependency(%q<POpen4>, [">= 0.1.4"])
31
- s.add_runtime_dependency(%q<twilio-ruby>, [">= 3.2.0"])
29
+ s.add_runtime_dependency(%q<sinatra>, [">= 1.3.2"])
32
30
  else
33
31
  s.add_dependency(%q<json>, [">= 1.2.4"])
34
32
  s.add_dependency(%q<net-ssh>, [">= 2.0.22"])
35
33
  s.add_dependency(%q<net-ssh-gateway>, [">= 1.0.1"])
36
- s.add_dependency(%q<sinatra>, [">= 1.2.6"])
37
- s.add_dependency(%q<POpen4>, [">= 0.1.4"])
38
- s.add_dependency(%q<twilio-ruby>, [">= 3.2.0"])
34
+ s.add_dependency(%q<sinatra>, [">= 1.3.2"])
39
35
  end
40
36
  else
41
37
  s.add_dependency(%q<json>, [">= 1.2.4"])
42
38
  s.add_dependency(%q<net-ssh>, [">= 2.0.22"])
43
39
  s.add_dependency(%q<net-ssh-gateway>, [">= 1.0.1"])
44
- s.add_dependency(%q<sinatra>, [">= 1.2.6"])
45
- s.add_dependency(%q<POpen4>, [">= 0.1.4"])
46
- s.add_dependency(%q<twilio-ruby>, [">= 3.2.0"])
40
+ s.add_dependency(%q<sinatra>, [">= 1.3.2"])
47
41
  end
48
42
  end
@@ -4,8 +4,6 @@ require 'net/ssh/gateway'
4
4
  require 'net/http'
5
5
  require 'uri'
6
6
  require 'json'
7
- require 'open4'
8
- require 'twilio-ruby'
9
7
 
10
8
  require 'localtunnel/net_ssh_gateway_patch'
11
9
 
@@ -17,13 +15,12 @@ class LocalTunnel::Tunnel
17
15
 
18
16
  SHELL_HOOK_FILE = "./.localtunnel_callback"
19
17
 
20
- attr_accessor :port, :key, :host, :config
18
+ attr_accessor :port, :key, :host
21
19
 
22
- def initialize(port, key, config)
20
+ def initialize(port, key)
23
21
  @port = port
24
22
  @key = key
25
23
  @host = ""
26
- @config = config
27
24
  end
28
25
 
29
26
  def register_tunnel(key=@key)
@@ -48,18 +45,8 @@ class LocalTunnel::Tunnel
48
45
  def start_tunnel
49
46
  port = @port
50
47
  tunnel = @tunnel
51
-
52
- TunnelApp.tunnel = tunnel['host']
53
- tunnel_pid = fork { TunnelApp.run! }
54
-
55
- at_exit do
56
- Process.kill('KILL', tunnel_pid)
57
- Process.waitpid(tunnel_pid)
58
- end
59
-
60
- error = ''
61
-
62
- status = Open4::popen4("ssh -nNT -g -R *:#{tunnel['through_port']}:0.0.0.0:#{port} #{tunnel['user']}@#{@host} -o PasswordAuthentication=no -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null") do |pid, i, o, e|
48
+ gateway = Net::SSH::Gateway.new(@host, tunnel['user'], :auth_methods => %w{ publickey })
49
+ gateway.open_remote(port.to_i, '127.0.0.1', tunnel['through_port'].to_i) do |rp,rh|
63
50
  puts " " << tunnel['banner'] if tunnel.has_key? 'banner'
64
51
  if File.exists?(File.expand_path(SHELL_HOOK_FILE))
65
52
  system "#{SHELL_HOOK_FILE} ""#{tunnel['host']}""" if File.exists?(File.expand_path(SHELL_HOOK_FILE))
@@ -68,39 +55,25 @@ class LocalTunnel::Tunnel
68
55
  puts " (Make sure it is executable)"
69
56
  end
70
57
  end
71
-
72
- if @config && @config.any?
73
- @config.each do |config|
74
- client = Twilio::REST::Client.new(config['account_sid'], config['auth_token'])
75
- account = client.account
76
- properties = config['urls'].inject({}) do |urls, k_v|
77
- k, v = k_v
78
- urls[k] = URI.join("http://#{tunnel['host']}", v).to_s
79
- urls
80
- end
81
- pn = account.incoming_phone_numbers.get(config['phone_number_sid']).update(properties)
82
- puts " Updated #{pn.phone_number} for localtunnel."
83
- end
84
- end
85
-
58
+ TunnelApp.tunnel = tunnel['host']
59
+ pid = fork {
60
+ TunnelApp.run!
61
+ }
86
62
  puts " Port #{port} is now publicly accessible from http://#{tunnel['host']} ..."
87
-
88
63
  begin
89
- while str = e.gets
90
- error += str
91
- puts str
92
- end
64
+ sleep 1 while true
93
65
  rescue Interrupt
66
+ Process.kill('KILL', pid)
67
+ Process.waitpid(pid)
68
+ gateway.close_remote(rp, rh)
94
69
  exit
95
70
  end
96
71
  end
97
-
98
- if error =~ /Permission denied/
99
- possible_key = Dir[File.expand_path('~/.ssh/*.pub')].first
100
- puts " Failed to authenticate. If this is your first tunnel, you need to"
101
- puts " upload a public key using the -k option. Try this:\n\n"
102
- puts " localtunnel -k #{possible_key ? possible_key : '~/path/to/key'} #{port}"
103
- exit
104
- end
72
+ rescue Net::SSH::AuthenticationFailed
73
+ possible_key = Dir[File.expand_path('~/.ssh/*.pub')].first
74
+ puts " Failed to authenticate. If this is your first tunnel, you need to"
75
+ puts " upload a public key using the -k option. Try this:\n\n"
76
+ puts " localtunnel -k #{possible_key ? possible_key : '~/path/to/key'} #{port}"
77
+ exit
105
78
  end
106
79
  end
metadata CHANGED
@@ -1,14 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hsume2-localtunnel
3
3
  version: !ruby/object:Gem::Version
4
- hash: 62196289
5
- prerelease: 4
4
+ hash: 13
5
+ prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - beta
10
- - 5
11
- version: 0.3.beta.5
9
+ version: "0.3"
12
10
  platform: ruby
13
11
  authors:
14
12
  - Jeff Lindsay
@@ -16,7 +14,7 @@ autorequire:
16
14
  bindir: bin
17
15
  cert_chain: []
18
16
 
19
- date: 2012-02-22 00:00:00 -08:00
17
+ date: 2012-01-24 00:00:00 -08:00
20
18
  default_executable: localtunnel
21
19
  dependencies:
22
20
  - !ruby/object:Gem::Dependency
@@ -75,46 +73,14 @@ dependencies:
75
73
  requirements:
76
74
  - - ">="
77
75
  - !ruby/object:Gem::Version
78
- hash: 19
76
+ hash: 31
79
77
  segments:
80
78
  - 1
81
- - 2
82
- - 6
83
- version: 1.2.6
84
- type: :runtime
85
- version_requirements: *id004
86
- - !ruby/object:Gem::Dependency
87
- name: POpen4
88
- prerelease: false
89
- requirement: &id005 !ruby/object:Gem::Requirement
90
- none: false
91
- requirements:
92
- - - ">="
93
- - !ruby/object:Gem::Version
94
- hash: 19
95
- segments:
96
- - 0
97
- - 1
98
- - 4
99
- version: 0.1.4
100
- type: :runtime
101
- version_requirements: *id005
102
- - !ruby/object:Gem::Dependency
103
- name: twilio-ruby
104
- prerelease: false
105
- requirement: &id006 !ruby/object:Gem::Requirement
106
- none: false
107
- requirements:
108
- - - ">="
109
- - !ruby/object:Gem::Version
110
- hash: 15
111
- segments:
112
79
  - 3
113
80
  - 2
114
- - 0
115
- version: 3.2.0
81
+ version: 1.3.2
116
82
  type: :runtime
117
- version_requirements: *id006
83
+ version_requirements: *id004
118
84
  description: instant public tunnel to your local web server
119
85
  email: jeff.lindsay@twilio.com
120
86
  executables:
@@ -125,23 +91,23 @@ extra_rdoc_files:
125
91
  - README.rdoc
126
92
  - Rakefile
127
93
  - bin/localtunnel
94
+ - hsume2-localtunnel.gemspec
128
95
  - lib/localtunnel.rb
129
96
  - lib/localtunnel/net_ssh_gateway_patch.rb
130
97
  - lib/localtunnel/tunnel.rb
131
98
  - lib/localtunnel/tunnel_app.rb
132
99
  - server.py
133
- - hsume2-localtunnel.gemspec
134
100
  files:
135
101
  - Manifest
136
102
  - README.rdoc
137
103
  - Rakefile
138
104
  - bin/localtunnel
105
+ - hsume2-localtunnel.gemspec
139
106
  - lib/localtunnel.rb
140
107
  - lib/localtunnel/net_ssh_gateway_patch.rb
141
108
  - lib/localtunnel/tunnel.rb
142
109
  - lib/localtunnel/tunnel_app.rb
143
110
  - server.py
144
- - hsume2-localtunnel.gemspec
145
111
  has_rdoc: true
146
112
  homepage: http://github.com/hsume2/localtunnel
147
113
  licenses: []