Skip to content

Commit

Permalink
Added RFC 8427 Support
Browse files Browse the repository at this point in the history
  • Loading branch information
alexreinert committed May 25, 2023
1 parent 127b888 commit ba3e4a4
Show file tree
Hide file tree
Showing 22 changed files with 1,776 additions and 1,080 deletions.
9 changes: 7 additions & 2 deletions ARSoft.Tools.Net/ARSoft.Tools.Net.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<PackageLicenseUrl>https://github.com/alexreinert/ARSoft.Tools.Net/blob/master/LICENSE</PackageLicenseUrl>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<Copyright>Copyright 2010..2023 Alexander Reinert</Copyright>
<VersionPrefix>3.2.0</VersionPrefix>
<VersionPrefix>3.3.0</VersionPrefix>
</PropertyGroup>

<ItemGroup>
Expand All @@ -36,7 +36,12 @@
</None>
</ItemGroup>

<ItemGroup>
<ItemGroup Condition="!Exists('..\..\arsoft.pfx')">
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
<_Parameter1>ARSoft.Tools.Net.Tests</_Parameter1>
</AssemblyAttribute>
</ItemGroup>
<ItemGroup Condition="Exists('..\..\arsoft.pfx')">
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
<_Parameter1>ARSoft.Tools.Net.Tests, PublicKey=00240000048000009400000006020000002400005253413100040000010001009B3C03B877D82BDB95D93615C1521BAE3C1D5E9AF140B9BE44BE07ADF2E2E303481FEF06BE780C26E9422384E9E5B0EFD7CF77B5F1F500BD79062D076F47F4F955BF3090AEEF3CE0D3FD2E9C27F496035D2055D40CFF7835CB4DC40A337C890BBE2973BDDDFEC2DE8EFB7B8B375BDBD96EE5B278D8A69866841BC5D06E817CB5</_Parameter1>
</AssemblyAttribute>
Expand Down
88 changes: 15 additions & 73 deletions ARSoft.Tools.Net/Dns/DnsMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json.Serialization;

namespace ARSoft.Tools.Net.Dns
{
/// <summary>
/// Message returned as result to a dns query
/// </summary>
[JsonConverter(typeof(Rfc8427JsonConverter<DnsMessage>))]
public class DnsMessage : DnsRecordMessageBase
{
/// <summary>
Expand All @@ -49,18 +51,8 @@ public static DnsMessage Parse(ArraySegment<byte> data)
/// </summary>
public bool IsAuthoritiveAnswer
{
get { return (Flags & 0x0400) != 0; }
set
{
if (value)
{
Flags |= 0x0400;
}
else
{
Flags &= 0xfbff;
}
}
get => AAFlagInternal;
set => AAFlagInternal = value;
}

/// <summary>
Expand All @@ -72,18 +64,8 @@ public bool IsAuthoritiveAnswer
/// </summary>
public bool IsTruncated
{
get { return (Flags & 0x0200) != 0; }
set
{
if (value)
{
Flags |= 0x0200;
}
else
{
Flags &= 0xfdff;
}
}
get => TCFlagInternal;
set => TCFlagInternal = value;
}

/// <summary>
Expand All @@ -95,18 +77,8 @@ public bool IsTruncated
/// </summary>
public bool IsRecursionDesired
{
get { return (Flags & 0x0100) != 0; }
set
{
if (value)
{
Flags |= 0x0100;
}
else
{
Flags &= 0xfeff;
}
}
get => RDFlagInternal;
set => RDFlagInternal = value;
}

/// <summary>
Expand All @@ -118,18 +90,8 @@ public bool IsRecursionDesired
/// </summary>
public bool IsRecursionAllowed
{
get { return (Flags & 0x0080) != 0; }
set
{
if (value)
{
Flags |= 0x0080;
}
else
{
Flags &= 0xff7f;
}
}
get => RAFlagInternal;
set => RAFlagInternal = value;
}

/// <summary>
Expand All @@ -141,18 +103,8 @@ public bool IsRecursionAllowed
/// </summary>
public bool IsAuthenticData
{
get { return (Flags & 0x0020) != 0; }
set
{
if (value)
{
Flags |= 0x0020;
}
else
{
Flags &= 0xffdf;
}
}
get => ADFlagInternal;
set => ADFlagInternal = value;
}

/// <summary>
Expand All @@ -164,18 +116,8 @@ public bool IsAuthenticData
/// </summary>
public bool IsCheckingDisabled
{
get { return (Flags & 0x0010) != 0; }
set
{
if (value)
{
Flags |= 0x0010;
}
else
{
Flags &= 0xffef;
}
}
get => CDFlagInternal;
set => CDFlagInternal = value;
}
#endregion

Expand Down Expand Up @@ -223,7 +165,7 @@ public DnsMessage CreateResponseInstance()
TransactionID = TransactionID,
IsEDnsEnabled = IsEDnsEnabled,
IsQuery = false,
OperationCode = OperationCode,
OperationCodeInternal = OperationCodeInternal,
IsRecursionDesired = IsRecursionDesired,
IsCheckingDisabled = IsCheckingDisabled,
IsDnsSecOk = IsDnsSecOk,
Expand Down
Loading

0 comments on commit ba3e4a4

Please sign in to comment.