Sha256: a5a1b694adda4bdae13bf5a51e2ece94816e880efb7005e8feffa188f4208d20

Contents?: true

Size: 1.41 KB

Versions: 7

Compression:

Stored size: 1.41 KB

Contents

=begin
    Copyright 2010-2014 Tasos Laskos <tasos.laskos@arachni-scanner.com>

    This file is part of the Arachni Framework project and is subject to
    redistribution and commercial restrictions. Please see the Arachni Framework
    web site for more information on licensing and terms of use.
=end

require 'arachni/rpc'

# @note Needs `ENV['WEB_SERVER_DISPATCHER']` in the format of `host:port`.
#
# {WebServerManager}-API-compatible client for the {WebServerDispatcher}.
#
# Delegates test webserver creation to the machine running {WebServerDispatcher},
# for hosts that lack support for fast servers (like Windows, which can't run
# Thin, Puma etc.).
#
# @author Tasos "Zapotek" Laskos <tasos.laskos@arachni-scanner.com>
class WebServerClient < Arachni::RPC::Proxy
    include Singleton

    def initialize( options = {} )
        @host, port = ENV['WEB_SERVER_DISPATCHER'].split( ':' )

        Arachni::Reactor.global.run_in_thread if !Arachni::Reactor.global.running?

        client = Arachni::RPC::Client.new( host: @host, port: port )
        super client, 'server'
    end

    def protocol_for( name )
        name.to_s.include?( 'https' ) ? 'https' : 'http'
    end

    def address_for( name )
        @host
    end

    def up?( name )
        Typhoeus.get(
            url_for( name, false ),
            ssl_verifypeer: false,
            ssl_verifyhost: 0,
            forbid_reuse:   true
        ).code != 0
    end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
arachni-1.0.6 spec/support/lib/web_server_client.rb
arachni-1.0.5 spec/support/lib/web_server_client.rb
arachni-1.0.4 spec/support/lib/web_server_client.rb
arachni-1.0.3 spec/support/lib/web_server_client.rb
arachni-1.0.2 spec/support/lib/web_server_client.rb
arachni-1.0.1 spec/support/lib/web_server_client.rb
arachni-1.0 spec/support/lib/web_server_client.rb