Visitar URL original
Fixing spelling mistakes by MichaConrad · Pull Request #70 · MichaCo/DnsClient.NET · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[![NuGet](https://img.shields.io/nuget/v/DnsClient?color=brightgreen&label=NuGet%20Stable)](https://www.nuget.org/packages/DnsClient)
[![NuGet](https://img.shields.io/nuget/vpre/DnsClient?color=yellow&label=NuGet%20Latest)](https://www.nuget.org/packages/DnsClient)

DnsClient.NET is a simple yet very powerful and high performant open source library for the .NET Framework to do DNS lookups.
DnsClient.NET is a simple yet very powerful and high performance open source library for the .NET Framework to do DNS lookups.

## Usage

Expand Down Expand Up @@ -68,6 +68,6 @@ dotnet run -s localhost mcnet.com any

## Examples

* More docuemntation and a simple query window on http://dnsclient.michaco.net
* More documentation and a simple query window on http://dnsclient.michaco.net
* The [Samples](https://github.com/MichaCo/DnsClient.NET.Samples) repository (there might be more in the future).
* [MiniDig](https://github.com/MichaCo/DnsClient.NET/tree/dev/samples/MiniDig)
2 changes: 1 addition & 1 deletion samples/MiniDig/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ MiniDig is multi targeted for now, which means, when you use `dotnet run` you ha
If nothing else is specified, it uses the DNS server configured for your local network adapter.
To specify a different server, use the `-s` switch, for example:

`dotnet run -f netcoreapp2.0 -s 8.8.8.8 google.com` to use the public google name server.
`dotnet run -f netcoreapp2.0 -s 8.8.8.8 google.com` to use the public Google name server.


`dotnet run -f netcoreapp2.0 -s 127.0.0.1#8600` to also specify a custom port.
Expand Down
4 changes: 2 additions & 2 deletions src/DnsClient/DnsClient.csproj
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<VersionPrefix>1.3.1</VersionPrefix>
<VersionPrefix>1.3.2</VersionPrefix>
<VersionSuffix Condition="'$(VersionSuffix)'!='' AND '$(BuildNumber)' != ''">$(VersionSuffix)-$(BuildNumber)</VersionSuffix>

<TargetFrameworks>netstandard1.3;netstandard2.0;netstandard2.1;net45;net471</TargetFrameworks>
<DebugType>full</DebugType>

<Product>DnsClient.NET</Product>
<Description>DnsClient.NET is a simple yet very powerful and high performant open source library for the .NET Framework to do DNS lookups</Description>
<Description>DnsClient.NET is a simple yet very powerful and high performance open source library for the .NET Framework to do DNS lookups</Description>

<Copyright>Copyright (c) 2020 MichaConrad</Copyright>
<Authors>MichaCo</Authors>
Expand Down
4 changes: 2 additions & 2 deletions src/DnsClient/DnsDatagramReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ public ICollection<ArraySegment<byte>> ReadLabels()

var subReader = new DnsDatagramReader(_data.SubArrayFromOriginal(subIndex));
var newLabels = subReader.ReadLabels();
result.AddRange(newLabels); // add range actually much faster than Concat and equal to or faster than foreach.. (array copy would work maybe)
result.AddRange(newLabels); // add range actually much faster than concat and equal to or faster than for-each.. (array copy would work maybe)
return result;
}

Expand All @@ -305,7 +305,7 @@ public ICollection<ArraySegment<byte>> ReadLabels()

var label = _data.SubArray(_index, length);

// maybe store orignial bytes in this instance too?
// maybe store original bytes in this instance too?
result.Add(label);

Advance(length);
Expand Down
7 changes: 4 additions & 3 deletions src/DnsClient/DnsQueryExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,7 @@ private static string ConcatResolveServiceName(string baseDomain, string service
private static ServiceHostEntry[] ResolveServiceProcessResult(IDnsQueryResponse result)
{
var hosts = new List<ServiceHostEntry>();
if (result.HasError)
if (result == null || result.HasError)
{
return hosts.ToArray();
}
Expand All @@ -643,7 +643,8 @@ private static ServiceHostEntry[] ResolveServiceProcessResult(IDnsQueryResponse
var hostName = result.Additionals
.OfType<CNameRecord>()
.Where(p => p.DomainName.Equals(entry.Target))
.Select(p => p.CanonicalName).FirstOrDefault();
.Select(p => p.CanonicalName).FirstOrDefault()
?? entry.Target;

hosts.Add(new ServiceHostEntry()
{
Expand Down Expand Up @@ -674,7 +675,7 @@ public class ServiceHostEntry : IPHostEntry
public int Port { get; set; }

/// <summary>
/// Gets or sets priortiy of the original <see cref="ResourceRecordType.SRV"/> record.
/// Gets or sets priority of the original <see cref="ResourceRecordType.SRV"/> record.
/// Might be zero if not provided.
/// </summary>
/// <value>
Expand Down
24 changes: 12 additions & 12 deletions src/DnsClient/DnsQueryOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ public TimeSpan Timeout
}

/// <summary>
/// Gets or sets a flag indicating whether Tcp should be used in case a Udp response is truncated.
/// Gets or sets a flag indicating whether TCP should be used in case a UDP response is truncated.
/// Default is <c>True</c>.
/// <para>
/// If <c>False</c>, truncated results will potentially yield no or incomplete answers.
Expand All @@ -176,10 +176,10 @@ public TimeSpan Timeout
public bool UseTcpFallback { get; set; } = true;

/// <summary>
/// Gets or sets a flag indicating whether Udp should not be used at all.
/// Gets or sets a flag indicating whether UDP should not be used at all.
/// Default is <c>False</c>.
/// <para>
/// Enable this only if Udp cannot be used because of your firewall rules for example.
/// Enable this only if UDP cannot be used because of your firewall rules for example.
/// Also, zone transfers (see <see cref="QueryType.AXFR"/>) must use TCP only.
/// </para>
/// </summary>
Expand Down Expand Up @@ -378,11 +378,11 @@ public LookupClientOptions(params IPAddress[] nameServers)
/// TTL of the record is lower than this minimum value.
/// Default is <c>Null</c>.
/// <para>
/// This is useful in case the server retruns records with zero TTL.
/// This is useful in case the server returns records with zero TTL.
/// </para>
/// </summary>
/// <remarks>
/// This setting gets igonred in case <see cref="DnsQueryOptions.UseCache"/> is set to <c>False</c>,
/// This setting gets ignored in case <see cref="DnsQueryOptions.UseCache"/> is set to <c>False</c>,
/// or the value is set to <c>Null</c> or <see cref="TimeSpan.Zero"/>.
/// The maximum value is 24 days or <see cref="Timeout.Infinite"/> (choose a wise setting).
/// </remarks>
Expand Down Expand Up @@ -414,7 +414,7 @@ public TimeSpan? MinimumCacheTimeout
/// Default is <c>Null</c>.
/// </summary>
/// <remarks>
/// This setting gets igonred in case <see cref="DnsQueryOptions.UseCache"/> is set to <c>False</c>,
/// This setting gets ignored in case <see cref="DnsQueryOptions.UseCache"/> is set to <c>False</c>,
/// or the value is set to <c>Null</c>, <see cref="Timeout.Infinite"/> or <see cref="TimeSpan.Zero"/>.
/// The maximum value is 24 days (which shouldn't be used).
/// </remarks>
Expand Down Expand Up @@ -575,7 +575,7 @@ public class DnsQuerySettings : IEquatable<DnsQuerySettings>
public TimeSpan Timeout { get; }

/// <summary>
/// Gets a flag indicating whether Tcp should be used in case a Udp response is truncated.
/// Gets a flag indicating whether TCP should be used in case a UDP response is truncated.
/// Default is <c>True</c>.
/// <para>
/// If <c>False</c>, truncated results will potentially yield no or incomplete answers.
Expand All @@ -584,10 +584,10 @@ public class DnsQuerySettings : IEquatable<DnsQuerySettings>
public bool UseTcpFallback { get; }

/// <summary>
/// Gets a flag indicating whether Udp should not be used at all.
/// Gets a flag indicating whether UDP should not be used at all.
/// Default is <c>False</c>.
/// <para>
/// Enable this only if Udp cannot be used because of your firewall rules for example.
/// Enable this only if UDP cannot be used because of your firewall rules for example.
/// Also, zone transfers (see <see cref="QueryType.AXFR"/>) must use TCP only.
/// </para>
/// </summary>
Expand Down Expand Up @@ -797,11 +797,11 @@ internal LookupClientSettings(LookupClientOptions options, IReadOnlyCollection<N
/// TTL of the record is lower than this minimum value.
/// Default is <c>Null</c>.
/// <para>
/// This is useful in cases where the server retruns records with zero TTL.
/// This is useful in cases where the server returns records with zero TTL.
/// </para>
/// </summary>
/// <remarks>
/// This setting gets igonred in case <see cref="DnsQueryOptions.UseCache"/> is set to <c>False</c>.
/// This setting gets ignored in case <see cref="DnsQueryOptions.UseCache"/> is set to <c>False</c>.
/// The maximum value is 24 days or <see cref="Timeout.Infinite"/>.
/// </remarks>
public TimeSpan? MinimumCacheTimeout { get; }
Expand All @@ -812,7 +812,7 @@ internal LookupClientSettings(LookupClientOptions options, IReadOnlyCollection<N
/// Default is <c>Null</c>.
/// </summary>
/// <remarks>
/// This setting gets igonred in case <see cref="DnsQueryOptions.UseCache"/> is set to <c>False</c>.
/// This setting gets ignored in case <see cref="DnsQueryOptions.UseCache"/> is set to <c>False</c>.
/// The maximum value is 24 days.
/// Setting it to <see cref="Timeout.Infinite"/> would be equal to not providing a value.
/// </remarks>
Expand Down
6 changes: 3 additions & 3 deletions src/DnsClient/DnsQueryResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public class DnsQueryResponse : IDnsQueryResponse
public IReadOnlyList<DnsResourceRecord> Additionals { get; }

/// <summary>
/// Gets a list of all answers, addtional and authority records.
/// Gets a list of all answers, additional and authority records.
/// </summary>
public IEnumerable<DnsResourceRecord> AllRecords
{
Expand Down Expand Up @@ -84,13 +84,13 @@ public IEnumerable<DnsResourceRecord> AllRecords
public IReadOnlyList<DnsResourceRecord> Authorities { get; }

/// <summary>
/// Returns a string value representing the error response code in case an error occured,
/// Returns a string value representing the error response code in case an error occurred,
/// otherwise '<see cref="DnsResponseCode.NoError"/>'.
/// </summary>
public string ErrorMessage => DnsResponseCodeText.GetErrorText((DnsResponseCode)Header.ResponseCode);

/// <summary>
/// A flag indicating if the header contains a response codde other than <see cref="DnsResponseCode.NoError"/>.
/// A flag indicating if the header contains a response code other than <see cref="DnsResponseCode.NoError"/>.
/// </summary>
public bool HasError => Header?.ResponseCode != DnsHeaderResponseCode.NoError;

Expand Down
2 changes: 1 addition & 1 deletion src/DnsClient/DnsQuestion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace DnsClient
public class DnsQuestion
{
/// <summary>
/// Gets the domain name the lookup was runnig for.
/// Gets the domain name the lookup was running for.
/// </summary>
/// <value>
/// The name of the query.
Expand Down
2 changes: 1 addition & 1 deletion src/DnsClient/DnsRecordFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public ResourceRecordInfo ReadRecordInfo()
_reader.ReadQuestionQueryString(), // name
(ResourceRecordType)_reader.ReadUInt16NetworkOrder(), // type
(QueryClass)_reader.ReadUInt16NetworkOrder(), // class
(int)_reader.ReadUInt32NetworkOrder(), // ttl - 32bit!!
(int)_reader.ReadUInt32NetworkOrder(), // TTL - 32bit!!
_reader.ReadUInt16NetworkOrder()); // RDLength
}

Expand Down
12 changes: 6 additions & 6 deletions src/DnsClient/DnsString.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ namespace DnsClient
public class DnsString
{
/// <summary>
/// The ACE prefix indicates that the domain name label contains not normally supported characters and that the label has been endoded.
/// The ACE prefix indicates that the domain name label contains not normally supported characters and that the label has been encoded.
/// </summary>
public const string ACEPrefix = "xn--";

/// <summary>
/// The maximum lenght in bytes for one label.
/// The maximum length in bytes for one label.
/// </summary>
public const int LabelMaxLength = 63;

/// <summary>
/// The maximum supported total length in bytes for a domain nanme. The calculation of the actual
/// The maximum supported total length in bytes for a domain name. The calculation of the actual
/// bytes this <see cref="DnsString"/> consumes includes all bytes used for to encode it as octet string.
/// </summary>
public const int QueryMaxLength = 255;
Expand All @@ -36,7 +36,7 @@ public class DnsString
private const string DotStr = ".";

/// <summary>
/// Gets the orginal value.
/// Gets the original value.
/// </summary>
public string Original { get; }

Expand Down Expand Up @@ -177,7 +177,7 @@ public static DnsString Parse(string query)
}
}

// octets length length bit per label + 2(start +end)
// octets length bit per label + 2(start +end)
if (charCount + labelsCount + 1 > QueryMaxLength)
{
throw new ArgumentException($"Octet length of '{query}' exceeds maximum of {QueryMaxLength} bytes.", nameof(query));
Expand All @@ -192,7 +192,7 @@ public static DnsString Parse(string query)
}

/// <summary>
/// Transforms names with the <see cref="ACEPrefix"/> to the unicode variant and adds a trailing '.' at the end if not present.
/// Transforms names with the <see cref="ACEPrefix"/> to the Unicode variant and adds a trailing '.' at the end if not present.
/// The original value will be kept in this instance in case it is needed.
/// </summary>
/// <remarks>
Expand Down
2 changes: 1 addition & 1 deletion src/DnsClient/DnsTcpMessageHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ private async Task<DnsResponseMessage> QueryAsyncInternal(TcpClient client, DnsR

var stream = client.GetStream();

// use a pooled buffer to writer the data + the length of the data later into the frist two bytes
// use a pooled buffer to writer the data + the length of the data later into the first two bytes
using (var memory = new PooledBytes(DnsDatagramWriter.BufferSize + 2))
using (var writer = new DnsDatagramWriter(new ArraySegment<byte>(memory.Buffer, 2, memory.Buffer.Length - 2)))
{
Expand Down
2 changes: 1 addition & 1 deletion src/DnsClient/DnsUdpMessageHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public override async Task<DnsResponseMessage> QueryAsync(
bool mustDispose = false;
try
{
// setup timeout cancelation, dispose socket (the only way to acutally cancel the request in async...
// setup timeout cancellation, dispose socket (the only way to actually cancel the request in async...
cancelationCallback(() =>
{
#if !NET45
Expand Down
6 changes: 3 additions & 3 deletions src/DnsClient/IDnsQueryResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public interface IDnsQueryResponse
IReadOnlyList<DnsResourceRecord> Additionals { get; }

/// <summary>
/// Gets a list of all answers, addtional and authority records.
/// Gets a list of all answers, additional and authority records.
/// </summary>
IEnumerable<DnsResourceRecord> AllRecords { get; }

Expand All @@ -44,13 +44,13 @@ public interface IDnsQueryResponse
string AuditTrail { get; }

/// <summary>
/// Returns a string value representing the error response code in case an error occured,
/// Returns a string value representing the error response code in case an error occurred,
/// otherwise '<see cref="DnsResponseCode.NoError"/>'.
/// </summary>
string ErrorMessage { get; }

/// <summary>
/// A flag indicating if the header contains a response codde other than <see cref="DnsResponseCode.NoError"/>.
/// A flag indicating if the header contains a response code other than <see cref="DnsResponseCode.NoError"/>.
/// </summary>
bool HasError { get; }

Expand Down
2 changes: 1 addition & 1 deletion src/DnsClient/Internal/StringBuilderObjectPool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public void Return(StringBuilder value)
}
}

/* copy of MS extesions object pool implementation minus disposable object pool
/* copy of MS extensions object pool implementation minus disposable object pool
* because it does not support the targets this library supports and fixes some issues I have with my StringBuilderObjectPool
* Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
*/
Expand Down
2 changes: 1 addition & 1 deletion src/DnsClient/Interop/Linux/StringParsingHelper.Dns.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

// TODO: Remove if fixed
// This code is from https://github.com/dotnet/corefx
// Will be removed whenever the bugs reading network information on linux are fixed and
// Will be removed whenever the bugs reading network information on Linux are fixed and
// I can use the Managed version.

namespace DnsClient.Linux
Expand Down
2 changes: 1 addition & 1 deletion src/DnsClient/IpAddressExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public static string GetArpaName(this IPAddress ip)
// check IP6
if (ip.AddressFamily == AddressFamily.InterNetworkV6)
{
// reveresed bytes need to be split into 4 bit parts and separated by '.'
// reversed bytes need to be split into 4 bit parts and separated by '.'
var newBytes = bytes
.SelectMany(b => new[] { (b >> 0) & 0xf, (b >> 4) & 0xf })
.Aggregate(new StringBuilder(), (s, b) => s.Append(b.ToString("x")).Append(".")) + "ip6.arpa.";
Expand Down
8 changes: 4 additions & 4 deletions src/DnsClient/LookupClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace DnsClient
/// <seealso cref="IDnsQuery"/>
/// <seealso cref="ILookupClient"/>
/// <example>
/// A basic example wihtout specifying any DNS server, which will use the DNS server configured by your local network.
/// A basic example without specifying any DNS server, which will use the DNS server configured by your local network.
/// <code>
/// <![CDATA[
/// var client = new LookupClient();
Expand Down Expand Up @@ -314,7 +314,7 @@ public LookupClient(IPAddress address, int port)
/// ]]>
/// </code>
/// <para>
/// The <see cref="NameServer"/> class also contains pre defined <see cref="IPEndPoint"/>s for the public google DNS servers, which can be used as follows:
/// The <see cref="NameServer"/> class also contains predefined <see cref="IPEndPoint"/>s for the public Google DNS servers, which can be used as follows:
/// <code>
/// <![CDATA[
/// var client = new LookupClient(NameServer.GooglePublicDns, NameServer.GooglePublicDnsIPv6);
Expand Down Expand Up @@ -1720,7 +1720,7 @@ public void AuditEdnsOpt(short udpSize, byte version, bool doFlag, DnsResponseCo
return;
}

_auditWriter.AppendLine($"; EDNS: version: {version}, flags:{(doFlag ? " do" : string.Empty)}; udp: {udpSize}; code: {responseCode}");
_auditWriter.AppendLine($"; EDNS: version: {version}, flags:{(doFlag ? " do" : string.Empty)}; UDP: {udpSize}; code: {responseCode}");
}

public void AuditEnd(IDnsQueryResponse queryResponse, NameServer nameServer)
Expand All @@ -1742,7 +1742,7 @@ public void AuditEnd(IDnsQueryResponse queryResponse, NameServer nameServer)

var elapsed = _swatch.ElapsedMilliseconds;

// TODO: find better way to print the actual ttl of cached values
// TODO: find better way to print the actual TTL of cached values
if (queryResponse != null)
{
if (queryResponse.Questions.Count > 0)
Expand Down
Loading