Method: Arachni::RPC::Server::Dispatcher::Node#add_neighbour

Defined in:
lib/arachni/rpc/server/dispatcher/node.rb

#add_neighbour(node_url, propagate = false) ⇒ Object

Adds a neighbour to the peer list.

Parameters:

  • node_url (String)

    URL of a neighbouring node.

  • propagate (Boolean) (defaults to: false)

    Whether or not to announce the new node to the peers.



93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/arachni/rpc/server/dispatcher/node.rb', line 93

def add_neighbour( node_url, propagate = false )
    # we don't want ourselves in the Set
    return false if node_url == @url
    return false if @neighbours.include?( node_url )

    print_status "Adding neighbour: #{node_url}"

    @neighbours << node_url
    log_updated_neighbours
    announce( node_url ) if propagate

    connect_to_peer( node_url ).add_neighbour( @url, propagate ) do |res|
        next if !res.rpc_exception?
        add_dead_neighbour( node_url )
        print_status "Neighbour seems dead: #{node_url}"
    end
    true
end