Class: Resolv
- Inherits:
-
Object
show all
- Defined in:
- lib/logmerge/resolv.rb
Defined Under Namespace
Classes: DNS, Hosts, IPv4, IPv6, ResolvError, ResolvTimeout
Constant Summary
collapse
- DefaultResolver =
self.new
- AddressRegex =
/(?:#{IPv4::Regex})|(?:#{IPv6::Regex})/
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(resolvers = [Hosts.new, DNS.new]) ⇒ Resolv
Returns a new instance of Resolv.
226
227
228
|
# File 'lib/logmerge/resolv.rb', line 226
def initialize(resolvers=[Hosts.new, DNS.new])
@resolvers = resolvers
end
|
Class Method Details
.each_address(name, &block) ⇒ Object
210
211
212
|
# File 'lib/logmerge/resolv.rb', line 210
def self.each_address(name, &block)
DefaultResolver.each_address(name, &block)
end
|
.each_name(address, &proc) ⇒ Object
222
223
224
|
# File 'lib/logmerge/resolv.rb', line 222
def self.each_name(address, &proc)
DefaultResolver.each_name(address, &proc)
end
|
.getaddress(name) ⇒ Object
202
203
204
|
# File 'lib/logmerge/resolv.rb', line 202
def self.getaddress(name)
DefaultResolver.getaddress(name)
end
|
.getaddresses(name) ⇒ Object
206
207
208
|
# File 'lib/logmerge/resolv.rb', line 206
def self.getaddresses(name)
DefaultResolver.getaddresses(name)
end
|
.getname(address) ⇒ Object
214
215
216
|
# File 'lib/logmerge/resolv.rb', line 214
def self.getname(address)
DefaultResolver.getname(address)
end
|
.getnames(address) ⇒ Object
218
219
220
|
# File 'lib/logmerge/resolv.rb', line 218
def self.getnames(address)
DefaultResolver.getnames(address)
end
|
Instance Method Details
#each_address(name) ⇒ Object
241
242
243
244
245
246
247
248
249
250
251
252
253
254
|
# File 'lib/logmerge/resolv.rb', line 241
def each_address(name)
if AddressRegex =~ name
yield name
return
end
yielded = false
@resolvers.each {|r|
r.each_address(name) {|address|
yield address.to_s
yielded = true
}
return if yielded
}
end
|
#each_name(address) ⇒ Object
267
268
269
270
271
272
273
274
275
276
|
# File 'lib/logmerge/resolv.rb', line 267
def each_name(address)
yielded = false
@resolvers.each {|r|
r.each_name(address) {|name|
yield name.to_s
yielded = true
}
return if yielded
}
end
|
#getaddress(name) ⇒ Object
230
231
232
233
|
# File 'lib/logmerge/resolv.rb', line 230
def getaddress(name)
each_address(name) {|address| return address}
raise ResolvError.new("no address for #{name}")
end
|
#getaddresses(name) ⇒ Object
235
236
237
238
239
|
# File 'lib/logmerge/resolv.rb', line 235
def getaddresses(name)
ret = []
each_address(name) {|address| ret << address}
return ret
end
|
#getname(address) ⇒ Object
256
257
258
259
|
# File 'lib/logmerge/resolv.rb', line 256
def getname(address)
each_name(address) {|name| return name}
raise ResolvError.new("no name for #{address}")
end
|
#getnames(address) ⇒ Object
261
262
263
264
265
|
# File 'lib/logmerge/resolv.rb', line 261
def getnames(address)
ret = []
each_name(address) {|name| ret << name}
return ret
end
|