Class: Forward::Tunnel
Constant Summary
Constants included from Common
Instance Attribute Summary collapse
-
#cname ⇒ Object
readonly
The CNAME for the Tunnel.
-
#host ⇒ Object
readonly
The host to forward requests to.
-
#id ⇒ Object
readonly
The Tunnel resource ID.
-
#last_active_at ⇒ Object
Returns the value of attribute last_active_at.
-
#no_auth ⇒ Object
readonly
Returns the value of attribute no_auth.
-
#password ⇒ Object
readonly
Returns the value of attribute password.
-
#port ⇒ Object
readonly
The port to forward requests to.
-
#requests ⇒ Object
readonly
Returns the value of attribute requests.
-
#socket ⇒ Object
readonly
Returns the value of attribute socket.
-
#socket_url ⇒ Object
readonly
Returns the value of attribute socket_url.
-
#subdomain ⇒ Object
readonly
The domain for the Tunnel.
-
#timeout ⇒ Object
readonly
The timeout.
-
#tunneler ⇒ Object
readonly
The tunneler host.
-
#url ⇒ Object
readonly
The public hostname/subdomain url for the tunnel.
-
#username ⇒ Object
readonly
Authentication for tunnel.
Instance Method Summary collapse
- #authority ⇒ Object
- #destroy(&block) ⇒ Object
-
#initialize(attributes = {}) ⇒ Tunnel
constructor
Initializes a Tunnel instance for the Client and requests a tunnel from API.
- #open? ⇒ Boolean
- #ready! ⇒ Object
- #track_activity! ⇒ Object
Methods included from Common
#config, #exit_with_error, #exit_with_message, #logged_in?, #logger, #os, #stop_reactor_and_exit, #windows?
Constructor Details
#initialize(attributes = {}) ⇒ Tunnel
Initializes a Tunnel instance for the Client and requests a tunnel from API.
client - The Client instance.
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/forward/tunnel.rb', line 36 def initialize(attributes = {}) logger.debug "[tunnel] initializing with: #{attributes.inspect}" @attributes = attributes @id = attributes[:id] @host = attributes[:vhost] @port = attributes[:hostport] @subdomain_prefix = attributes[:subdomain_prefix] @username = attributes[:username] @password = attributes[:password] @no_auth = attributes[:no_auth] @static_path = attributes[:static_path] @cname = attributes[:cname] @timeout = attributes[:timeout] @tunneler = attributes[:tunneler] @url = attributes[:url] @requests = {} @open = false @socket = Socket.new(self) end |
Instance Attribute Details
#cname ⇒ Object (readonly)
The CNAME for the Tunnel
10 11 12 |
# File 'lib/forward/tunnel.rb', line 10 def cname @cname end |
#host ⇒ Object (readonly)
The host to forward requests to
12 13 14 |
# File 'lib/forward/tunnel.rb', line 12 def host @host end |
#id ⇒ Object (readonly)
The Tunnel resource ID
6 7 8 |
# File 'lib/forward/tunnel.rb', line 6 def id @id end |
#last_active_at ⇒ Object
Returns the value of attribute last_active_at.
30 31 32 |
# File 'lib/forward/tunnel.rb', line 30 def last_active_at @last_active_at end |
#no_auth ⇒ Object (readonly)
Returns the value of attribute no_auth.
18 19 20 |
# File 'lib/forward/tunnel.rb', line 18 def no_auth @no_auth end |
#password ⇒ Object (readonly)
Returns the value of attribute password.
17 18 19 |
# File 'lib/forward/tunnel.rb', line 17 def password @password end |
#port ⇒ Object (readonly)
The port to forward requests to
14 15 16 |
# File 'lib/forward/tunnel.rb', line 14 def port @port end |
#requests ⇒ Object (readonly)
Returns the value of attribute requests.
28 29 30 |
# File 'lib/forward/tunnel.rb', line 28 def requests @requests end |
#socket ⇒ Object (readonly)
Returns the value of attribute socket.
26 27 28 |
# File 'lib/forward/tunnel.rb', line 26 def socket @socket end |
#socket_url ⇒ Object (readonly)
Returns the value of attribute socket_url.
27 28 29 |
# File 'lib/forward/tunnel.rb', line 27 def socket_url @socket_url end |
#subdomain ⇒ Object (readonly)
The domain for the Tunnel
8 9 10 |
# File 'lib/forward/tunnel.rb', line 8 def subdomain @subdomain end |
#timeout ⇒ Object (readonly)
The timeout
24 25 26 |
# File 'lib/forward/tunnel.rb', line 24 def timeout @timeout end |
#tunneler ⇒ Object (readonly)
The tunneler host
22 23 24 |
# File 'lib/forward/tunnel.rb', line 22 def tunneler @tunneler end |
#url ⇒ Object (readonly)
The public hostname/subdomain url for the tunnel
20 21 22 |
# File 'lib/forward/tunnel.rb', line 20 def url @url end |
#username ⇒ Object (readonly)
Authentication for tunnel
16 17 18 |
# File 'lib/forward/tunnel.rb', line 16 def username @username end |
Instance Method Details
#authority ⇒ Object
73 74 75 76 77 78 79 80 |
# File 'lib/forward/tunnel.rb', line 73 def @authority ||= begin = "#{host}" << ":#{port}" unless port == 80 end end |
#destroy(&block) ⇒ Object
69 70 71 |
# File 'lib/forward/tunnel.rb', line 69 def destroy(&block) API::Tunnel.destroy(id, &block) end |
#open? ⇒ Boolean
65 66 67 |
# File 'lib/forward/tunnel.rb', line 65 def open? @open end |
#ready! ⇒ Object
56 57 58 59 60 61 62 63 |
# File 'lib/forward/tunnel.rb', line 56 def ready! logger.debug '[tunnel] opened successfully' @open = true copy_url_to_clipboard open_url_in_browser end |
#track_activity! ⇒ Object
82 83 84 |
# File 'lib/forward/tunnel.rb', line 82 def track_activity! self.last_active_at = Time.now.to_i end |