Skip to content

Commit

Permalink
improvement: 'resolv', '~> 0.4.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
thekuwayama committed May 4, 2024
1 parent 7937877 commit f42d7ad
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ gem 'rake'
group :development do
gem 'byebug'
gem 'http_parser.rb'
gem 'resolv', '~> 0.4.0'
gem 'rspec', '3.9.0'
gem 'rubocop', '0.78.0'
gem 'svcb_rr_patch'
gem 'webrick'
end

Expand Down
11 changes: 8 additions & 3 deletions example/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

$LOAD_PATH << __dir__ + '/../lib'

require 'resolv'
require 'socket'
require 'time'
require 'uri'
require 'webrick'

require 'ech_config'
require 'http/parser'
require 'svcb_rr_patch'

require 'tttls1.3'

Expand Down Expand Up @@ -100,8 +100,13 @@ def resolve_echconfig(hostname)
hostname,
Resolv::DNS::Resource::IN::HTTPS
)
ech = 5
raise "failed to resolve echconfig via #{hostname} HTTPS RR" \
if rr.first.nil? || !rr.first.svc_params.keys.include?('ech')
if rr.first.nil? || rr.first.params[ech].nil?

rr.first.svc_params['ech'].echconfiglist.first
octet = rr.first.params[ech].value
raise 'failed to parse ECHConfigs' \
unless octet.length == octet.slice(0, 2).unpack1('n') + 2

ECHConfig.decode_vectors(octet.slice(2..)).first
end

0 comments on commit f42d7ad

Please sign in to comment.