Skip to content

Commit

Permalink
Merge branch 'ruby:master' into handle-nameserver-servfail-reply
Browse files Browse the repository at this point in the history
  • Loading branch information
BobSilent authored Nov 15, 2023
2 parents 8146134 + b28a266 commit 048a670
Show file tree
Hide file tree
Showing 11 changed files with 41 additions and 1,176 deletions.
11 changes: 9 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,22 @@ name: test
on: [push, pull_request]

jobs:
ruby-versions:
uses: ruby/actions/.github/workflows/ruby_versions.yml@master
with:
engine: cruby
min_version: 2.5

build:
needs: ruby-versions
name: build (${{ matrix.ruby }} / ${{ matrix.os }})
strategy:
matrix:
ruby: [ '3.0', 2.7, 2.6, 2.5, head ]
ruby: ${{ fromJson(needs.ruby-versions.outputs.versions) }}
os: [ ubuntu-latest, macos-latest ]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@
/pkg/
/spec/reports/
/tmp/

Gemfile.lock
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
source "https://rubygems.org"

gemspec

gem "rake"
gem "test-unit"
gem "test-unit-ruby-core"
7 changes: 0 additions & 7 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,4 @@ Rake::TestTask.new(:test) do |t|
t.test_files = FileList["test/**/test_*.rb"]
end

task :sync_tool do
require 'fileutils'
FileUtils.cp "../ruby/tool/lib/core_assertions.rb", "./test/lib"
FileUtils.cp "../ruby/tool/lib/envutil.rb", "./test/lib"
FileUtils.cp "../ruby/tool/lib/find_executable.rb", "./test/lib"
end

task :default => :test
16 changes: 9 additions & 7 deletions lib/resolv.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@

class Resolv

VERSION = "0.2.2"

##
# Looks up the first IP address for +name+.

Expand Down Expand Up @@ -198,7 +200,7 @@ def lazy_initialize # :nodoc:
next unless addr
@addr2name[addr] = [] unless @addr2name.include? addr
@addr2name[addr] << hostname
@addr2name[addr] += aliases
@addr2name[addr].concat(aliases)
@name2addr[hostname] = [] unless @name2addr.include? hostname
@name2addr[hostname] << addr
aliases.each {|n|
Expand Down Expand Up @@ -969,7 +971,7 @@ def Config.parse_resolv_conf(filename)
next unless keyword
case keyword
when 'nameserver'
nameserver += args
nameserver.concat(args)
when 'domain'
next if args.empty?
search = [args[0]]
Expand Down Expand Up @@ -1491,14 +1493,14 @@ def put_string_list(ds)
}
end

def put_name(d)
put_labels(d.to_a)
def put_name(d, compress: true)
put_labels(d.to_a, compress: compress)
end

def put_labels(d)
def put_labels(d, compress: true)
d.each_index {|i|
domain = d[i..-1]
if idx = @names[domain]
if compress && idx = @names[domain]
self.put_pack("n", 0xc000 | idx)
return
else
Expand Down Expand Up @@ -2332,7 +2334,7 @@ def encode_rdata(msg) # :nodoc:
msg.put_pack("n", @priority)
msg.put_pack("n", @weight)
msg.put_pack("n", @port)
msg.put_name(@target)
msg.put_name(@target, compress: false)
end

def self.decode_rdata(msg) # :nodoc:
Expand Down
11 changes: 9 additions & 2 deletions resolv.gemspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
name = File.basename(__FILE__, ".gemspec")
version = ["lib", Array.new(name.count("-")+1).join("/")].find do |dir|
break File.foreach(File.join(__dir__, dir, "#{name.tr('-', '/')}.rb")) do |line|
/^\s*VERSION\s*=\s*"(.*)"/ =~ line and break $1
end rescue nil
end

Gem::Specification.new do |spec|
spec.name = "resolv"
spec.version = "0.2.1"
spec.name = name
spec.version = version
spec.authors = ["Tanaka Akira"]
spec.email = ["[email protected]"]

Expand Down
Loading

0 comments on commit 048a670

Please sign in to comment.