Class: Arachni::UI::Web::InstanceManager

Inherits:
Object
  • Object
show all
Includes:
Utilities
Defined in:
lib/arachni/ui/web/instance_manager.rb

Overview

Provides methods for instance management.

@author: Tasos “Zapotek” Laskos

<[email protected]>
<[email protected]>

@version: 0.1

Instance Method Summary collapse

Methods included from Utilities

#escape, #escape_hash, #parse_datetime, #port_to_url, #remove_proto, #unescape, #unescape_hash

Constructor Details

#initialize(opts, settings) ⇒ InstanceManager

Returns a new instance of InstanceManager.



31
32
33
34
# File 'lib/arachni/ui/web/instance_manager.rb', line 31

def initialize( opts, settings )
    @opts     = opts
    @settings = settings
end

Instance Method Details

#connect(url, session = nil, token = nil) ⇒ Arachni::RPC::Client::Instance

Provides an easy way to connect to an instance

Parameters:

  • url (String)
  • session (Hash) (defaults to: nil)

    session of the current user (optional)

  • token (String) (defaults to: nil)

    authentication token (optional)

Returns:



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/arachni/ui/web/instance_manager.rb', line 45

def connect( url, session = nil, token = nil )
    #
    # Sync up the session authentication tokens with the ones in the
    # class variables.
    #
    # This will allow users to still connect to instances even if they
    # shutdown the WebUI or remove their cookies.
    #
    @@tokens ||= {}
    session['tokens'] ||= {} if session
    @@tokens[url] = token if token

    session['tokens'].merge!( @@tokens ) if session
    @@tokens.merge!( session['tokens'] ) if session
    session['tokens'].merge!( @@tokens ) if session

    tmp_token = session ? session['tokens'][url] : @@tokens[url]

    Arachni::RPC::Client::Instance.new( @opts, url, tmp_token )
end