Skip to content

Commit 2395999

Browse files
author
Michael Conrad
authored
Readme update & cleanup
* removing old net45 ifdefs and workarounds. (#223) * update to readme * fix linux build
1 parent ca36de4 commit 2395999

10 files changed

Lines changed: 8 additions & 43 deletions

File tree

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,14 @@ var ip = record?.Address;
4444

4545
### Supported resource records
4646

47-
* A, AAAA, NS, CNAME, SOA, MB, MG, MR, WKS, HINFO, MINFO, MX, RP, TXT, AFSDB, URI, CAA, NULL, SSHFP, TLSA, RRSIG, NSEC, NSEC3, NSEC3PARAM, DNSKEY, DS
47+
* A, AAAA, NS, CNAME, SOA, MB, MG, MR, WKS, HINFO, MINFO, MX, RP, TXT, AFSDB, URI, CAA, NULL, SSHFP, TLSA, RRSIG, NSEC, NSEC3, NSEC3PARAM, DNSKEY, DS, NAPTR, CERT
4848
* PTR for reverse lookups
4949
* SRV for service discovery. `LookupClient` has some extensions to help with that.
5050
* AXFR zone transfer (as per spec, LookupClient has to be set to TCP mode only for this type. Also, the result depends on if the DNS server trusts your current connection)
5151

5252
## Build from Source
5353

54-
To build and contribute to this project, you must have the latest [.NET 5 SDK](https://dotnet.microsoft.com/download) installed.
55-
Just clone the repository and open the solution in Visual Studio 2019.
54+
To build and contribute to this project, you must have the latest [.NET SDKs](https://dotnet.microsoft.com/download) and Visual Studio 2022 installed.
5655

5756
## Examples
5857

azure-pipelines-ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ jobs:
4141
inputs:
4242
command: 'test'
4343
projects: 'test/**/*.csproj'
44-
publishTestResults: false
45-
arguments: '-c Release --no-build --no-restore -f netcoreapp3.1'
44+
publishTestResults: true
45+
arguments: '-c Release --no-build --no-restore -f net6.0'
4646

4747
- job: Windows
4848
displayName: 'Build & Test on Windows'

src/DnsClient/DnsClient.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<PublicSign Condition="'$(OS)' != 'Windows_NT'">true</PublicSign>
1919

2020
<PackageId>DnsClient</PackageId>
21-
<PackageTags>dns;client;stub;resolver;name;server;core;service;discovery</PackageTags>
21+
<PackageTags>dns;client;resolver;servicediscovery</PackageTags>
2222

2323
<PackageIcon>icon.png</PackageIcon>
2424
<PackageReadmeFile>README.md</PackageReadmeFile>

src/DnsClient/DnsTcpMessageHandler.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -436,11 +436,7 @@ public void DisposeClient()
436436
{
437437
try
438438
{
439-
#if !NET45
440439
Client.Dispose();
441-
#else
442-
Client.Close();
443-
#endif
444440
}
445441
catch { }
446442
}

src/DnsClient/Interop/Windows/IpHlpApi/FixedNetworkInformation.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
using System.Net;
99
using System.Runtime.InteropServices;
1010

11-
#if !NET45
12-
1311
namespace DnsClient.Windows.IpHlpApi
1412
{
1513
internal class FixedNetworkInformation
@@ -82,4 +80,3 @@ public static FixedNetworkInformation GetFixedInformation()
8280
}
8381
}
8482
}
85-
#endif

src/DnsClient/Interop/Windows/NameResolutionPolicy.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212

1313
namespace DnsClient.Windows
1414
{
15-
#if !NET45
16-
1715
internal static class NameResolutionPolicy
1816
{
1917
private static readonly char[] s_splitOn = new char[] { ';' };
@@ -133,5 +131,4 @@ private static void AddServers(HashSet<NameServer> nameServers, string[] names,
133131
}
134132
}
135133
}
136-
#endif
137134
}

src/DnsClient/NameServer.cs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,6 @@ public override int GetHashCode()
245245
/// </returns>
246246
public static IReadOnlyCollection<NameServer> ResolveNameServers(bool skipIPv6SiteLocal = true, bool fallbackToGooglePublicDns = true)
247247
{
248-
// TODO: Use Array.Empty after dropping NET45
249248
IReadOnlyCollection<NameServer> nameServers = Array.Empty<NameServer>();
250249

251250
var exceptions = new List<Exception>();
@@ -263,7 +262,6 @@ public static IReadOnlyCollection<NameServer> ResolveNameServers(bool skipIPv6Si
263262
exceptions.Add(ex);
264263
}
265264

266-
#if !NET45
267265
if (exceptions.Count > 0)
268266
{
269267
logger?.LogDebug("Using native path to resolve servers.");
@@ -309,7 +307,6 @@ public static IReadOnlyCollection<NameServer> ResolveNameServers(bool skipIPv6Si
309307
logger?.LogInformation(ex, "Resolving name servers from NRPT failed.");
310308
}
311309

312-
#endif
313310
IReadOnlyCollection<NameServer> filtered = nameServers
314311
.Where(p => (p.IPEndPoint.Address.AddressFamily == AddressFamily.InterNetwork
315312
|| p.IPEndPoint.Address.AddressFamily == AddressFamily.InterNetworkV6)
@@ -349,8 +346,6 @@ public static IReadOnlyCollection<NameServer> ResolveNameServers(bool skipIPv6Si
349346
return filtered;
350347
}
351348

352-
#if !NET45
353-
354349
/// <summary>
355350
/// Using my custom native implementation to support UWP apps and such until <see cref="NetworkInterface.GetAllNetworkInterfaces"/>
356351
/// gets an implementation in netstandard2.1.
@@ -410,8 +405,6 @@ public static IReadOnlyCollection<NameServer> ResolveNameResolutionPolicyServers
410405
return NameResolutionPolicy.Resolve();
411406
}
412407

413-
#endif
414-
415408
internal static IReadOnlyCollection<NameServer> ValidateNameServers(IReadOnlyCollection<NameServer> servers, ILogger logger = null)
416409
{
417410
// Right now, I'm only checking for ANY address, but might be more validation rules at some point...

src/DnsClient/Protocol/RRSigRecord.cs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,8 @@ public RRSigRecord(
153153
Algorithm = (DnsSecurityAlgorithm)algorithm;
154154
Labels = labels;
155155
OriginalTtl = originalTtl;
156-
SignatureExpiration = FromUnixTimeSeconds(signatureExpiration);
157-
SignatureInception = FromUnixTimeSeconds(signatureInception);
156+
SignatureExpiration = DateTimeOffset.FromUnixTimeSeconds(signatureExpiration);
157+
SignatureInception = DateTimeOffset.FromUnixTimeSeconds(signatureInception);
158158
KeyTag = keyTag;
159159
SignersName = signersName ?? throw new ArgumentNullException(nameof(signersName));
160160
Signature = signature ?? throw new ArgumentNullException(nameof(signature));
@@ -175,12 +175,5 @@ private protected override string RecordToString()
175175
SignersName,
176176
SignatureAsString);
177177
}
178-
179-
// DateTimeOffset does have that method build in .NET47+ but not .NET45 which we will support. TODO: delete this when we drop support for .NET 4.5
180-
private static DateTimeOffset FromUnixTimeSeconds(long seconds)
181-
{
182-
long ticks = seconds * TimeSpan.TicksPerSecond + new DateTime(1970, 1, 1, 0, 0, 0).Ticks;
183-
return new DateTimeOffset(ticks, TimeSpan.Zero);
184-
}
185178
}
186-
}
179+
}

test-other/OldReference/OldReference.csproj

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,6 @@
77
<NoWarn>CA1707</NoWarn>
88
</PropertyGroup>
99

10-
<ItemGroup>
11-
</ItemGroup>
12-
<!--<ItemGroup Condition=" '$(TargetFramework)' == 'net45' ">
13-
<PackageReference Include="DnsClient" Version="1.1.0" />
14-
</ItemGroup>-->
15-
1610
<ItemGroup Condition=" '$(TargetFramework)' == 'net472' ">
1711
<PackageReference Include="DnsClient" Version="1.1.0" />
1812
</ItemGroup>

test/DnsClient.Tests/UdpServer.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,7 @@ protected virtual void DataReceivedInternal(IPEndPoint receivedEndPoint, byte[]
6767

6868
public void Dispose()
6969
{
70-
#if !NET45
7170
_client.Dispose();
72-
#else
73-
_client.Close();
74-
#endif
7571

7672
_disposed = true;
7773
}

0 commit comments

Comments
 (0)