Class: SvcbRrPatch::SvcParams::Alpn
- Inherits:
-
Object
- Object
- SvcbRrPatch::SvcParams::Alpn
- Defined in:
- lib/svcb_rr_patch/svc_params/alpn.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#protocols ⇒ Object
readonly
Returns the value of attribute protocols.
Class Method Summary collapse
-
.decode(octet) ⇒ Object
:nodec:.
-
.decode_protocols(octet) ⇒ Object
:nodoc:.
Instance Method Summary collapse
- #encode ⇒ String
-
#initialize(protocols) ⇒ Alpn
constructor
A new instance of Alpn.
-
#to_s ⇒ Object
:nodoc:.
Constructor Details
#initialize(protocols) ⇒ Alpn
Returns a new instance of Alpn.
7 8 9 |
# File 'lib/svcb_rr_patch/svc_params/alpn.rb', line 7 def initialize(protocols) @protocols = protocols end |
Instance Attribute Details
#protocols ⇒ Object (readonly)
Returns the value of attribute protocols.
4 5 6 |
# File 'lib/svcb_rr_patch/svc_params/alpn.rb', line 4 def protocols @protocols end |
Class Method Details
.decode(octet) ⇒ Object
:nodec:
34 35 36 37 |
# File 'lib/svcb_rr_patch/svc_params/alpn.rb', line 34 def self.decode(octet) protocols = decode_protocols(octet) new(protocols) end |
.decode_protocols(octet) ⇒ Object
:nodoc:
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/svcb_rr_patch/svc_params/alpn.rb', line 17 def self.decode_protocols(octet) protocols = [] i = 0 while i < octet.length raise ::Resolv::DNS::DecodeError if i + 1 > octet.length id_len = octet.slice(i, 1).unpack1('C1') i += 1 protocols << octet.slice(i, id_len) i += id_len end raise ::Resolv::DNS::DecodeError if i != octet.length protocols end |
Instance Method Details
#encode ⇒ String
12 13 14 |
# File 'lib/svcb_rr_patch/svc_params/alpn.rb', line 12 def encode @protocols.map { |p| [p.length].pack('C') + p }.join end |
#to_s ⇒ Object
:nodoc:
40 41 42 |
# File 'lib/svcb_rr_patch/svc_params/alpn.rb', line 40 def to_s @protocols.join(',') end |