Class: ReverseTunnel::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/reverse-tunnel/client.rb

Defined Under Namespace

Classes: ApiServer, LocalConnection, LocalConnections, Tunnel, TunnelConnection

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#api_hostObject

Returns the value of attribute api_host.



289
290
291
# File 'lib/reverse-tunnel/client.rb', line 289

def api_host
  @api_host
end

#api_portObject

Returns the value of attribute api_port.



289
290
291
# File 'lib/reverse-tunnel/client.rb', line 289

def api_port
  @api_port
end

#local_portObject

Returns the value of attribute local_port.



287
288
289
# File 'lib/reverse-tunnel/client.rb', line 287

def local_port
  @local_port
end

#server_hostObject

Returns the value of attribute server_host.



288
289
290
# File 'lib/reverse-tunnel/client.rb', line 288

def server_host
  @server_host
end

#server_portObject

Returns the value of attribute server_port.



288
289
290
# File 'lib/reverse-tunnel/client.rb', line 288

def server_port
  @server_port
end

#tokenObject

Returns the value of attribute token.



287
288
289
# File 'lib/reverse-tunnel/client.rb', line 287

def token
  @token
end

Instance Method Details

#startObject



269
270
271
272
273
274
# File 'lib/reverse-tunnel/client.rb', line 269

def start
  EventMachine.run do
    tunnel.start
    start_api
  end
end

#start_apiObject



276
277
278
279
280
281
# File 'lib/reverse-tunnel/client.rb', line 276

def start_api
  if api_host
    ReverseTunnel.logger.info "Wait api requests #{api_host}:#{api_port}"
    EventMachine.start_server api_host, api_port, ApiServer, tunnel
  end
end

#tunnelObject



283
284
285
# File 'lib/reverse-tunnel/client.rb', line 283

def tunnel
  @tunnel ||= Tunnel.new(:token => token, :local_port => local_port, :host => server_host, :port => server_port)
end