Class: Gem::Resolv::MDNS
- Defined in:
- lib/rubygems/vendor/resolv/lib/resolv.rb
Overview
Gem::Resolv::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 collapse
- Port =
Default mDNS Port
5353
- AddressV4 =
Default IPv4 mDNS address
'224.0.0.251'
- AddressV6 =
Default IPv6 mDNS address
'ff02::fb'
- Addresses =
Default mDNS addresses
[ [AddressV4, Port], [AddressV6, Port], ]
Constants inherited from DNS
DNS::RequestID, DNS::RequestIDMutex, DNS::UDPSize
Instance Method Summary collapse
-
#each_address(name) ⇒ Object
Iterates over all IP addresses for
name
retrieved from the mDNS resolver, provided name ends with “local”. -
#initialize(config_info = nil) ⇒ MDNS
constructor
Creates a new one-shot Multicast DNS (mDNS) resolver.
-
#make_udp_requester ⇒ Object
:nodoc:.
Methods inherited from DNS
allocate_request_id, bind_random_port, #close, #each_name, #each_resource, #extract_resources, #fetch_resource, free_request_id, #getaddress, #getaddresses, #getname, #getnames, #getresource, #getresources, #lazy_initialize, #make_tcp_requester, open, random, #timeouts=
Constructor Details
#initialize(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.
3173 3174 3175 3176 3177 3178 3179 |
# 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) ⇒ Object
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 Gem::Resolv::DNS::Name or a String. Retrieved addresses will be a Gem::Resolv::IPv4 or Gem::Resolv::IPv6
3189 3190 3191 3192 3193 3194 3195 |
# 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 ⇒ Object
:nodoc:
3197 3198 3199 3200 |
# 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 |