Class: Forward::Command::Tunnel

Inherits:
Base
  • Object
show all
Defined in:
lib/forward/command/tunnel.rb

Constant Summary collapse

BASIC_AUTH_REGEX =
/\A[^\s:]+:[^\s:]+\z/i.freeze
CNAME_REGEX =
/\A[a-z0-9]+(?:[\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}\z/i.freeze
SUBDOMAIN_PREFIX_REGEX =
/\A[a-z0-9]{1}[a-z0-9\-]+\z/i.freeze
STATIC_HOST =
'127.0.0.1'.freeze
STATIC_PORT =
32645.freeze
DEFAULT_OPTIONS =
{
  host: 'localhost',
  port: 80
}

Constants included from Forward::Common

Forward::Common::EMAIL_REGEX

Instance Attribute Summary

Attributes inherited from Base

#args, #options

Instance Method Summary collapse

Methods inherited from Base

#initialize, run

Methods included from Forward::Common

#config, #exit_with_error, #exit_with_message, #logged_in?, #logger, #os, #stop_reactor_and_exit, #windows?

Constructor Details

This class inherits a constructor from Forward::Command::Base

Instance Method Details

#startObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/forward/command/tunnel.rb', line 14

def start
  print_help_and_exit! if !forwardfile? && @args.empty?

  config.create_or_load
  @options.merge!(DEFAULT_OPTIONS)
  parse_forwardfile
  parse_forwarded

  @options[:subdomain_prefix] = @args[1] if @args.length > 1
  @options[:no_auth]          = @options.fetch(:'no-auth', nil)

  validate :port, :auth, :cname, :subdomain_prefix

  client do
    authenticate_user do
      start_static_server if @options[:static_path]
      open_tunnel
    end
  end
end