Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c9844c0

Browse files
committed
Documentation Update
1 parent 4137387 commit c9844c0

File tree

3 files changed

+20
-4
lines changed

3 files changed

+20
-4
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,6 @@ A small, fast, modern DNS / MDNS / DNS-SD client
1111
* Resolution using common public recursive resolvers (Google, CloudFlare, etc.)
1212
* Support for DoH (DNS over HTTPS) with options for secure or insecure lookup
1313
* Leak protection to ensure sensitive queries are not shared with public DNS servers
14-
* Support for async, zerocopy, spans and all the modern .Net performance features
14+
* A DNS-SD and MDNS client with known answer suppression, passive caching and other mandatory and optional flood control features from the spec.
15+
* Support for async, zerocopy, spans and all the modern .Net performance features
16+
* See the TinyDNSDemo project for examples

TinyDNS/TinyDNS.csproj

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,16 @@
44
<TargetFrameworks>net80</TargetFrameworks>
55
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>
7-
<Version>0.9.0</Version>
7+
<Version>0.9.1</Version>
88
<PackageLicenseExpression>AGPL-3.0-or-later</PackageLicenseExpression>
99
<PackageReadmeFile>README.md</PackageReadmeFile>
1010
<Authors>jdomnitz</Authors>
1111
<Company>SmartHomeOS and Contributors</Company>
1212
<PackageTags>dns; dns-client; doh; mdns; secure-dns</PackageTags>
13+
<Title>Tiny DNS Client</Title>
14+
<Description>A small, fast, modern DNS / MDNS / DNS-SD client</Description>
15+
<Copyright>Copyright 2024 - Smart Home OS Contributors</Copyright>
16+
<RepositoryUrl>https://github.com/SmartHomeOS/TinyDNS/</RepositoryUrl>
1317
</PropertyGroup>
1418

1519
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net80|AnyCPU'">

TinyDNSDemo/DNS-SD.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,17 @@ public async Task Run()
3737
mdns.AnswerReceived += Mdns_AnswerReceived;
3838
await mdns.Start();
3939

40+
//Query all services (unicast first since we are new to the network)
4041
var records = await mdns.QueryService(ALL_SERVICES, DEFAULT_DOMAIN, true);
4142
await ProcessRecords(records);
4243

4344
await Task.Delay(10000);
44-
records = await mdns.QueryService(ALL_SERVICES, DEFAULT_DOMAIN, true);
45+
46+
//Check for any services we didn't hear about in the last query (known answer suppression is automatic)
47+
records = await mdns.QueryService(ALL_SERVICES, DEFAULT_DOMAIN, false);
4548
await ProcessRecords(records);
49+
50+
//In long running implementations, scanning should occur every 15-60 mins
4651
}
4752

4853
private async Task Mdns_AnswerReceived(DNSMessageEvent e)
@@ -59,9 +64,10 @@ private async Task ProcessRecords(ResourceRecord[] records)
5964
string? serviceName;
6065
PtrRecord item = (PtrRecord)record;
6166
if (!item.Domain.EndsWith(".local"))
62-
return; //NOT DNS-SD
67+
return; //NOT DNS-SD this is regular MDNS
6368
if (item.Name.StartsWith(ALL_SERVICES))
6469
{
70+
//These records tell us a service exists on the network for 1 or more hosts
6571
serviceName = MDNS.GetServiceName(item.DomainLabels);
6672
var cachedAnswers = await mdns.QueryService(serviceName!, DEFAULT_DOMAIN);
6773
if (serviceName != null)
@@ -73,12 +79,14 @@ private async Task ProcessRecords(ResourceRecord[] records)
7379
serviceName = MDNS.GetServiceName(item.DomainLabels);
7480
if (serviceName == ALL_SERVICES)
7581
continue;
82+
//These records are instance pointers - they tell us about hosts which have a specific service
7683
string? serviceInstance = MDNS.GetInstanceName(item.DomainLabels);
7784

7885
if (serviceName != null)
7986
{
8087
if (UpdateService(serviceName, serviceInstance))
8188
{
89+
// Request details on this instance of the service
8290
var lst = await mdns.ResolveServiceInstance(serviceInstance!, serviceName!, DEFAULT_DOMAIN);
8391
foreach (var msg in lst)
8492
await ProcessRecords(msg.Answers);
@@ -88,6 +96,7 @@ private async Task ProcessRecords(ResourceRecord[] records)
8896
}
8997
else if (record.Type == DNSRecordType.SRV)
9098
{
99+
// A detailed record of a host that is running a service on a particular port (with optional text info)
91100
string? serviceName = MDNS.GetServiceName(((SRVRecord)record).Labels);
92101
string? serviceInstance = MDNS.GetInstanceName(((SRVRecord)record).Labels);
93102
List<ResourceRecord> rcds = new List<ResourceRecord>();
@@ -101,6 +110,7 @@ private async Task ProcessRecords(ResourceRecord[] records)
101110
{
102111
if (records.Any(r => r.Type == DNSRecordType.SRV && record.Name.Equals(r.Name)))
103112
continue;
113+
//There are a few services that publish text without a SRV record - catch them here. Most implementations won't need this.
104114
string? serviceName = MDNS.GetServiceName(((TxtRecord)record).Labels);
105115
string? serviceInstance = MDNS.GetInstanceName(((TxtRecord)record).Labels);
106116
if (serviceInstance != null && serviceName != null)

0 commit comments

Comments
 (0)