Class: Onionurigen::AddressFinder
- Inherits:
-
Object
- Object
- Onionurigen::AddressFinder
- Defined in:
- lib/onionurigen/address_finder.rb
Instance Attribute Summary collapse
-
#found ⇒ Object
readonly
Returns the value of attribute found.
-
#match ⇒ Object
readonly
Returns the value of attribute match.
-
#onion_url ⇒ Object
readonly
Returns the value of attribute onion_url.
-
#private_key ⇒ Object
readonly
Returns the value of attribute private_key.
-
#rsa ⇒ Object
readonly
Returns the value of attribute rsa.
Instance Method Summary collapse
- #found? ⇒ Boolean
-
#initialize(match, multi_threading = false) ⇒ AddressFinder
constructor
A new instance of AddressFinder.
- #multi_thread_process ⇒ Object
- #single_thread_process ⇒ Object
Constructor Details
#initialize(match, multi_threading = false) ⇒ AddressFinder
Returns a new instance of AddressFinder.
16 17 18 19 20 21 |
# File 'lib/onionurigen/address_finder.rb', line 16 def initialize(match, multi_threading = false) raise 'Invalid Pattern' unless [String, Regexp].include?(match.class) @found = false @match = match.class.eql?(String) ? /\A#{Regexp.quote(match.upcase)}/ : match multi_threading ? multi_thread_process : single_thread_process end |
Instance Attribute Details
#found ⇒ Object (readonly)
Returns the value of attribute found.
14 15 16 |
# File 'lib/onionurigen/address_finder.rb', line 14 def found @found end |
#match ⇒ Object (readonly)
Returns the value of attribute match.
14 15 16 |
# File 'lib/onionurigen/address_finder.rb', line 14 def match @match end |
#onion_url ⇒ Object (readonly)
Returns the value of attribute onion_url.
14 15 16 |
# File 'lib/onionurigen/address_finder.rb', line 14 def onion_url @onion_url end |
#private_key ⇒ Object (readonly)
Returns the value of attribute private_key.
14 15 16 |
# File 'lib/onionurigen/address_finder.rb', line 14 def private_key @private_key end |
#rsa ⇒ Object (readonly)
Returns the value of attribute rsa.
14 15 16 |
# File 'lib/onionurigen/address_finder.rb', line 14 def rsa @rsa end |
Instance Method Details
#found? ⇒ Boolean
43 44 45 |
# File 'lib/onionurigen/address_finder.rb', line 43 def found? @found end |
#multi_thread_process ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'lib/onionurigen/address_finder.rb', line 33 def multi_thread_process @rsa = Onionurigen::RSAGen.new @spki = Onionurigen::SPKI.new(@rsa) if @spki.encoded =~ @match @found = true @private_key = @rsa.private_key.to_pem_pkcs8 @onion_url = "http://#{@spki.encoded.downcase}.onion" end end |
#single_thread_process ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/onionurigen/address_finder.rb', line 23 def single_thread_process loop do @rsa = Onionurigen::RSAGen.new @spki = Onionurigen::SPKI.new(@rsa) break if @spki.encoded =~ @match end @private_key = @rsa.private_key.to_pem_pkcs8 @onion_url = "http://#{@spki.encoded.downcase}.onion" end |