Skip to content
This repository has been archived by the owner on Dec 7, 2018. It is now read-only.

Add support for un-encoded IDNs #14

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions celluloid-dns.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Gem::Specification.new do |spec|
spec.add_dependency("celluloid", "~> 0.17.3")
spec.add_dependency("celluloid-io", "~> 0.17.3")
spec.add_dependency("timers", "~> 4.1.0")
spec.add_dependency("addressable", "~> 2.4.0")

spec.add_development_dependency "bundler", "~> 1.3"
spec.add_development_dependency "process-daemon", "~> 1.0.0"
Expand Down
2 changes: 2 additions & 0 deletions lib/celluloid/dns/resolver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

require 'securerandom'
require 'celluloid/io'
require 'addressable'

module Celluloid::DNS
class InvalidProtocolError < StandardError
Expand Down Expand Up @@ -71,6 +72,7 @@ def fully_qualified_name(name)
end

# ..else if we have a string, we need to do some basic processing:
name = Addressable::IDNA.to_ascii(name) unless name.ascii_only?
if name.end_with? '.'
return Resolv::DNS::Name.create(name)
else
Expand Down
16 changes: 16 additions & 0 deletions spec/celluloid/dns/resolver_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -148,5 +148,21 @@ def handle_connection(socket)

expect(addresses.size).to be > 0
end

it "should resolve punycode encoded IDNs" do
resolver = Celluloid::DNS::Resolver.new([[:udp, "8.8.8.8", 53], [:tcp, "8.8.8.8", 53]])

addresses = resolver.addresses_for('xn--80ajiqg.xn--90ae')

expect(addresses.size).to be > 0
end

it "should resolve raw UTF-8 IDNs" do
resolver = Celluloid::DNS::Resolver.new([[:udp, "8.8.8.8", 53], [:tcp, "8.8.8.8", 53]])

addresses = resolver.addresses_for('имена.бг')

expect(addresses.size).to be > 0
end
end
end