Class: Zwiebel::HiddenService::InnerLayer
- Inherits:
-
Object
- Object
- Zwiebel::HiddenService::InnerLayer
- Defined in:
- lib/zwiebel/hidden_service/inner_layer.rb
Constant Summary collapse
- FIELDS =
%w(create2-formats intro-auth-required single-onion-service introduction-point).freeze
- INTRODUCTION_POINT_FIELDS =
%w(onion-key auth-key enc-key enc-key-cert legacy-key legacy-key-cert).freeze
Instance Attribute Summary collapse
-
#decrypted_data ⇒ Object
Returns the value of attribute decrypted_data.
-
#introduction_points ⇒ Object
Returns the value of attribute introduction_points.
Instance Method Summary collapse
- #create2_formats ⇒ Object
- #encrypted ⇒ Object
-
#initialize(decrypted_data:) ⇒ InnerLayer
constructor
A new instance of InnerLayer.
- #intro_auth_required ⇒ Object
- #parse ⇒ Object
- #single_onion_service? ⇒ Boolean
Constructor Details
#initialize(decrypted_data:) ⇒ InnerLayer
Returns a new instance of InnerLayer.
23 24 25 26 27 |
# File 'lib/zwiebel/hidden_service/inner_layer.rb', line 23 def initialize(decrypted_data:) @decrypted_data = decrypted_data @introduction_points = [] parse end |
Instance Attribute Details
#decrypted_data ⇒ Object
Returns the value of attribute decrypted_data.
21 22 23 |
# File 'lib/zwiebel/hidden_service/inner_layer.rb', line 21 def decrypted_data @decrypted_data end |
#introduction_points ⇒ Object
Returns the value of attribute introduction_points.
21 22 23 |
# File 'lib/zwiebel/hidden_service/inner_layer.rb', line 21 def introduction_points @introduction_points end |
Instance Method Details
#create2_formats ⇒ Object
64 65 66 |
# File 'lib/zwiebel/hidden_service/inner_layer.rb', line 64 def create2_formats @inner_layer["create2-formats"].to_i end |
#encrypted ⇒ Object
76 77 78 |
# File 'lib/zwiebel/hidden_service/inner_layer.rb', line 76 def encrypted @inner_layer["encrypted"] end |
#intro_auth_required ⇒ Object
68 69 70 |
# File 'lib/zwiebel/hidden_service/inner_layer.rb', line 68 def intro_auth_required @inner_layer["intro-auth-required"] end |
#parse ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/zwiebel/hidden_service/inner_layer.rb', line 29 def parse @inner_layer = {} layer_current_field = nil current_introduction_point_data = nil decrypted_data.each_line do |line| line_field = line.split(" ")[0] if FIELDS.include?(line_field) layer_current_field = line_field if layer_current_field == "introduction-point" introduction_points.push(IntroductionPoint.new(data: current_introduction_point_data)) unless current_introduction_point_data.nil? current_introduction_point_data = { layer_current_field => line.split(" ")[1] } else if @inner_layer[layer_current_field].nil? && !line.split(" ")[1..-1].nil? @inner_layer[layer_current_field] = line.split(" ")[1..-1].join(" ") elsif !@inner_layer[layer_current_field].nil? && !line.split(" ")[1..-1].nil? @inner_layer[layer_current_field] += line.split(" ")[1..-1].join(" ") elsif layer_current_field == "single-onion-service" @inner_layer[layer_current_field] = true else @inner_layer[layer_current_field] = "" end end elsif INTRODUCTION_POINT_FIELDS.include?(line_field) || INTRODUCTION_POINT_FIELDS.include?(layer_current_field) layer_current_field = line_field unless !INTRODUCTION_POINT_FIELDS.include?(line_field) if current_introduction_point_data[layer_current_field].nil? current_introduction_point_data[layer_current_field] = line.split(" ")[1..-1].join(" ") else current_introduction_point_data[layer_current_field] += line end end end introduction_points.push(IntroductionPoint.new(data: current_introduction_point_data)) unless current_introduction_point_data.nil? end |
#single_onion_service? ⇒ Boolean
72 73 74 |
# File 'lib/zwiebel/hidden_service/inner_layer.rb', line 72 def single_onion_service? !!@inner_layer["single-onion-service"] end |