class LocalTunnel::Tunnel
Public Class Methods
new(domain: nil, debug: false)
click to toggle source
# File lib/local_tunnel.rb, line 158 def initialize(domain: nil, debug: false) @domain = domain @logger = self.class.logger.dup @logger.level = Logger::DEBUG if debug end
Private Class Methods
logger()
click to toggle source
# File lib/local_tunnel.rb, line 217 def logger @logger ||= LocalTunnel.logger.dup end
logger=(value)
click to toggle source
# File lib/local_tunnel.rb, line 221 def logger=(value) @logger = value end
Public Instance Methods
create(port)
click to toggle source
# File lib/local_tunnel.rb, line 179 def create(port) assign_url! logger.debug("#{url}, #{max_conn_count}") @max_conn_count.times do |i| @conns[i] = TunnelConn.new(URI(SERVER).host, @port, port, id: i) @conns[i].start end end
max_conn_count()
click to toggle source
# File lib/local_tunnel.rb, line 174 def max_conn_count assign_url! unless defined?(@max_conn_count) @max_conn_count end
port()
click to toggle source
# File lib/local_tunnel.rb, line 169 def port assign_url! unless defined?(@port) @port end
start(port)
click to toggle source
# File lib/local_tunnel.rb, line 188 def start(port) create(port) self end
stop()
click to toggle source
# File lib/local_tunnel.rb, line 197 def stop @conns.compact.each(&:stop) end
url()
click to toggle source
# File lib/local_tunnel.rb, line 164 def url assign_url! unless defined?(@url) @url end
wait()
click to toggle source
# File lib/local_tunnel.rb, line 193 def wait @conns.compact.each(&:wait) end
Private Instance Methods
assign_url!()
click to toggle source
# File lib/local_tunnel.rb, line 207 def assign_url! info = LocalTunnel.get_assigned_url(@domain) @url = info.url @max_conn_count = info.max_conn_count @port = info.port @conns = Array.new(@max_conn_count) info end
logger()
click to toggle source
# File lib/local_tunnel.rb, line 203 def logger @logger end