123456789_123456789_123456789_123456789_123456789_

Class: Resolv::MDNS

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, DNS
Instance Chain:
self, DNS
Inherits: Resolv::DNS
Defined in: 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, UDPSize

Class Method Summary

DNS - Inherited

.new

Creates a new DNS resolver.

.open

Creates a new DNS resolver.

Instance Attribute Summary

DNS - Inherited

#timeouts=

Sets the resolver timeouts.

Instance Method Summary

  • #each_address(name)

    Iterates over all IP addresses for name retrieved from the mDNS resolver, provided name ends with “local”.

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.

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 Resolv::DNS#initialize.

[ GitHub ]

  
# File 'lib/resolv.rb', line 2577

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/resolv.rb', line 2593

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

  return unless name.to_a.last == 'local'

  super(name)
end