Module: Caldecott::Client::Tunnel

Defined in:
lib/caldecott/client/tunnel.rb

Class Method Summary collapse

Class Method Details

.start(logger, tun_url, dst_host, dst_port, auth_token) ⇒ Object

Note: I wanted to do this with self#new but had issues with getting send :initialize to figure out the right number of arguments



11
12
13
14
15
16
17
18
19
20
# File 'lib/caldecott/client/tunnel.rb', line 11

def self.start(logger, tun_url, dst_host, dst_port, auth_token)
  case Addressable::URI.parse(tun_url).normalized_scheme
  when "http", "https"
    HttpTunnel.new(logger, tun_url, dst_host, dst_port, auth_token)
  when "ws"
    WebSocketTunnel.new(logger, tun_url, dst_host, dst_port, auth_token)
  else
    raise "invalid url"
  end
end