mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* lib/resolv.rb (Resolv::DNS::Resource#ttl): new attribute.
(Resolv::DNS::Resource#==): ignore @ttl. (Resolv::DNS::Resource#hash): ditto. (Resolv::DNS::Message::MessageDecoder#get_rr): save TTL in a Resource object. based on [ruby-core:5190] by Eric Hodel. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8627 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
27e59d7cdd
commit
e710ced659
2 changed files with 31 additions and 7 deletions
|
@ -1,3 +1,12 @@
|
||||||
|
Thu Jun 16 00:13:41 2005 Tanaka Akira <akr@m17n.org>
|
||||||
|
|
||||||
|
* lib/resolv.rb (Resolv::DNS::Resource#ttl): new attribute.
|
||||||
|
(Resolv::DNS::Resource#==): ignore @ttl.
|
||||||
|
(Resolv::DNS::Resource#hash): ditto.
|
||||||
|
(Resolv::DNS::Message::MessageDecoder#get_rr): save TTL in a
|
||||||
|
Resource object.
|
||||||
|
based on [ruby-core:5190] by Eric Hodel.
|
||||||
|
|
||||||
Wed Jun 15 18:26:39 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
|
Wed Jun 15 18:26:39 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
|
||||||
|
|
||||||
* ext/tk/lib/tk.rb: support "tk inactive" sub-command [for Tcl/Tk8.5a3]
|
* ext/tk/lib/tk.rb: support "tk inactive" sub-command [for Tcl/Tk8.5a3]
|
||||||
|
|
|
@ -1406,7 +1406,9 @@ class Resolv
|
||||||
name = self.get_name
|
name = self.get_name
|
||||||
type, klass, ttl = self.get_unpack('nnN')
|
type, klass, ttl = self.get_unpack('nnN')
|
||||||
typeclass = Resource.get_class(type, klass)
|
typeclass = Resource.get_class(type, klass)
|
||||||
return name, ttl, self.get_length16 {typeclass.decode_rdata(self)}
|
res = self.get_length16 { typeclass.decode_rdata self }
|
||||||
|
res.instance_variable_set :@ttl, ttl
|
||||||
|
return name, ttl, res
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1429,6 +1431,11 @@ class Resolv
|
||||||
|
|
||||||
class Resource < Query
|
class Resource < Query
|
||||||
|
|
||||||
|
##
|
||||||
|
# Remaining Time To Live for this Resource.
|
||||||
|
|
||||||
|
attr_reader :ttl
|
||||||
|
|
||||||
ClassHash = {} # :nodoc:
|
ClassHash = {} # :nodoc:
|
||||||
|
|
||||||
def encode_rdata(msg) # :nodoc:
|
def encode_rdata(msg) # :nodoc:
|
||||||
|
@ -1440,10 +1447,16 @@ class Resolv
|
||||||
end
|
end
|
||||||
|
|
||||||
def ==(other) # :nodoc:
|
def ==(other) # :nodoc:
|
||||||
return self.class == other.class &&
|
return false unless self.class == other.class
|
||||||
self.instance_variables == other.instance_variables &&
|
s_ivars = self.instance_variables
|
||||||
self.instance_variables.collect {|name| self.instance_eval name} ==
|
s_ivars.sort!
|
||||||
other.instance_variables.collect {|name| other.instance_eval name}
|
s_ivars.delete "@ttl"
|
||||||
|
o_ivars = other.instance_variables
|
||||||
|
o_ivars.sort!
|
||||||
|
o_ivars.delete "@ttl"
|
||||||
|
return s_ivars == o_ivars &&
|
||||||
|
s_ivars.collect {|name| self.instance_variable_get name} ==
|
||||||
|
o_ivars.collect {|name| other.instance_variable_get name}
|
||||||
end
|
end
|
||||||
|
|
||||||
def eql?(other) # :nodoc:
|
def eql?(other) # :nodoc:
|
||||||
|
@ -1452,8 +1465,10 @@ class Resolv
|
||||||
|
|
||||||
def hash # :nodoc:
|
def hash # :nodoc:
|
||||||
h = 0
|
h = 0
|
||||||
self.instance_variables.each {|name|
|
vars = self.instance_variables
|
||||||
h ^= self.instance_eval("#{name}.hash")
|
vars.delete "@ttl"
|
||||||
|
vars.each {|name|
|
||||||
|
h ^= self.instance_variable_get(name).hash
|
||||||
}
|
}
|
||||||
return h
|
return h
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue