Class: Arachni::RPC::Client::Instance

Inherits:
Object
  • Object
show all
Defined in:
lib/arachni/rpc/client/instance.rb,
lib/arachni/rpc/client/instance/service.rb,
lib/arachni/rpc/client/instance/framework.rb

Overview

RPC client for remote instances spawned by a remote dispatcher

Defined Under Namespace

Classes: Framework, Service

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options, url, token = nil) ⇒ Instance

Returns a new instance of Instance.



54
55
56
57
58
59
60
61
62
63
64
# File 'lib/arachni/rpc/client/instance.rb', line 54

def initialize( options, url, token = nil )
    @token  = token
    @client = Base.new( options, url, token )

    @framework = Framework.new( @client )
    @service   = Service.new( @client )

    @options   = Proxy.new( @client, 'options' )
    @checks    = Proxy.new( @client, 'checks' )
    @plugins   = Proxy.new( @client, 'plugins' )
end

Instance Attribute Details

#checksObject (readonly)

Returns the value of attribute checks.



22
23
24
# File 'lib/arachni/rpc/client/instance.rb', line 22

def checks
  @checks
end

#frameworkObject (readonly)

Returns the value of attribute framework.



21
22
23
# File 'lib/arachni/rpc/client/instance.rb', line 21

def framework
  @framework
end

#optionsObject (readonly)

Returns the value of attribute options.



20
21
22
# File 'lib/arachni/rpc/client/instance.rb', line 20

def options
  @options
end

#pluginsObject (readonly)

Returns the value of attribute plugins.



23
24
25
# File 'lib/arachni/rpc/client/instance.rb', line 23

def plugins
  @plugins
end

#serviceObject (readonly)

Returns the value of attribute service.



24
25
26
# File 'lib/arachni/rpc/client/instance.rb', line 24

def service
  @service
end

Class Method Details

.when_ready(url, token, &block) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/arachni/rpc/client/instance.rb', line 31

def when_ready( url, token, &block )
    options     = OpenStruct.new
    options.rpc = OpenStruct.new( Arachni::Options.to_h[:rpc] )
    options.rpc.client_max_retries   = 0
    options.rpc.connection_pool_size = 1

    client = new( options, url, token )
    Reactor.global.delay( 0.1 ) do |task|
        client.service.alive? do |r|
            if r.rpc_exception?
                Reactor.global.delay( 0.1, &task )
                next
            end

            client.close

            block.call
        end
    end
end

Instance Method Details

#closeObject



74
75
76
# File 'lib/arachni/rpc/client/instance.rb', line 74

def close
    @client.close
end

#tokenObject



70
71
72
# File 'lib/arachni/rpc/client/instance.rb', line 70

def token
    @token
end

#urlObject



78
79
80
# File 'lib/arachni/rpc/client/instance.rb', line 78

def url
    @client.url
end

#when_ready(&block) ⇒ Object



66
67
68
# File 'lib/arachni/rpc/client/instance.rb', line 66

def when_ready( &block )
    self.class.when_ready( url, token, &block )
end