mDNS Responder for advertising Matter services
Handles:
- Service advertisement (announcements)
- Query responses
- Using Authority Section for authoritative records
Constants
ANNOUNCEMENT_INTERVAL = 30.seconds
DEFAULT_TTL = 120.seconds
MDNS_IPV4 = Socket::IPAddress.new("224.0.0.251", MDNS_PORT)
MDNS_IPV6 = Socket::IPAddress.new("ff02::fb", MDNS_PORT)
Constructors
new(port : Int32 = MDNS_PORT, hostname : String = "matter-device.local", ip_addresses : Array(Socket::IPAddress) = [] of Socket::IPAddress)
SourceInstance methods
advertise_commissioning(info : CommissioningInfo, port : Int32 = 5540, ttl : Time::Span = 120.seconds) : Nil
Advertise commissioning service
Sourceadvertise_operational(info : OperationalInfo, port : Int32 = 5540, ttl : Time::Span = 120.seconds) : Nil
Advertise operational service
Sourcecommissioning_instance_name
Returns the current commissioning DNS-SD instance name (e.g. DD200C20D25AE5F7._matterc._udp.local)
if commissioning is currently being advertised.
Sourceon_query
Callback for received queries
Signature: (query : DNS::Packet, peer_address : Socket::IPAddress) -> Nil
Sourceon_query=(on_query : Proc(DNS::Packet, Socket::IPAddress, Nil) | Nil)
Callback for received queries
Signature: (query : DNS::Packet, peer_address : Socket::IPAddress) -> Nil
Sourcerespond_to_query(query : DNS::Packet, service_type : ServiceType, instance : String, port : Int32, txt_records : Hash(String, String), hostname : String) : Nil
Respond to a specific query with explicit hostname (SRV target).
Sourcerespond_to_query(query : DNS::Packet, service_type : ServiceType, instance : String, port : Int32, txt_records : Hash(String, String)) : Nil
Respond to a specific query
Sourcesend_goodbye(service_type : ServiceType, instance : String) : Nil
Send goodbye announcement (TTL=0) to remove service
Sourcestart
Start listening for mDNS queries
Sourcestop_commissioning
Stop all commissioning advertisements
Sourcestop_operational_advertisement
Stop all operational advertisements
Sourceupdate_commissioning_hostname(hostname : String) : Nil
Updates the default commissioning target hostname (SRV target) and re-announces
any active commissioning advertisements without changing the commissioning
instance name.
Source