Class: ReverseTunnel::CLI

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

Defined Under Namespace

Classes: Base, Client, Configurator, Global, Server

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(arguments = []) ⇒ CLI

Returns a new instance of CLI.



6
7
8
# File 'lib/reverse-tunnel/cli.rb', line 6

def initialize(arguments = [])
  @arguments = arguments
end

Instance Attribute Details

#argumentsObject

Returns the value of attribute arguments.



4
5
6
# File 'lib/reverse-tunnel/cli.rb', line 4

def arguments
  @arguments
end

Instance Method Details

#configurator_classObject



153
154
155
# File 'lib/reverse-tunnel/cli.rb', line 153

def configurator_class
  mode == "server" ? ReverseTunnel::CLI::Server : ReverseTunnel::CLI::Client
end

#configureObject



161
162
163
# File 'lib/reverse-tunnel/cli.rb', line 161

def configure
  Global.new(arguments).configure(self)
end

#debug=(debug) ⇒ Object



139
140
141
142
# File 'lib/reverse-tunnel/cli.rb', line 139

def debug=(debug)
  level = debug ? Logger::DEBUG : Logger::INFO
  ReverseTunnel.logger.level = level
end

#instanceObject



157
158
159
# File 'lib/reverse-tunnel/cli.rb', line 157

def instance
  configurator_class.configure(arguments)
end

#modeObject



10
11
12
# File 'lib/reverse-tunnel/cli.rb', line 10

def mode
  @mode ||= arguments.shift
end

#runObject



165
166
167
168
# File 'lib/reverse-tunnel/cli.rb', line 165

def run
  configure
  instance.start
end

#syslog=(syslog) ⇒ Object



144
145
146
147
148
149
150
151
# File 'lib/reverse-tunnel/cli.rb', line 144

def syslog=(syslog)
  if syslog
    syslog_logger = Syslog::Logger.new("rtunnel").tap do |logger|
      logger.level = ReverseTunnel.logger.level
    end
    ReverseTunnel.logger = syslog_logger
  end
end