diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2005-01-29 05:14:11 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2005-01-29 05:14:11 +0000 |
commit | a0b39cf64f05c4864e63310a9a1364b02dc31b93 (patch) | |
tree | 8c4757e03f3aa3e1c60500695a3e5b9cdce56cd0 | |
parent | 962af989ec513944b558a2b52c1e5e0d967d6feb (diff) | |
download | ruby-a0b39cf64f05c4864e63310a9a1364b02dc31b93.tar.gz |
* lib/resolv.rb (Resolv::DNS::Resource::IN::SRV): Added RFC2782 SRV
resource record for specifying location of services.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7848 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | lib/resolv.rb | 58 |
2 files changed, 63 insertions, 0 deletions
@@ -1,3 +1,8 @@ +Sat Jan 29 09:42:12 2005 Sam Roberts <sroberts@uniserve.com> + + * lib/resolv.rb (Resolv::DNS::Resource::IN::SRV): Added RFC2782 SRV + resource record for specifying location of services. + Sat Jan 29 00:10:33 2005 Kazuo Saito <ksaito@uranus.dti.ne.jp> * ascii.c, euc_jp.c, hash.c, oniggnu.h, oniguruma.h, regcomp.c, diff --git a/lib/resolv.rb b/lib/resolv.rb index 769ebe34f5..fb92c638fb 100644 --- a/lib/resolv.rb +++ b/lib/resolv.rb @@ -1600,6 +1600,64 @@ class Resolv return self.new(IPv6.new(msg.get_bytes(16))) end end + + # SRV resource record defined in RFC 2782 + # + # These records identify the hostname and port that a service is + # available at. + # + # The format is: + # _Service._Proto.Name TTL Class SRV Priority Weight Port Target + # + # The fields specific to SRV are defined in RFC 2782 as meaning: + # - +priority+ The priority of this target host. A client MUST attempt + # to contact the target host with the lowest-numbered priority it can + # reach; target hosts with the same priority SHOULD be tried in an + # order defined by the weight field. The range is 0-65535. Note that + # it is not widely implemented and should be set to zero. + # + # - +weight+ A server selection mechanism. The weight field specifies + # a relative weight for entries with the same priority. Larger weights + # SHOULD be given a proportionately higher probability of being + # selected. The range of this number is 0-65535. Domain administrators + # SHOULD use Weight 0 when there isn't any server selection to do, to + # make the RR easier to read for humans (less noisy). Note that it is + # not widely implemented and should be set to zero. + # + # - +port+ The port on this target host of this service. The range is 0- + # 65535. + # + # - +target+ The domain name of the target host. A target of "." means + # that the service is decidedly not available at this domain. + class SRV < Resource + ClassHash[[TypeValue = 33, ClassValue = ClassValue]] = self + + # Create a SRV resource record. + def initialize(priority, weight, port, target) + @priority = priority.to_int + @weight = weight.to_int + @port = port.to_int + @target = Name.create(target) + end + + attr_reader :priority, :weight, :port, :target + + def encode_rdata(msg) + msg.put_pack("n", @priority) + msg.put_pack("n", @weight) + msg.put_pack("n", @port) + msg.put_name(@target) + end + + def self.decode_rdata(msg) + priority, = msg.get_unpack("n") + weight, = msg.get_unpack("n") + port, = msg.get_unpack("n") + target = msg.get_name + return self.new(priority, weight, port, target) + end + end + end end end |