Class: Arachni::Rest::Server

Inherits:
Sinatra::Base
  • Object
show all
Extended by:
UI::Output
Defined in:
lib/arachni/rest/server.rb,
lib/arachni/rest/server/instance_helpers.rb

Defined Under Namespace

Modules: InstanceHelpers

Constant Summary collapse

VALID_REPORT_FORMATS =
%w(json xml yaml html.zip)

Class Method Summary collapse

Methods included from UI::Output

caller_location, debug?, debug_level, debug_level_1?, debug_level_2?, debug_level_3?, debug_level_4?, debug_off, debug_on, disable_only_positives, error_buffer, error_log_fd, error_logfile, has_error_log?, included, log_error, mute, muted?, only_positives, only_positives?, print_bad, print_debug, print_debug_backtrace, print_debug_exception, print_debug_level_1, print_debug_level_2, print_debug_level_3, print_debug_level_4, print_error, print_error_backtrace, print_exception, print_info, print_line, print_ok, print_status, print_verbose, reroute_to_file, reroute_to_file?, reset_output_options, set_error_logfile, unmute, verbose?, verbose_off, verbose_on

Class Method Details

.run!(options) ⇒ Object


192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
# File 'lib/arachni/rest/server.rb', line 192

def run!( options )
    set :username, options[:username]
    set :password, options[:password]

    server = Puma::Server.new( self )
    server.min_threads = 0
    server.max_threads = 16

    ssl = false
    if options[:ssl_key] && options[:ssl_certificate]
        ctx = Puma::MiniSSL::Context.new

        ctx.key  = options[:ssl_key]
        ctx.cert = options[:ssl_certificate]

        if options[:ssl_ca]
            print_info 'CA provided, peer verification has been enabled.'

            ctx.ca          = options[:ssl_ca]
            ctx.verify_mode = Puma::MiniSSL::VERIFY_PEER |
                Puma::MiniSSL::VERIFY_FAIL_IF_NO_PEER_CERT
        else
            print_info 'CA missing, peer verification has been disabled.'
        end

        ssl = true
        server.binder.add_ssl_listener( options[:bind], options[:port], ctx )
    else
        ssl = false
        server.add_tcp_listener( options[:bind], options[:port] )
    end

    print_status "Listening on http#{'s' if ssl}://#{options[:bind]}:#{options[:port]}"

    begin
        server.run.join
    rescue Interrupt
        server.stop( true )
    end
end