forward 0.0.11 → 0.0.12

Sign up to get free protection for your applications and to get access to all the features.
@@ -40,34 +40,34 @@ module Forward
40
40
  end
41
41
 
42
42
  def self.client=(client)
43
- @@client = client
43
+ @client = client
44
44
  end
45
45
 
46
46
  def self.client
47
- defined?(@@client) && @@client
47
+ @client
48
48
  end
49
49
 
50
50
  def self.debug!
51
- @@debug = true
51
+ @debug = true
52
52
  logger.level = Logger::DEBUG
53
53
  end
54
54
 
55
55
  def self.debug?
56
- defined?(@@debug) && @@debug
56
+ @debug
57
57
  end
58
58
 
59
59
  def self.stringio_log
60
- @@stringio_log ||= StringIO.new
60
+ @stringio_log ||= StringIO.new
61
61
  end
62
62
 
63
63
  def self.debug_remotely!
64
64
  logger(stringio_log)
65
65
  debug!
66
- @@debug_remotely = true
66
+ @debug_remotely = true
67
67
  end
68
68
 
69
69
  def self.debug_remotely?
70
- defined?(@@debug_remotely) && @@debug_remotely
70
+ @debug_remotely
71
71
  end
72
72
 
73
73
  def self.log(level, message)
@@ -75,7 +75,7 @@ module Forward
75
75
  end
76
76
 
77
77
  def self.logger(logdev = STDOUT)
78
- @@logger ||= Logger.new(logdev)
78
+ @logger ||= Logger.new(logdev)
79
79
  end
80
80
 
81
81
  # Returns a string representing a detailed client version.
@@ -7,6 +7,7 @@ module Forward
7
7
  resource.uri = '/api/tunnels'
8
8
  params = {
9
9
  :hostport => options[:port],
10
+ :vhost => options[:host],
10
11
  :client => Forward.client_string,
11
12
  }
12
13
 
@@ -22,6 +22,8 @@ module Forward
22
22
  else
23
23
  cleanup_and_exit!('Unable to create a tunnel. If this continues contact support@forwardhq.com')
24
24
  end
25
+
26
+ @tunnel
25
27
  end
26
28
 
27
29
  # The options Hash used by Net::SSH.
@@ -51,17 +53,15 @@ module Forward
51
53
  trap(:INT) { cleanup_and_exit!('closing tunnel and exiting...') }
52
54
 
53
55
  @client = Client.new(options)
56
+ @tunnel = @client.setup_tunnel
54
57
 
55
- @client.setup_tunnel
56
-
57
- Forward.log(:debug, "Starting remote forward on https://#{@client.tunnel.subdomain}.fwd.wf on port #{@client.tunnel.port}")
58
- puts "Forwarding port #{@client.options[:port]} at \033[04mhttps://#{@client.tunnel.subdomain}.fwd.wf\033[m\nCtrl-C to stop forwarding"
59
- Net::SSH.start(@client.tunnel.tunneler, Forward.ssh_user, @client.ssh_options) do |session|
60
- session.forward.remote(@client.options[:port], @client.options[:host], @client.tunnel.port)
58
+ Forward.log(:debug, "Starting remote forward at #{@tunnel.subdomain}.fwd.wf on port #{@tunnel.port}")
59
+ puts "Forwarding port #{@tunnel.hostport} at \033[04mhttps://#{@tunnel.subdomain}.fwd.wf\033[m\nCtrl-C to stop forwarding"
60
+ Net::SSH.start(@tunnel.tunneler, Forward.ssh_user, @client.ssh_options) do |session|
61
+ session.forward.remote(@tunnel.hostport, @tunnel.host, @tunnel.port)
61
62
  session.loop { watch_session(session) }
62
63
  end
63
64
 
64
- # cleanup_and_exit!
65
65
  rescue Net::SSH::AuthenticationFailed => e
66
66
  Forward.log(:fatal, "SSH Auth failed `#{e}'")
67
67
  cleanup_and_exit!("Authentication failed, try deleting `#{Forward::Config::CONFIG_PATH}' and giving it another go. If the problem continues, contact support@forwardhq.com")
@@ -6,6 +6,12 @@ module Forward
6
6
  attr_reader :id
7
7
  # The domain for the Tunnel.
8
8
  attr_reader :subdomain
9
+ # The host
10
+ attr_reader :host
11
+ # The vhost
12
+ attr_reader :vhost
13
+ # The hostport (local port)
14
+ attr_reader :hostport
9
15
  # The remote port.
10
16
  attr_reader :port
11
17
  # The tunneler host.
@@ -18,9 +24,12 @@ module Forward
18
24
  #
19
25
  # client - The Client instance.
20
26
  def initialize(options = {})
27
+ @host = options[:host]
21
28
  @response = Forward::Api::Tunnel.create(options)
22
29
  @id = @response[:_id]
23
30
  @subdomain = @response[:subdomain]
31
+ @vhost = @response[:vhost]
32
+ @hostport = @response[:hostport]
24
33
  @port = @response[:port]
25
34
  @tunneler = @response[:tunneler_public]
26
35
  @timeout = @response[:timeout]
@@ -1,3 +1,3 @@
1
1
  module Forward
2
- VERSION = '0.0.11'
2
+ VERSION = '0.0.12'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: forward
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.11
4
+ version: 0.0.12
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-01 00:00:00.000000000 Z
12
+ date: 2012-10-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json