Class: Net::DNS::RR::A
- Inherits:
-
Net::DNS::RR
- Object
- Net::DNS::RR
- Net::DNS::RR::A
- Defined in:
- lib/Net/DNS/RR/A.rb
Overview
NAME
Net::DNS::RR::A - DNS A resource record
DESCRIPTION
Class for DNS Address (A) resource records.
head1 COPYRIGHT
Copyright © 1997-2002 Michael Fuhr.
Portions Copyright © 2002-2004 Chris Reinhardt.
All rights reserved. This program is free software; you may redistribute it and/or modify it under the same terms as Perl itself.
head1 SEE ALSO
Net::DNS, Net::DNS::Resolver, Net::DNS::Packet, Net::DNS::Header, Net::DNS::Question, Net::DNS::RR, RFC 1035 Section 3.4.1
Constant Summary
Constants inherited from Net::DNS::RR
Instance Attribute Summary collapse
-
#address ⇒ Object
Returns the RR’s address field.
Attributes inherited from Net::DNS::RR
#name, #rdata, #rdlength, #rrclass, #ttl, #type
Class Method Summary collapse
Instance Method Summary collapse
- #inet_aton(ip) ⇒ Object
- #inet_ntoa(n) ⇒ Object
- #new_from_data(data, offset) ⇒ Object
- #new_from_hash(values) ⇒ Object
- #new_from_string(string) ⇒ Object
- #rdatastr ⇒ Object
- #rr_rdata(*args) ⇒ Object
Methods inherited from Net::DNS::RR
#_canonicalRdata, #_canonicaldata, _get_subclass, _name2wire, #_name2wire, build_regex, create, #create_rrsort_func, #data, #get_rrsort_func, #init, #init_rrsort_func, #inspect, new_from_data, new_from_hash, new_from_string, #set_rrsort_func
Instance Attribute Details
#address ⇒ Object
Returns the RR’s address field.
print "address = ", rr.address, "\n"
46 47 48 |
# File 'lib/Net/DNS/RR/A.rb', line 46 def address @address end |
Class Method Details
.inet_aton(ip) ⇒ Object
50 51 52 53 |
# File 'lib/Net/DNS/RR/A.rb', line 50 def A.inet_aton ip ret = ip.split(/\./).map{|c| c.to_i}.pack("C*") # .unpack("N").first return ret end |
.inet_ntoa(n) ⇒ Object
57 58 59 60 |
# File 'lib/Net/DNS/RR/A.rb', line 57 def A.inet_ntoa n ret= n.unpack("C*").join "." return ret end |
Instance Method Details
#inet_aton(ip) ⇒ Object
47 48 49 |
# File 'lib/Net/DNS/RR/A.rb', line 47 def inet_aton ip A.inet_aton ip end |
#inet_ntoa(n) ⇒ Object
54 55 56 |
# File 'lib/Net/DNS/RR/A.rb', line 54 def inet_ntoa n A.inet_ntoa n end |
#new_from_data(data, offset) ⇒ Object
75 76 77 78 79 80 81 |
# File 'lib/Net/DNS/RR/A.rb', line 75 def new_from_data(data, offset) if (@rdlength > 0) @address = inet_ntoa(data[offset, 4]); # @address = IPAddr.new_ntoh(data[offset, 4]) # IPAddr.new(data[offset, 4], Socket::AF_INET).to_s end end |
#new_from_hash(values) ⇒ Object
82 83 84 85 86 |
# File 'lib/Net/DNS/RR/A.rb', line 82 def new_from_hash(values) if (values.has_key?(:address)) @address=values[:address] end end |
#new_from_string(string) ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/Net/DNS/RR/A.rb', line 61 def new_from_string(string) if (string && (string =~ /^(\d+)\.(\d+)\.(\d+)\.(\d+)\s*$/o)) a = $1.to_i b = $2.to_i if (a >= 0) && (a <= 255) && (b >= 0) && (b <= 255) c = $3.to_i d = $4.to_i if (c >= 0) && (c <= 255) && (d >= 0) && (d <= 255) @address = "#{a}.#{b}.#{c}.#{d}"; end end end end |
#rdatastr ⇒ Object
88 89 90 |
# File 'lib/Net/DNS/RR/A.rb', line 88 def rdatastr return @address || ''; end |
#rr_rdata(*args) ⇒ Object
92 93 94 95 96 97 98 |
# File 'lib/Net/DNS/RR/A.rb', line 92 def rr_rdata(*args) if (defined?@address) return inet_aton(@address) else return "" end end |