Support IPv6 addresses

This also checks for IPv6-mapped IPv4 addresses.

Closes #1.
This commit is contained in:
Niklas Haas 2015-06-18 06:09:46 +02:00
parent c3331d19ca
commit d2747549fe
No known key found for this signature in database
GPG Key ID: 3BA77D4BFDB10BCE
2 changed files with 4 additions and 2 deletions

View File

@ -85,7 +85,7 @@ module Dyndnsd
# malformed myip?
begin
IPAddr.new(params["myip"], Socket::AF_INET)
IPAddr.new(params["myip"])
rescue ArgumentError
params["myip"] = env["REMOTE_ADDR"]
end

View File

@ -19,8 +19,10 @@ module Dyndnsd
out << "@ IN NS #{@dns}"
out << ""
zone['hosts'].each do |hostname,ip|
ip = IPAddr.new(ip).native
type = ip.ipv6? ? "AAAA" : "A"
name = hostname.chomp('.' + @domain)
out << "#{name} IN A #{ip}"
out << "#{name} IN #{type} #{ip}"
end
out << ""
out << @additional_zone_content