123456789_123456789_123456789_123456789_123456789_

Class: Gem::Resolv::MDNS

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, DNS
Instance Chain:
self, DNS
Inherits: Gem::Resolv::DNS
Defined in: lib/rubygems/vendor/resolv/lib/resolv.rb

Overview

MDNS is a one-shot Multicast DNS (mDNS) resolver. It blindly makes queries to the mDNS addresses without understanding anything about multicast ports.

Information taken form the following places:

  • RFC 6762

Constant Summary

DNS - Inherited

Port, RequestID, RequestIDMutex, UDPSize

Class Method Summary

DNS - Inherited

.new

Creates a new DNS resolver.

.open

Creates a new DNS resolver.

.allocate_request_id, .bind_random_port, .free_request_id,
.random

See additional method definition at line 606.

Instance Attribute Summary

DNS - Inherited

#timeouts=

Sets the resolver timeouts.

#use_ipv6?

Instance Method Summary

DNS - Inherited

#close

Closes the DNS resolver.

#each_address

Iterates over all IP addresses for name retrieved from the DNS resolver.

#each_name

Iterates over all hostnames for address retrieved from the DNS resolver.

#each_resource

Iterates over all typeclass DNS resources for name.

#fetch_resource,
#getaddress

Gets the IP address of name from the DNS resolver.

#getaddresses

Gets all IP addresses for name from the DNS resolver.

#getname

Gets the hostname for address from the DNS resolver.

#getnames

Gets all hostnames for address from the DNS resolver.

#getresource

Look up the typeclass DNS resource of name.

#getresources

Looks up all typeclass DNS resources for name.

#extract_resources, #lazy_initialize, #make_tcp_requester, #make_udp_requester

Constructor Details

.new(config_info = nil) ⇒ MDNS

Creates a new one-shot Multicast DNS (mDNS) resolver.

config_info can be:

nil

Uses the default mDNS addresses

Hash

Must contain :nameserver or :nameserver_port like Gem::Resolv::DNS#initialize.

[ GitHub ]

  
# File 'lib/rubygems/vendor/resolv/lib/resolv.rb', line 3173

def initialize(config_info=nil)
  if config_info then
    super({ nameserver_port: Addresses }.merge(config_info))
  else
    super(nameserver_port: Addresses)
  end
end

Instance Method Details

#each_address(name)

Iterates over all IP addresses for name retrieved from the mDNS resolver, provided name ends with “local”. If the name does not end in “local” no records will be returned.

name can be a DNS::Name or a String. Retrieved addresses will be a IPv4 or IPv6

[ GitHub ]

  
# File 'lib/rubygems/vendor/resolv/lib/resolv.rb', line 3189

def each_address(name)
  name = Gem::Resolv::DNS::Name.create(name)

  return unless name[-1].to_s == 'local'

  super(name)
end

#make_udp_requester

This method is for internal use only.
[ GitHub ]

  
# File 'lib/rubygems/vendor/resolv/lib/resolv.rb', line 3197

def make_udp_requester # :nodoc:
  nameserver_port = @config.nameserver_port
  Requester::MDNSOneShot.new(*nameserver_port)
end