Class: Onion::Router

Inherits:
Object
  • Object
show all
Defined in:
lib/onion/elements/router.rb

Overview

Onion::Router is a Ruby object representing a Tor router.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(nick, fingerprint, status_flags) ⇒ Router

Returns a new instance of Router.



5
6
7
8
9
# File 'lib/onion/elements/router.rb', line 5

def initialize(nick, fingerprint, status_flags)
  @nick         = nick         # Nickname of the router.
  @fingerprint  = fingerprint  # Fingerprint of the router.
  @status_flags = status_flags # Array of strings with status flags.
end

Instance Attribute Details

#fingerprintObject (readonly)

Returns the value of attribute fingerprint.



4
5
6
# File 'lib/onion/elements/router.rb', line 4

def fingerprint
  @fingerprint
end

#nickObject (readonly)

Returns the value of attribute nick.



4
5
6
# File 'lib/onion/elements/router.rb', line 4

def nick
  @nick
end

#status_flagsObject (readonly)

Returns the value of attribute status_flags.



4
5
6
# File 'lib/onion/elements/router.rb', line 4

def status_flags
  @status_flags
end

Instance Method Details

#exit?Boolean

Returns true if the router is an exit router, false otherwise.

Returns:

  • (Boolean)


17
18
19
# File 'lib/onion/elements/router.rb', line 17

def exit?
  @status_flags and @status_flags.include?("Exit")
end

#guard?Boolean

Returns true if the rotuer is a guard router, false otherwise.

Returns:

  • (Boolean)


12
13
14
# File 'lib/onion/elements/router.rb', line 12

def guard?
  @status_flags and @status_flags.include?("Guard")
end