From 83c1e25c2d8e6aaa14fa84b862ed585e1d3ce3c2 Mon Sep 17 00:00:00 2001 From: Dieter Lunn Date: Mon, 18 Jun 2018 16:02:11 -0500 Subject: [PATCH 01/15] Reenable codecov and add prerelease build deployment --- appveyor.yml | 16 +++++++++++++++- build.cake | 2 +- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index f61a23c..01b8c1c 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -11,6 +11,9 @@ before_build: build_script: - cmd: PowerShell -Version 2.0 .\build.ps1 +artifacts: + - path: '**\*.nupkg' + deploy: release: Ubiety.Dns.Core-v$(appveyor_build_version) description: Ubiety DNS for .NET Standard @@ -22,4 +25,15 @@ deploy: prerelease: false on: branch: master - appveyor_repo_tag: false \ No newline at end of file + +deploy: + release: Ubiety.Dns.Core-v$(appveyor_build_version) + description: Ubiety DNS Beta + provider: GitHub + auth_token: + secure: +fxguAe7QHo5zfhN7YRoOqMf4x8ZG4mR29Q8HMY0Y9d4gvwv+NP5daWbQyc0R/BJ + artifact: /.*\.nupkg/ + draft: true + prerelease: true + on: + branch: develop \ No newline at end of file diff --git a/build.cake b/build.cake index bd5f90a..cc46413 100644 --- a/build.cake +++ b/build.cake @@ -60,7 +60,7 @@ Task("Test") Configuration = configuration }); - //Codecov("test/Ubiety.Dns.Test/coverage.opencover.xml", "977eef75-3209-48ad-8543-92e88ccf4bc5"); + Codecov("test/Ubiety.Dns.Test/coverage.opencover.xml", "977eef75-3209-48ad-8543-92e88ccf4bc5"); }); Task("SonarBegin") From ad0097021cf64c57fb1c5110d96719e158e6dfba Mon Sep 17 00:00:00 2001 From: Dieter Lunn Date: Mon, 18 Jun 2018 16:03:18 -0500 Subject: [PATCH 02/15] Remove duplicate key --- appveyor.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 01b8c1c..5965542 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -30,8 +30,6 @@ deploy: release: Ubiety.Dns.Core-v$(appveyor_build_version) description: Ubiety DNS Beta provider: GitHub - auth_token: - secure: +fxguAe7QHo5zfhN7YRoOqMf4x8ZG4mR29Q8HMY0Y9d4gvwv+NP5daWbQyc0R/BJ artifact: /.*\.nupkg/ draft: true prerelease: true From 3cc8f75551e410ee99fa5fdc069f6542af830b12 Mon Sep 17 00:00:00 2001 From: Dieter Lunn Date: Mon, 18 Jun 2018 16:04:30 -0500 Subject: [PATCH 03/15] Fix actual duplicate key issue --- appveyor.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 5965542..f7d1c0e 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -26,10 +26,11 @@ deploy: on: branch: master -deploy: release: Ubiety.Dns.Core-v$(appveyor_build_version) description: Ubiety DNS Beta provider: GitHub + auth_token: + secure: +fxguAe7QHo5zfhN7YRoOqMf4x8ZG4mR29Q8HMY0Y9d4gvwv+NP5daWbQyc0R/BJ artifact: /.*\.nupkg/ draft: true prerelease: true From e668af5d8602a8831417570b0317dc5519fd8121 Mon Sep 17 00:00:00 2001 From: Dieter Lunn Date: Mon, 18 Jun 2018 16:05:50 -0500 Subject: [PATCH 04/15] Change prerelease deployment name --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index f7d1c0e..902d1d1 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -26,7 +26,7 @@ deploy: on: branch: master - release: Ubiety.Dns.Core-v$(appveyor_build_version) + release: Ubiety.Dns.Core.beta-v$(appveyor_build_version) description: Ubiety DNS Beta provider: GitHub auth_token: From 0851c9cd65e0682947fe40dd2819a0dbf9fd8dbc Mon Sep 17 00:00:00 2001 From: Dieter Lunn Date: Mon, 18 Jun 2018 16:09:18 -0500 Subject: [PATCH 05/15] Set specific branches to build --- appveyor.yml | 47 +++++++++++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 20 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 902d1d1..3f51881 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,6 +1,13 @@ image: Visual Studio 2017 skip_tags: true +branches: + only: + - master + - develop + except: + - gh-pages + install: - choco install gitversion.portable -pre -y @@ -15,24 +22,24 @@ artifacts: - path: '**\*.nupkg' deploy: - release: Ubiety.Dns.Core-v$(appveyor_build_version) - description: Ubiety DNS for .NET Standard - provider: GitHub - auth_token: - secure: +fxguAe7QHo5zfhN7YRoOqMf4x8ZG4mR29Q8HMY0Y9d4gvwv+NP5daWbQyc0R/BJ - artifact: /.*\.nupkg/ - draft: true - prerelease: false - on: - branch: master + - provider: GitHub + release: Ubiety.Dns.Core-v$(appveyor_build_version) + description: Ubiety DNS for .NET Standard + auth_token: + secure: +fxguAe7QHo5zfhN7YRoOqMf4x8ZG4mR29Q8HMY0Y9d4gvwv+NP5daWbQyc0R/BJ + artifact: /.*\.nupkg/ + draft: true + prerelease: false + on: + branch: master - release: Ubiety.Dns.Core.beta-v$(appveyor_build_version) - description: Ubiety DNS Beta - provider: GitHub - auth_token: - secure: +fxguAe7QHo5zfhN7YRoOqMf4x8ZG4mR29Q8HMY0Y9d4gvwv+NP5daWbQyc0R/BJ - artifact: /.*\.nupkg/ - draft: true - prerelease: true - on: - branch: develop \ No newline at end of file + - provider: GitHub + release: Ubiety.Dns.Core.beta-v$(appveyor_build_version) + description: Ubiety DNS Beta + auth_token: + secure: +fxguAe7QHo5zfhN7YRoOqMf4x8ZG4mR29Q8HMY0Y9d4gvwv+NP5daWbQyc0R/BJ + artifact: /.*\.nupkg/ + draft: true + prerelease: true + on: + branch: develop \ No newline at end of file From 0062ff7ddf853ec641d1bca30725d113c25751b4 Mon Sep 17 00:00:00 2001 From: Dieter Lunn Date: Mon, 18 Jun 2018 16:15:06 -0500 Subject: [PATCH 06/15] Fix artifact discovery --- appveyor.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 3f51881..fa7f4ef 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -2,9 +2,6 @@ image: Visual Studio 2017 skip_tags: true branches: - only: - - master - - develop except: - gh-pages @@ -12,14 +9,13 @@ install: - choco install gitversion.portable -pre -y before_build: - - cmd: dotnet restore - ps: gitversion /l console /output buildserver /updateAssemblyInfo build_script: - cmd: PowerShell -Version 2.0 .\build.ps1 artifacts: - - path: '**\*.nupkg' + - path: 'src\**\*.nupkg' deploy: - provider: GitHub From c7f4ca8cc6390099dbb8a5edc99df26c74c0239d Mon Sep 17 00:00:00 2001 From: Dieter Lunn Date: Mon, 18 Jun 2018 16:31:01 -0500 Subject: [PATCH 07/15] Implement mx operators --- appveyor.yml | 4 +- src/Ubiety.Dns.Core/Records/Mail/RecordMX.cs | 108 ++++++++++++------- 2 files changed, 71 insertions(+), 41 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index fa7f4ef..623def4 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -36,6 +36,4 @@ deploy: secure: +fxguAe7QHo5zfhN7YRoOqMf4x8ZG4mR29Q8HMY0Y9d4gvwv+NP5daWbQyc0R/BJ artifact: /.*\.nupkg/ draft: true - prerelease: true - on: - branch: develop \ No newline at end of file + prerelease: true \ No newline at end of file diff --git a/src/Ubiety.Dns.Core/Records/Mail/RecordMX.cs b/src/Ubiety.Dns.Core/Records/Mail/RecordMX.cs index f399400..db5ce39 100644 --- a/src/Ubiety.Dns.Core/Records/Mail/RecordMX.cs +++ b/src/Ubiety.Dns.Core/Records/Mail/RecordMX.cs @@ -6,12 +6,6 @@ namespace Ubiety.Dns.Core.Records.Mail /* 3.3.9. MX RDATA format - +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - | PREFERENCE | - +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - / EXCHANGE / - / / - +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ where: @@ -28,12 +22,26 @@ specified by EXCHANGE. The use of MX RRs is explained in detail in */ /// - /// Mail exchange DNS record + /// Mail exchange DNS record /// + /// + /// # [Description](#tab/description) + /// Standard MX mail DNS record + /// + /// # [RFC](#tab/rfc) + /// ``` + /// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ + /// | PREFERENCE | + /// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ + /// / EXCHANGE / + /// / / + /// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ + /// ``` + /// public sealed class RecordMx : Record, IComparable, IEquatable { /// - /// Initializes a new instance of the class + /// Initializes a new instance of the class /// /// for the record data public RecordMx(RecordReader rr) @@ -43,17 +51,17 @@ public RecordMx(RecordReader rr) } /// - /// Gets or sets the preference + /// Gets or sets the preference /// public UInt16 Preference { get; set; } /// - /// Gets or sets the exchange + /// Gets or sets the exchange /// public String Exchange { get; set; } /// - /// String representation of the record data + /// String representation of the record data /// /// Exchange and preference as a string public override String ToString() @@ -62,93 +70,117 @@ public override String ToString() } /// - /// Compares record to an object + /// Compares record to an object /// /// Object to compare record to /// Int value of the comparison public int CompareTo(object obj) { - RecordMx recordMX = obj as RecordMx; - if (recordMX == null) - { - return -1; - } - else if (this.Preference > recordMX.Preference) + return CompareTo(this, obj as RecordMx); + } + + /// + /// + public override Boolean Equals(object obj) + { + if (obj is null) { - return 1; + return false; } - else if (this.Preference < recordMX.Preference) + + if (this.GetType() != obj.GetType()) { - return -1; + return false; } - else + + if (ReferenceEquals(this, obj)) { - // they are the same, now compare case insensitive names - return string.Compare(this.Exchange, recordMX.Exchange, true, CultureInfo.InvariantCulture); + return true; } - } - /// - /// - public override Boolean Equals(object obj) - { - throw new NotImplementedException(); + return this.Equals(obj as RecordMx); } /// /// public override Int32 GetHashCode() { - throw new NotImplementedException(); + return Exchange.GetHashCode(); } /// /// public Boolean Equals(RecordMx other) { - throw new NotImplementedException(); + if (other is null) + { + return false; + } + + return CompareTo(this, other) == 0; } /// /// public static Boolean operator <(RecordMx x, RecordMx y) { - throw new NotImplementedException(); + return CompareTo(x, y) < 0; } /// /// public static Boolean operator >(RecordMx x, RecordMx y) { - throw new NotImplementedException(); + return CompareTo(x, y) > 0; } /// /// public static Boolean operator <=(RecordMx x, RecordMx y) { - throw new NotImplementedException(); + return CompareTo(x, y) <= 0; } /// /// public static Boolean operator >=(RecordMx x, RecordMx y) { - throw new NotImplementedException(); + return CompareTo(x, y) >= 0; } /// /// public static Boolean operator ==(RecordMx x, RecordMx y) { - throw new NotImplementedException(); + return CompareTo(x, y) == 0; } /// /// public static Boolean operator !=(RecordMx x, RecordMx y) { - throw new NotImplementedException(); + return CompareTo(x, y) != 0; + } + + private static Int32 CompareTo(RecordMx x, RecordMx y) + { + if (y == null) + { + return -1; + } + else if (x.Preference > y.Preference) + { + return 1; + } + else if (x.Preference < y.Preference) + { + return -1; + } + else + { + // they are the same, now compare case insensitive names + return string.Compare(x.Exchange, y.Exchange, true, CultureInfo.InvariantCulture); + } } } } From 8caab46b48ed546125fcfe25f6cd0a712326b61f Mon Sep 17 00:00:00 2001 From: Dieter Lunn Date: Mon, 18 Jun 2018 16:39:08 -0500 Subject: [PATCH 08/15] Move comments to documentation --- src/Ubiety.Dns.Core/Records/Mail/RecordMX.cs | 31 ++++++++------------ 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/src/Ubiety.Dns.Core/Records/Mail/RecordMX.cs b/src/Ubiety.Dns.Core/Records/Mail/RecordMX.cs index db5ce39..e4541f0 100644 --- a/src/Ubiety.Dns.Core/Records/Mail/RecordMX.cs +++ b/src/Ubiety.Dns.Core/Records/Mail/RecordMX.cs @@ -3,24 +3,6 @@ namespace Ubiety.Dns.Core.Records.Mail { - /* - 3.3.9. MX RDATA format - - - where: - - PREFERENCE A 16 bit integer which specifies the preference given to - this RR among others at the same owner. Lower values - are preferred. - - EXCHANGE A which specifies a host willing to act as - a mail exchange for the owner name. - - MX records cause type A additional section processing for the host - specified by EXCHANGE. The use of MX RRs is explained in detail in - [RFC-974]. - */ - /// /// Mail exchange DNS record /// @@ -36,6 +18,19 @@ specified by EXCHANGE. The use of MX RRs is explained in detail in /// / EXCHANGE / /// / / /// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ + /// + /// where: + /// + /// PREFERENCE A 16 bit integer which specifies the preference given to + /// this RR among others at the same owner. Lower values + /// are preferred. + /// + /// EXCHANGE A [domain-name] which specifies a host willing to act as + /// a mail exchange for the owner name. + /// + /// MX records cause type A additional section processing for the host + /// specified by EXCHANGE. The use of MX RRs is explained in detail in + /// [RFC-974]. /// ``` /// public sealed class RecordMx : Record, IComparable, IEquatable From b41bffbe70a3252d15e484684434b7dc4c980a45 Mon Sep 17 00:00:00 2001 From: Dieter Lunn Date: Mon, 18 Jun 2018 19:12:06 -0500 Subject: [PATCH 09/15] Add documentation --- src/Ubiety.Dns.Core/Records/Mail/RecordMX.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Ubiety.Dns.Core/Records/Mail/RecordMX.cs b/src/Ubiety.Dns.Core/Records/Mail/RecordMX.cs index e4541f0..72ca7f3 100644 --- a/src/Ubiety.Dns.Core/Records/Mail/RecordMX.cs +++ b/src/Ubiety.Dns.Core/Records/Mail/RecordMX.cs @@ -75,7 +75,10 @@ public int CompareTo(object obj) } /// + /// Does this instance equal an object /// + /// Object to compare to + /// Boolean indicating whether the objects are equal public override Boolean Equals(object obj) { if (obj is null) @@ -97,14 +100,19 @@ public override Boolean Equals(object obj) } /// + /// Gets the record hash code /// + /// Integer representing the hash code public override Int32 GetHashCode() { return Exchange.GetHashCode(); } /// + /// Does this instance equal another instance of RecordMx /// + /// RecordMx to compare to + /// Boolean indicating whether the objects are equal public Boolean Equals(RecordMx other) { if (other is null) From b165b7805c0246579daf79ff76d9ef1d141d54b0 Mon Sep 17 00:00:00 2001 From: Dieter Lunn Date: Wed, 20 Jun 2018 22:59:34 -0500 Subject: [PATCH 10/15] Update package reference versions --- src/ProjectLevel.ruleset | 5 +- src/Ubiety.Dns.Core/AdditionalRR.cs | 2 +- src/Ubiety.Dns.Core/AnswerRR.cs | 2 +- src/Ubiety.Dns.Core/AuthorityRR.cs | 2 +- src/Ubiety.Dns.Core/Common/OperationClass.cs | 3 +- src/Ubiety.Dns.Core/Common/OperationCode.cs | 4 +- src/Ubiety.Dns.Core/Common/QuestionClass.cs | 3 +- src/Ubiety.Dns.Core/Common/QuestionType.cs | 2 - src/Ubiety.Dns.Core/Common/RecordType.cs | 2 - .../Common/VerboseEventArgs.cs | 6 +- .../Common/VerboseOutputEventArgs.cs | 10 +- src/Ubiety.Dns.Core/Header.cs | 98 ++--- src/Ubiety.Dns.Core/Question.cs | 74 ++-- src/Ubiety.Dns.Core/RecordReader.cs | 66 +-- .../Records/General/RecordA.cs | 54 ++- .../Records/General/RecordAAAA.cs | 43 +- .../Records/General/RecordCNAME.cs | 12 +- src/Ubiety.Dns.Core/Records/Mail/RecordMB.cs | 14 +- src/Ubiety.Dns.Core/Records/Mail/RecordMG.cs | 14 +- .../Records/Mail/RecordMINFO.cs | 20 +- src/Ubiety.Dns.Core/Records/Mail/RecordMR.cs | 16 +- src/Ubiety.Dns.Core/Records/Mail/RecordMX.cs | 141 +++--- .../Records/NotUsed/RecordA6.cs | 37 +- .../Records/NotUsed/RecordApl.cs | 2 +- .../Records/NotUsed/RecordAtma.cs | 2 +- .../Records/NotUsed/RecordDNSKey.cs | 2 +- .../Records/NotUsed/RecordDhcid.cs | 2 +- .../Records/NotUsed/RecordEid.cs | 2 +- .../Records/NotUsed/RecordGID.cs | 2 +- .../Records/NotUsed/RecordHIP.cs | 2 +- .../Records/NotUsed/RecordIPSECKEY.cs | 2 +- .../Records/NotUsed/RecordNIMLOC.cs | 2 +- .../Records/NotUsed/RecordNSEC.cs | 2 +- .../Records/NotUsed/RecordNSEC3.cs | 2 +- .../Records/NotUsed/RecordNSEC3PARAM.cs | 2 +- .../Records/NotUsed/RecordOPT.cs | 2 +- .../Records/NotUsed/RecordRRSIG.cs | 2 +- .../Records/NotUsed/RecordSINK.cs | 2 +- .../Records/NotUsed/RecordSPF.cs | 2 +- .../Records/NotUsed/RecordSSHFP.cs | 2 +- .../Records/NotUsed/RecordUID.cs | 2 +- .../Records/NotUsed/RecordUINFO.cs | 2 +- .../Records/NotUsed/RecordUNSPEC.cs | 2 +- .../Records/NotUsed/RecordUnknown.cs | 2 +- .../Records/Obsolete/RecordGPOS.cs | 26 +- .../Records/Obsolete/RecordMD.cs | 15 +- .../Records/Obsolete/RecordMF.cs | 15 +- .../Records/Obsolete/RecordNSAPPTR.cs | 12 +- .../Records/Obsolete/RecordNXT.cs | 52 +-- src/Ubiety.Dns.Core/Records/Record.cs | 29 +- src/Ubiety.Dns.Core/Records/RecordAFSDB.cs | 63 ++- src/Ubiety.Dns.Core/Records/RecordCERT.cs | 38 +- src/Ubiety.Dns.Core/Records/RecordDNAME.cs | 15 +- src/Ubiety.Dns.Core/Records/RecordDS.cs | 40 +- src/Ubiety.Dns.Core/Records/RecordHINFO.cs | 22 +- src/Ubiety.Dns.Core/Records/RecordISDN.cs | 16 +- src/Ubiety.Dns.Core/Records/RecordKEY.cs | 24 +- src/Ubiety.Dns.Core/Records/RecordKX.cs | 168 ++++---- src/Ubiety.Dns.Core/Records/RecordLOC.cs | 78 ++-- src/Ubiety.Dns.Core/Records/RecordNAPTR.cs | 32 +- src/Ubiety.Dns.Core/Records/RecordNS.cs | 12 +- src/Ubiety.Dns.Core/Records/RecordNSAP.cs | 45 +- src/Ubiety.Dns.Core/Records/RecordNULL.cs | 16 +- src/Ubiety.Dns.Core/Records/RecordPTR.cs | 10 +- src/Ubiety.Dns.Core/Records/RecordPX.cs | 20 +- src/Ubiety.Dns.Core/Records/RecordRP.cs | 16 +- src/Ubiety.Dns.Core/Records/RecordRT.cs | 16 +- src/Ubiety.Dns.Core/Records/RecordSIG.cs | 47 +- src/Ubiety.Dns.Core/Records/RecordSOA.cs | 34 +- src/Ubiety.Dns.Core/Records/RecordSRV.cs | 24 +- src/Ubiety.Dns.Core/Records/RecordTKEY.cs | 55 ++- src/Ubiety.Dns.Core/Records/RecordTSIG.cs | 58 +-- src/Ubiety.Dns.Core/Records/RecordTXT.cs | 12 +- src/Ubiety.Dns.Core/Records/RecordWKS.cs | 25 +- src/Ubiety.Dns.Core/Records/RecordX25.cs | 12 +- src/Ubiety.Dns.Core/Request.cs | 40 +- src/Ubiety.Dns.Core/Resolver.cs | 403 ++++++++---------- src/Ubiety.Dns.Core/ResourceRecord.cs | 62 ++- src/Ubiety.Dns.Core/Response.cs | 162 +++---- src/Ubiety.Dns.Core/stylecop.json | 3 + .../Records/NotUsed/RecordA6Tests.cs | 9 +- .../Records/NotUsed/RecordAplTests.cs | 9 +- test/Ubiety.Dns.Test/Records/RecordATests.cs | 7 +- .../Records/RecordAaaaTests.cs | 7 +- test/Ubiety.Dns.Test/Ubiety.Dns.Test.csproj | 10 +- 85 files changed, 1129 insertions(+), 1302 deletions(-) diff --git a/src/ProjectLevel.ruleset b/src/ProjectLevel.ruleset index 3ff60a8..08e7823 100644 --- a/src/ProjectLevel.ruleset +++ b/src/ProjectLevel.ruleset @@ -4,5 +4,8 @@ + + + - \ No newline at end of file + diff --git a/src/Ubiety.Dns.Core/AdditionalRR.cs b/src/Ubiety.Dns.Core/AdditionalRR.cs index 7aba538..0017cd6 100644 --- a/src/Ubiety.Dns.Core/AdditionalRR.cs +++ b/src/Ubiety.Dns.Core/AdditionalRR.cs @@ -14,4 +14,4 @@ public AdditionalRR(RecordReader br) { } } -} +} \ No newline at end of file diff --git a/src/Ubiety.Dns.Core/AnswerRR.cs b/src/Ubiety.Dns.Core/AnswerRR.cs index d9621a4..6d8c75d 100644 --- a/src/Ubiety.Dns.Core/AnswerRR.cs +++ b/src/Ubiety.Dns.Core/AnswerRR.cs @@ -14,4 +14,4 @@ public AnswerRR(RecordReader br) { } } -} +} \ No newline at end of file diff --git a/src/Ubiety.Dns.Core/AuthorityRR.cs b/src/Ubiety.Dns.Core/AuthorityRR.cs index 231add0..2d7b9c4 100644 --- a/src/Ubiety.Dns.Core/AuthorityRR.cs +++ b/src/Ubiety.Dns.Core/AuthorityRR.cs @@ -14,4 +14,4 @@ public AuthorityRR(RecordReader br) { } } -} +} \ No newline at end of file diff --git a/src/Ubiety.Dns.Core/Common/OperationClass.cs b/src/Ubiety.Dns.Core/Common/OperationClass.cs index 3e5fade..b0ca18c 100644 --- a/src/Ubiety.Dns.Core/Common/OperationClass.cs +++ b/src/Ubiety.Dns.Core/Common/OperationClass.cs @@ -1,4 +1,3 @@ -using System; using System.Diagnostics.CodeAnalysis; namespace Ubiety.Dns.Core.Common @@ -7,7 +6,7 @@ namespace Ubiety.Dns.Core.Common /// Resource record class /// [SuppressMessage("Microsoft.Naming", "CA1717", Justification = "Class is not plural")] - public enum OperationClass : UInt16 + public enum OperationClass : ushort { /// /// Internet class diff --git a/src/Ubiety.Dns.Core/Common/OperationCode.cs b/src/Ubiety.Dns.Core/Common/OperationCode.cs index a24e3a8..1245d32 100644 --- a/src/Ubiety.Dns.Core/Common/OperationCode.cs +++ b/src/Ubiety.Dns.Core/Common/OperationCode.cs @@ -83,6 +83,6 @@ public enum OperationCode /// /// Reserved /// - RESERVED15 = 15, + RESERVED15 = 15 } -} +} \ No newline at end of file diff --git a/src/Ubiety.Dns.Core/Common/QuestionClass.cs b/src/Ubiety.Dns.Core/Common/QuestionClass.cs index caa6054..8fb77ea 100644 --- a/src/Ubiety.Dns.Core/Common/QuestionClass.cs +++ b/src/Ubiety.Dns.Core/Common/QuestionClass.cs @@ -1,4 +1,3 @@ -using System; using System.Diagnostics.CodeAnalysis; namespace Ubiety.Dns.Core.Common @@ -7,7 +6,7 @@ namespace Ubiety.Dns.Core.Common /// Question class /// [SuppressMessage("Microsoft.Naming", "CA1717", Justification = "Class is not plural")] - public enum QuestionClass : UInt16 + public enum QuestionClass : ushort { /// /// Internet class diff --git a/src/Ubiety.Dns.Core/Common/QuestionType.cs b/src/Ubiety.Dns.Core/Common/QuestionType.cs index 7b3ec84..79bad5e 100644 --- a/src/Ubiety.Dns.Core/Common/QuestionType.cs +++ b/src/Ubiety.Dns.Core/Common/QuestionType.cs @@ -1,5 +1,3 @@ -using System; - namespace Ubiety.Dns.Core.Common { /// diff --git a/src/Ubiety.Dns.Core/Common/RecordType.cs b/src/Ubiety.Dns.Core/Common/RecordType.cs index bfdf01a..3ef05a4 100644 --- a/src/Ubiety.Dns.Core/Common/RecordType.cs +++ b/src/Ubiety.Dns.Core/Common/RecordType.cs @@ -1,5 +1,3 @@ -using System; - namespace Ubiety.Dns.Core.Common { /// diff --git a/src/Ubiety.Dns.Core/Common/VerboseEventArgs.cs b/src/Ubiety.Dns.Core/Common/VerboseEventArgs.cs index a135e63..ca8b7e2 100644 --- a/src/Ubiety.Dns.Core/Common/VerboseEventArgs.cs +++ b/src/Ubiety.Dns.Core/Common/VerboseEventArgs.cs @@ -11,14 +11,14 @@ public class VerboseEventArgs : EventArgs /// Initializes a new instance of the class /// /// Verbose message - public VerboseEventArgs(String message) + public VerboseEventArgs(string message) { - this.Message = message; + Message = message; } /// /// Gets or sets the message to output /// - public String Message { get; set; } + public string Message { get; set; } } } \ No newline at end of file diff --git a/src/Ubiety.Dns.Core/Common/VerboseOutputEventArgs.cs b/src/Ubiety.Dns.Core/Common/VerboseOutputEventArgs.cs index 01a7131..0ec8daf 100644 --- a/src/Ubiety.Dns.Core/Common/VerboseOutputEventArgs.cs +++ b/src/Ubiety.Dns.Core/Common/VerboseOutputEventArgs.cs @@ -1,6 +1,6 @@ using System; -namespace Ubiety.Dns.Core +namespace Ubiety.Dns.Core.Common { /// /// Event args for verbose output @@ -11,14 +11,14 @@ public class VerboseOutputEventArgs : EventArgs /// Initializes a new instance of the class /// /// Message to output - public VerboseOutputEventArgs(String message) + public VerboseOutputEventArgs(string message) { - this.Message = message; + Message = message; } /// - /// Gets or sets the string message + /// Gets the string message /// - public String Message { get; set; } + public string Message { get; } } } \ No newline at end of file diff --git a/src/Ubiety.Dns.Core/Header.cs b/src/Ubiety.Dns.Core/Header.cs index 5053078..54188b0 100644 --- a/src/Ubiety.Dns.Core/Header.cs +++ b/src/Ubiety.Dns.Core/Header.cs @@ -1,8 +1,6 @@ using System; using System.Collections.Generic; -using System.IO; using System.Net; -using System.Text; using Ubiety.Dns.Core.Common; namespace Ubiety.Dns.Core @@ -13,7 +11,7 @@ namespace Ubiety.Dns.Core public class Header { // internal flag - private UInt16 flags; + private UInt16 _flags; /// /// Initializes a new instance of the class @@ -28,12 +26,12 @@ public Header() /// of the record public Header(RecordReader rr) { - this.Id = rr.ReadUInt16(); - this.flags = rr.ReadUInt16(); - this.QuestionCount = rr.ReadUInt16(); - this.AnswerCount = rr.ReadUInt16(); - this.NameserverCount = rr.ReadUInt16(); - this.AdditionalRecordsCount = rr.ReadUInt16(); + Id = rr.ReadUInt16(); + _flags = rr.ReadUInt16(); + QuestionCount = rr.ReadUInt16(); + AnswerCount = rr.ReadUInt16(); + NameserverCount = rr.ReadUInt16(); + AdditionalRecordsCount = rr.ReadUInt16(); } /// @@ -66,11 +64,8 @@ public Header(RecordReader rr) /// public Boolean QueryResponse { - get => GetBits(this.flags, 15, 1) == 1; - set - { - this.flags = SetBits(this.flags, 15, 1, value); - } + get => GetBits(_flags, 15, 1) == 1; + set => _flags = SetBits(_flags, 15, 1, value); } /// @@ -78,11 +73,8 @@ public Boolean QueryResponse /// public OperationCode OpCode { - get => (OperationCode)GetBits(this.flags, 11, 4); - set - { - this.flags = SetBits(this.flags, 11, 4, (UInt16)value); - } + get => (OperationCode)GetBits(_flags, 11, 4); + set => _flags = SetBits(_flags, 11, 4, (UInt16)value); } /// @@ -90,11 +82,8 @@ public OperationCode OpCode /// public Boolean AuthoritativeAnswer { - get => GetBits(this.flags, 10, 1) == 1; - set - { - this.flags = SetBits(this.flags, 10, 1, value); - } + get => GetBits(_flags, 10, 1) == 1; + set => _flags = SetBits(_flags, 10, 1, value); } /// @@ -102,11 +91,8 @@ public Boolean AuthoritativeAnswer /// public Boolean Truncation { - get => GetBits(this.flags, 9, 1) == 1; - set - { - this.flags = SetBits(this.flags, 9, 1, value); - } + get => GetBits(_flags, 9, 1) == 1; + set => _flags = SetBits(_flags, 9, 1, value); } /// @@ -114,11 +100,8 @@ public Boolean Truncation /// public Boolean Recursion { - get => GetBits(this.flags, 8, 1) == 1; - set - { - this.flags = SetBits(this.flags, 8, 1, value); - } + get => GetBits(_flags, 8, 1) == 1; + set => _flags = SetBits(_flags, 8, 1, value); } /// @@ -126,11 +109,8 @@ public Boolean Recursion /// public Boolean RA { - get => GetBits(this.flags, 7, 1) == 1; - set - { - this.flags = SetBits(this.flags, 7, 1, value); - } + get => GetBits(_flags, 7, 1) == 1; + set => _flags = SetBits(_flags, 7, 1, value); } /// @@ -138,11 +118,8 @@ public Boolean RA /// public UInt16 Z { - get => GetBits(this.flags, 4, 3); - set - { - this.flags = SetBits(this.flags, 4, 3, value); - } + get => GetBits(_flags, 4, 3); + set => _flags = SetBits(_flags, 4, 3, value); } /// @@ -150,26 +127,23 @@ public UInt16 Z /// public ResponseCode ResponseCode { - get => (ResponseCode)GetBits(this.flags, 0, 4); - set - { - this.flags = SetBits(this.flags, 0, 4, (UInt16)value); - } + get => (ResponseCode)GetBits(_flags, 0, 4); + set => _flags = SetBits(_flags, 0, 4, (UInt16)value); } /// /// Gets the header as a byte array /// /// Byte array of the header data - public Byte[] GetData() + public IEnumerable GetData() { - List data = new List(); - data.AddRange(WriteShort(this.Id)); - data.AddRange(WriteShort(this.flags)); - data.AddRange(WriteShort(this.QuestionCount)); - data.AddRange(WriteShort(this.AnswerCount)); - data.AddRange(WriteShort(this.NameserverCount)); - data.AddRange(WriteShort(this.AdditionalRecordsCount)); + var data = new List(); + data.AddRange(WriteShort(Id)); + data.AddRange(WriteShort(_flags)); + data.AddRange(WriteShort(QuestionCount)); + data.AddRange(WriteShort(AnswerCount)); + data.AddRange(WriteShort(NameserverCount)); + data.AddRange(WriteShort(AdditionalRecordsCount)); return data.ToArray(); } @@ -187,7 +161,7 @@ private static UInt16 SetBits(UInt16 oldValue, Int32 position, Int32 length, UIn } // get some mask to put on - Int32 mask = (2 << (length - 1)) - 1; + var mask = (2 << (length - 1)) - 1; // clear out value oldValue &= (UInt16)~(mask << position); @@ -206,15 +180,15 @@ private static UInt16 GetBits(UInt16 oldValue, Int32 position, Int32 length) } // get some mask to put on - Int32 mask = (2 << (length - 1)) - 1; + var mask = (2 << (length - 1)) - 1; // shift down to get some value and mask it return (UInt16)((oldValue >> position) & mask); } - private static Byte[] WriteShort(UInt16 sValue) + private static IEnumerable WriteShort(UInt16 value) { - return BitConverter.GetBytes(IPAddress.HostToNetworkOrder((Int16)sValue)); + return BitConverter.GetBytes(IPAddress.HostToNetworkOrder((Int16)value)); } } -} +} \ No newline at end of file diff --git a/src/Ubiety.Dns.Core/Question.cs b/src/Ubiety.Dns.Core/Question.cs index fdabf0d..92896d2 100644 --- a/src/Ubiety.Dns.Core/Question.cs +++ b/src/Ubiety.Dns.Core/Question.cs @@ -1,7 +1,5 @@ using System; using System.Collections.Generic; -using System.Globalization; -using System.IO; using System.Net; using System.Text; using Ubiety.Dns.Core.Common; @@ -13,7 +11,7 @@ namespace Ubiety.Dns.Core /// public class Question { - private String questionName; + private string _questionName; /// /// Initializes a new instance of the class @@ -21,11 +19,11 @@ public class Question /// Query name /// Question type /// Question class - public Question(String questionName, QuestionType questionType, QuestionClass questionClass) + public Question(string questionName, QuestionType questionType, QuestionClass questionClass) { - this.QuestionName = questionName; - this.QuestionType = questionType; - this.QuestionClass = questionClass; + QuestionName = questionName; + QuestionType = questionType; + QuestionClass = questionClass; } /// @@ -34,40 +32,34 @@ public Question(String questionName, QuestionType questionType, QuestionClass qu /// of the record public Question(RecordReader rr) { - this.QuestionName = rr.ReadDomainName(); - this.QuestionType = (QuestionType)rr.ReadUInt16(); - this.QuestionClass = (QuestionClass)rr.ReadUInt16(); + QuestionName = rr.ReadDomainName(); + QuestionType = (QuestionType)rr.ReadUInt16(); + QuestionClass = (QuestionClass)rr.ReadUInt16(); } /// - /// Gets or sets the question name + /// Gets the question name /// public String QuestionName { - get - { - return this.questionName; - } + get => _questionName; - set + private set { - this.questionName = value; - if (!this.questionName.EndsWith(".", StringComparison.InvariantCulture)) - { - this.questionName += "."; - } + _questionName = value; + if (!_questionName.EndsWith(".", StringComparison.InvariantCulture)) _questionName += "."; } } /// - /// Gets or sets the query type + /// Gets the query type /// - public QuestionType QuestionType { get; set; } + public QuestionType QuestionType { get; } /// - /// Gets or sets the query class + /// Gets the query class /// - public QuestionClass QuestionClass { get; set; } + public QuestionClass QuestionClass { get; } /// /// String representation of the question @@ -75,23 +67,23 @@ public String QuestionName /// String of the question public override String ToString() { - return string.Format(CultureInfo.InvariantCulture, "{0,-32}\t{1}\t{2}", this.QuestionName, this.QuestionClass, this.QuestionType); + return $"{QuestionName,-32}\t{QuestionClass}\t{QuestionType}"; } /// /// Gets the question as a byte array /// /// Byte array of the question data - public Byte[] GetData() + public IEnumerable GetData() { - List data = new List(); - data.AddRange(WriteName(this.QuestionName)); - data.AddRange(WriteShort((UInt16)this.QuestionType)); - data.AddRange(WriteShort((UInt16)this.QuestionClass)); + var data = new List(); + data.AddRange(WriteName(QuestionName)); + data.AddRange(WriteShort((UInt16)QuestionType)); + data.AddRange(WriteShort((UInt16)QuestionClass)); return data.ToArray(); } - private static Byte[] WriteName(String src) + private static IEnumerable WriteName(String src) { if (!src.EndsWith(".", StringComparison.InvariantCulture)) { @@ -103,26 +95,28 @@ private static Byte[] WriteName(String src) return new Byte[1]; } - StringBuilder sb = new StringBuilder(); + var sb = new StringBuilder(); Int32 intI, intJ, intLen = src.Length; sb.Append('\0'); for (intI = 0, intJ = 0; intI < intLen; intI++, intJ++) { sb.Append(src[intI]); - if (src[intI] == '.') + if (src[intI] != '.') { - sb[intI - intJ] = (Char)(intJ & 0xff); - intJ = -1; + continue; } + + sb[intI - intJ] = (Char)(intJ & 0xff); + intJ = -1; } sb[sb.Length - 1] = '\0'; - return System.Text.Encoding.ASCII.GetBytes(sb.ToString()); + return Encoding.ASCII.GetBytes(sb.ToString()); } - private static Byte[] WriteShort(UInt16 sValue) + private static Byte[] WriteShort(UInt16 value) { - return BitConverter.GetBytes(IPAddress.HostToNetworkOrder((Int16)sValue)); + return BitConverter.GetBytes(IPAddress.HostToNetworkOrder((Int16)value)); } } -} +} \ No newline at end of file diff --git a/src/Ubiety.Dns.Core/RecordReader.cs b/src/Ubiety.Dns.Core/RecordReader.cs index 034508b..bf17fda 100644 --- a/src/Ubiety.Dns.Core/RecordReader.cs +++ b/src/Ubiety.Dns.Core/RecordReader.cs @@ -15,7 +15,7 @@ namespace Ubiety.Dns.Core /// public class RecordReader { - private readonly Byte[] data; + private readonly Byte[] _data; /// /// Initializes a new instance of the class @@ -23,8 +23,8 @@ public class RecordReader /// Byte array of the record public RecordReader(Byte[] data) { - this.data = data; - this.Position = 0; + _data = data; + Position = 0; } /// @@ -34,8 +34,8 @@ public RecordReader(Byte[] data) /// Position of the cursor in the record public RecordReader(Byte[] data, Int32 position) { - this.data = data; - this.Position = position; + _data = data; + Position = position; } /// @@ -49,14 +49,7 @@ public RecordReader(Byte[] data, Int32 position) /// Next available byte of the record public Byte ReadByte() { - if (this.Position >= this.data.Length) - { - return 0; - } - else - { - return this.data[this.Position++]; - } + return Position >= _data.Length ? (Byte)0 : _data[Position++]; } /// @@ -65,7 +58,7 @@ public Byte ReadByte() /// Next available char of the record public Char ReadChar() { - return (char)this.ReadByte(); + return (Char)ReadByte(); } /// @@ -74,7 +67,7 @@ public Char ReadChar() /// Next available unsigned int 16 of the record public UInt16 ReadUInt16() { - return (UInt16)(this.ReadByte() << 8 | this.ReadByte()); + return (UInt16)((ReadByte() << 8) | ReadByte()); } /// @@ -84,8 +77,8 @@ public UInt16 ReadUInt16() /// Next unsigned int 16 from the offset public UInt16 ReadUInt16(Int32 offset) { - this.Position += offset; - return this.ReadUInt16(); + Position += offset; + return ReadUInt16(); } /// @@ -94,7 +87,7 @@ public UInt16 ReadUInt16(Int32 offset) /// Next available unsigned int 32 in the record public UInt32 ReadUInt32() { - return (UInt32)(this.ReadUInt16() << 16 | this.ReadUInt16()); + return (UInt32)((ReadUInt16() << 16) | ReadUInt16()); } /// @@ -103,17 +96,17 @@ public UInt32 ReadUInt32() /// Domain name of the record public String ReadDomainName() { - StringBuilder name = new StringBuilder(); - Int32 length = 0; + var name = new StringBuilder(); + Int32 length; // get the length of the first label - while ((length = this.ReadByte()) != 0) + while ((length = ReadByte()) != 0) { // top 2 bits set denotes domain name compression and to reference elsewhere if ((length & 0xc0) == 0xc0) { // work out the existing domain name, copy this pointer - RecordReader newRecordReader = new RecordReader(this.data, (length & 0x3f) << 8 | this.ReadByte()); + var newRecordReader = new RecordReader(_data, ((length & 0x3f) << 8) | ReadByte()); name.Append(newRecordReader.ReadDomainName()); return name.ToString(); @@ -122,21 +115,14 @@ public String ReadDomainName() // if not using compression, copy a char at a time to the domain name while (length > 0) { - name.Append(this.ReadChar()); + name.Append(ReadChar()); length--; } name.Append('.'); } - if (name.Length == 0) - { - return "."; - } - else - { - return name.ToString(); - } + return name.Length == 0 ? "." : name.ToString(); } /// @@ -145,13 +131,10 @@ public String ReadDomainName() /// String read from the record public String ReadString() { - Int16 length = this.ReadByte(); + Int16 length = ReadByte(); - StringBuilder name = new StringBuilder(); - for (int i = 0; i < length; i++) - { - name.Append(this.ReadChar()); - } + var name = new StringBuilder(); + for (var i = 0; i < length; i++) name.Append(ReadChar()); return name.ToString(); } @@ -163,11 +146,8 @@ public String ReadString() /// Byte array read from the record public Byte[] ReadBytes(Int32 length) { - List list = new List(); - for (Int32 i = 0; i < length; i++) - { - list.Add(this.ReadByte()); - } + var list = new List(); + for (var i = 0; i < length; i++) list.Add(ReadByte()); return list.ToArray(); } @@ -304,4 +284,4 @@ public Record ReadRecord(RecordType type) } } } -} +} \ No newline at end of file diff --git a/src/Ubiety.Dns.Core/Records/General/RecordA.cs b/src/Ubiety.Dns.Core/Records/General/RecordA.cs index 34476f4..575b8d1 100644 --- a/src/Ubiety.Dns.Core/Records/General/RecordA.cs +++ b/src/Ubiety.Dns.Core/Records/General/RecordA.cs @@ -1,59 +1,53 @@ using System; -using System.Globalization; using System.Net; namespace Ubiety.Dns.Core.Records.General { /// - /// IPv4 Address DNS record + /// IPv4 Address DNS record /// /// - /// # [Description](#tab/description) - /// A Records are the most basic type of DNS record and are used to point - /// a domain or subdomain to an IP address. - /// - /// # [RFC](#tab/rfc) - /// ``` - /// A RDATA format - /// - /// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - /// | ADDRESS | - /// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - /// - /// where: - /// - /// ADDRESS A 32 bit internet address - /// - /// Hosts that have multiple internet address will have multiple A - /// records. - /// ``` + /// # [Description](#tab/description) + /// A Records are the most basic type of DNS record and are used to point + /// a domain or subdomain to an IP address. + /// # [RFC](#tab/rfc) + /// ``` + /// A RDATA format + /// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ + /// | ADDRESS | + /// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ + /// where: + /// ADDRESS A 32 bit internet address + /// Hosts that have multiple internet address will have multiple A + /// records. + /// ``` /// public class RecordA : Record { - private readonly String address; + private readonly String _address; /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// for the record data public RecordA(RecordReader reader) { - this.address = $"{reader.ReadByte()}.{reader.ReadByte()}.{reader.ReadByte()}.{reader.ReadByte()}"; + _address = $"{reader.ReadByte()}.{reader.ReadByte()}.{reader.ReadByte()}.{reader.ReadByte()}"; } /// - /// Gets the IP address + /// Gets the IP address /// /// IP address of the A record - public IPAddress Address { get => IPAddress.Parse(this.address); } + public IPAddress Address => IPAddress.Parse(_address); /// - /// String representation of the address + /// String representation of the address /// /// String of the IP address - public override String ToString() + public override string ToString() { - return this.address; + return _address; } } -} +} \ No newline at end of file diff --git a/src/Ubiety.Dns.Core/Records/General/RecordAAAA.cs b/src/Ubiety.Dns.Core/Records/General/RecordAAAA.cs index 2479ebb..75b7aca 100644 --- a/src/Ubiety.Dns.Core/Records/General/RecordAAAA.cs +++ b/src/Ubiety.Dns.Core/Records/General/RecordAAAA.cs @@ -1,52 +1,45 @@ -using System; -using System.Globalization; using System.Net; namespace Ubiety.Dns.Core.Records.General { /// - /// IPv6 Address record + /// IPv6 Address record /// /// - /// # [Description](#tab/description) - /// - /// The AAAA resource record type is a record specific to the Internet - /// class that stores a single IPv6 address - /// - /// # [RFC](#tab/rfc) - /// - /// ``` - /// A 128 bit IPv6 address is encoded in the data portion of an AAAA - /// resource record in network byte order (high-order byte first) - /// ``` + /// # [Description](#tab/description) + /// The AAAA resource record type is a record specific to the Internet + /// class that stores a single IPv6 address + /// # [RFC](#tab/rfc) + /// ``` + /// A 128 bit IPv6 address is encoded in the data portion of an AAAA + /// resource record in network byte order (high-order byte first) + /// ``` /// public class RecordAaaa : Record { - private readonly IPAddress address; - /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// for the record data public RecordAaaa(RecordReader reader) { - this.address = IPAddress.Parse( - $"{reader.ReadUInt16():x4}:{reader.ReadUInt16():x4}:{reader.ReadUInt16():x4}:{reader.ReadUInt16():x4}:{reader.ReadUInt16():x4}:{reader.ReadUInt16():x4}:{reader.ReadUInt16():x4}:{reader.ReadUInt16():x4}"); + Address = IPAddress.Parse( + $"{reader.ReadUInt16():x4}:{reader.ReadUInt16():x4}:{reader.ReadUInt16():x4}:{reader.ReadUInt16():x4}:{reader.ReadUInt16():x4}:{reader.ReadUInt16():x4}:{reader.ReadUInt16():x4}:{reader.ReadUInt16():x4}"); } /// - /// Gets the IP address of the record + /// Gets the IP address of the record /// /// IP address of the AAAA record - public IPAddress Address { get => this.address; } + public IPAddress Address { get; } /// - /// String version of the record + /// String version of the record /// /// String of the address - public override String ToString() + public override string ToString() { - return this.address.ToString(); + return Address.ToString(); } } -} +} \ No newline at end of file diff --git a/src/Ubiety.Dns.Core/Records/General/RecordCNAME.cs b/src/Ubiety.Dns.Core/Records/General/RecordCNAME.cs index 8ab0e26..7020809 100644 --- a/src/Ubiety.Dns.Core/Records/General/RecordCNAME.cs +++ b/src/Ubiety.Dns.Core/Records/General/RecordCNAME.cs @@ -1,5 +1,3 @@ -using System; - /* * 3.3.1. CNAME RDATA format @@ -33,13 +31,13 @@ public class RecordCname : Record /// for the record data public RecordCname(RecordReader rr) { - this.Cname = rr.ReadDomainName(); + Cname = rr.ReadDomainName(); } /// - /// Gets or sets the canonical name + /// Gets the canonical name /// - public String Cname { get; set; } + public string Cname { get; } /// /// String representation of the record @@ -47,7 +45,7 @@ public RecordCname(RecordReader rr) /// String version of the cname public override string ToString() { - return this.Cname; + return Cname; } } -} +} \ No newline at end of file diff --git a/src/Ubiety.Dns.Core/Records/Mail/RecordMB.cs b/src/Ubiety.Dns.Core/Records/Mail/RecordMB.cs index 8350720..64106c4 100644 --- a/src/Ubiety.Dns.Core/Records/Mail/RecordMB.cs +++ b/src/Ubiety.Dns.Core/Records/Mail/RecordMB.cs @@ -1,4 +1,4 @@ -using System; + /* 3.3.3. MB RDATA format (EXPERIMENTAL) @@ -30,21 +30,21 @@ public class RecordMb : Record /// for the record data public RecordMb(RecordReader rr) { - this.MadName = rr.ReadDomainName(); + MadName = rr.ReadDomainName(); } /// - /// Gets or sets the mailbox domain + /// Gets the mailbox domain /// - public String MadName { get; set; } + public string MadName { get; } /// /// String representation of the record data /// /// String version of the domain - public override String ToString() + public override string ToString() { - return this.MadName; + return MadName; } } -} +} \ No newline at end of file diff --git a/src/Ubiety.Dns.Core/Records/Mail/RecordMG.cs b/src/Ubiety.Dns.Core/Records/Mail/RecordMG.cs index b018f39..33805ee 100644 --- a/src/Ubiety.Dns.Core/Records/Mail/RecordMG.cs +++ b/src/Ubiety.Dns.Core/Records/Mail/RecordMG.cs @@ -1,4 +1,4 @@ -using System; + /* 3.3.6. MG RDATA format (EXPERIMENTAL) @@ -29,21 +29,21 @@ public class RecordMg : Record /// for the record data public RecordMg(RecordReader rr) { - this.MgmName = rr.ReadDomainName(); + MgmName = rr.ReadDomainName(); } /// - /// Gets or sets the mail group name + /// Gets the mail group name /// - public String MgmName { get; set; } + public string MgmName { get; } /// /// String representation of the record /// /// Mail group name as a string - public override String ToString() + public override string ToString() { - return this.MgmName; + return MgmName; } } -} +} \ No newline at end of file diff --git a/src/Ubiety.Dns.Core/Records/Mail/RecordMINFO.cs b/src/Ubiety.Dns.Core/Records/Mail/RecordMINFO.cs index 70fbee6..8a9d095 100644 --- a/src/Ubiety.Dns.Core/Records/Mail/RecordMINFO.cs +++ b/src/Ubiety.Dns.Core/Records/Mail/RecordMINFO.cs @@ -1,5 +1,3 @@ -using System; - /* 3.3.7. MINFO RDATA format (EXPERIMENTAL) @@ -32,6 +30,8 @@ MINFO records cause no additional section processing. Although these with a mailing list. */ +using System; + namespace Ubiety.Dns.Core.Records.Mail { /// @@ -45,19 +45,19 @@ public class RecordMinfo : Record /// for the record data public RecordMinfo(RecordReader rr) { - this.ResponsibleMailbox = rr.ReadDomainName(); - this.ErrorMailbox = rr.ReadDomainName(); + ResponsibleMailbox = rr.ReadDomainName(); + ErrorMailbox = rr.ReadDomainName(); } /// - /// Gets or sets the responsible mailbox + /// Gets the responsible mailbox /// - public String ResponsibleMailbox { get; set; } + public String ResponsibleMailbox { get; } /// - /// Gets or sets the error mailbox + /// Gets the error mailbox /// - public String ErrorMailbox { get; set; } + public String ErrorMailbox { get; } /// /// String representation of the record @@ -65,7 +65,7 @@ public RecordMinfo(RecordReader rr) /// String version of the domains public override String ToString() { - return $"{this.ResponsibleMailbox} {this.ErrorMailbox}"; + return $"{ResponsibleMailbox} {ErrorMailbox}"; } } -} +} \ No newline at end of file diff --git a/src/Ubiety.Dns.Core/Records/Mail/RecordMR.cs b/src/Ubiety.Dns.Core/Records/Mail/RecordMR.cs index 04b20f2..ddc8e69 100644 --- a/src/Ubiety.Dns.Core/Records/Mail/RecordMR.cs +++ b/src/Ubiety.Dns.Core/Records/Mail/RecordMR.cs @@ -1,5 +1,3 @@ -using System; - /* 3.3.8. MR RDATA format (EXPERIMENTAL) @@ -18,6 +16,8 @@ proper rename of the specified mailbox. mailbox. */ +using System; + namespace Ubiety.Dns.Core.Records.Mail { /// @@ -31,21 +31,21 @@ public class RecordMr : Record /// for the record data public RecordMr(RecordReader rr) { - this.NewName = rr.ReadDomainName(); + NewName = rr.ReadDomainName(); } /// - /// Gets or sets the new name + /// Gets the new name /// - public String NewName { get; set; } + public String NewName { get; } /// /// String representation of the record data /// /// Rename domain from the record - public override String ToString() + public override string ToString() { - return this.NewName; + return NewName; } } -} +} \ No newline at end of file diff --git a/src/Ubiety.Dns.Core/Records/Mail/RecordMX.cs b/src/Ubiety.Dns.Core/Records/Mail/RecordMX.cs index 72ca7f3..c1fa00c 100644 --- a/src/Ubiety.Dns.Core/Records/Mail/RecordMX.cs +++ b/src/Ubiety.Dns.Core/Records/Mail/RecordMX.cs @@ -4,103 +4,108 @@ namespace Ubiety.Dns.Core.Records.Mail { /// - /// Mail exchange DNS record + /// Mail exchange DNS record /// /// - /// # [Description](#tab/description) - /// Standard MX mail DNS record - /// - /// # [RFC](#tab/rfc) - /// ``` - /// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - /// | PREFERENCE | - /// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - /// / EXCHANGE / - /// / / - /// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - /// - /// where: - /// - /// PREFERENCE A 16 bit integer which specifies the preference given to - /// this RR among others at the same owner. Lower values - /// are preferred. - /// - /// EXCHANGE A [domain-name] which specifies a host willing to act as - /// a mail exchange for the owner name. - /// - /// MX records cause type A additional section processing for the host - /// specified by EXCHANGE. The use of MX RRs is explained in detail in - /// [RFC-974]. - /// ``` + /// # [Description](#tab/description) + /// Standard MX mail DNS record + /// # [RFC](#tab/rfc) + /// ``` + /// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ + /// | PREFERENCE | + /// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ + /// / EXCHANGE / + /// / / + /// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ + /// where: + /// PREFERENCE A 16 bit integer which specifies the preference given to + /// this RR among others at the same owner. Lower values + /// are preferred. + /// EXCHANGE A [domain-name] which specifies a host willing to act as + /// a mail exchange for the owner name. + /// MX records cause type A additional section processing for the host + /// specified by EXCHANGE. The use of MX RRs is explained in detail in + /// [RFC-974]. + /// ``` /// public sealed class RecordMx : Record, IComparable, IEquatable { /// - /// Initializes a new instance of the class + /// Initializes a new instance of the class /// /// for the record data public RecordMx(RecordReader rr) { - this.Preference = rr.ReadUInt16(); - this.Exchange = rr.ReadDomainName(); + Preference = rr.ReadUInt16(); + Exchange = rr.ReadDomainName(); } /// - /// Gets or sets the preference + /// Gets the preference /// - public UInt16 Preference { get; set; } + public UInt16 Preference { get; } /// - /// Gets or sets the exchange + /// Gets the exchange /// - public String Exchange { get; set; } + public String Exchange { get; } /// - /// String representation of the record data + /// Compares record to an object /// - /// Exchange and preference as a string - public override String ToString() + /// Object to compare record to + /// Int value of the comparison + public Int32 CompareTo(Object obj) { - return $"{this.Preference} {this.Exchange}"; + return CompareTo(this, obj as RecordMx); } /// - /// Compares record to an object + /// Does this instance equal another instance of RecordMx /// - /// Object to compare record to - /// Int value of the comparison - public int CompareTo(object obj) + /// RecordMx to compare to + /// Boolean indicating whether the objects are equal + public Boolean Equals(RecordMx other) { - return CompareTo(this, obj as RecordMx); + if (other is null) + { + return false; + } + + return CompareTo(this, other) == 0; + } + + /// + /// String representation of the record data + /// + /// Exchange and preference as a string + public override String ToString() + { + return $"{Preference} {Exchange}"; } /// - /// Does this instance equal an object + /// Does this instance equal an object /// /// Object to compare to /// Boolean indicating whether the objects are equal - public override Boolean Equals(object obj) + public override Boolean Equals(Object obj) { if (obj is null) { return false; } - if (this.GetType() != obj.GetType()) + if (GetType() != obj.GetType()) { return false; } - if (ReferenceEquals(this, obj)) - { - return true; - } - - return this.Equals(obj as RecordMx); + return ReferenceEquals(this, obj) || Equals(obj as RecordMx); } /// - /// Gets the record hash code + /// Gets the record hash code /// /// Integer representing the hash code public override Int32 GetHashCode() @@ -108,23 +113,10 @@ public override Int32 GetHashCode() return Exchange.GetHashCode(); } - /// - /// Does this instance equal another instance of RecordMx - /// - /// RecordMx to compare to - /// Boolean indicating whether the objects are equal - public Boolean Equals(RecordMx other) - { - if (other is null) - { - return false; - } - - return CompareTo(this, other) == 0; - } - /// /// + /// + /// public static Boolean operator <(RecordMx x, RecordMx y) { return CompareTo(x, y) < 0; @@ -171,19 +163,18 @@ private static Int32 CompareTo(RecordMx x, RecordMx y) { return -1; } - else if (x.Preference > y.Preference) + + if (x.Preference > y.Preference) { return 1; } - else if (x.Preference < y.Preference) + + if (x.Preference < y.Preference) { return -1; } - else - { - // they are the same, now compare case insensitive names - return string.Compare(x.Exchange, y.Exchange, true, CultureInfo.InvariantCulture); - } + + return string.Compare(x.Exchange, y.Exchange, true, CultureInfo.InvariantCulture); } } -} +} \ No newline at end of file diff --git a/src/Ubiety.Dns.Core/Records/NotUsed/RecordA6.cs b/src/Ubiety.Dns.Core/Records/NotUsed/RecordA6.cs index 44dc783..d71f7f8 100644 --- a/src/Ubiety.Dns.Core/Records/NotUsed/RecordA6.cs +++ b/src/Ubiety.Dns.Core/Records/NotUsed/RecordA6.cs @@ -1,34 +1,29 @@ namespace Ubiety.Dns.Core.Records.NotUsed { /// - /// Historic IPv6 record lookup + /// Historic IPv6 record lookup /// /// - /// > [!WARNING] - /// > AAAA is preferred over A6 - /// - /// # [Description](#tab/description) - /// A6 records are defined to map a domain name to an IPv6 address. - /// - /// # [RFC](#tab/rfc) - /// - /// ``` - /// The RDATA portion of the A6 record contains two or three fields - /// - /// +-----------+------------------+-------------------+ - /// |Prefix len.| Address suffix | Prefix name | - /// | (1 octet) | (0..16 octets) | (0..255 octets) | - /// +-----------+------------------+-------------------+ - /// - /// * A prefix length, encoded as an eight-bit unsigned integer with + /// > [!WARNING] + /// > AAAA is preferred over A6 + /// # [Description](#tab/description) + /// A6 records are defined to map a domain name to an IPv6 address. + /// # [RFC](#tab/rfc) + /// ``` + /// The RDATA portion of the A6 record contains two or three fields + /// +-----------+------------------+-------------------+ + /// |Prefix len.| Address suffix | Prefix name | + /// | (1 octet) | (0..16 octets) | (0..255 octets) | + /// +-----------+------------------+-------------------+ + /// * A prefix length, encoded as an eight-bit unsigned integer with /// value between 0 and 128 inclusive - /// * An IPv6 address suffix, encoded in network order (high-order octet + /// * An IPv6 address suffix, encoded in network order (high-order octet /// first). There MUST be exactly enough octets in this field to /// contain a number of bits equal to 128 minus prefix length, with 0 /// to 7 leading pad bits to make this field an integral number of /// octets. Pad bits, if present, MUST be set to zero when loading a /// zone file and ignored. - /// ``` + /// ``` /// public class RecordA6 : Record { @@ -41,4 +36,4 @@ public RecordA6(RecordReader reader) { } } -} +} \ No newline at end of file diff --git a/src/Ubiety.Dns.Core/Records/NotUsed/RecordApl.cs b/src/Ubiety.Dns.Core/Records/NotUsed/RecordApl.cs index db424be..1fca0fa 100644 --- a/src/Ubiety.Dns.Core/Records/NotUsed/RecordApl.cs +++ b/src/Ubiety.Dns.Core/Records/NotUsed/RecordApl.cs @@ -14,4 +14,4 @@ public RecordApl(RecordReader rr) { } } -} +} \ No newline at end of file diff --git a/src/Ubiety.Dns.Core/Records/NotUsed/RecordAtma.cs b/src/Ubiety.Dns.Core/Records/NotUsed/RecordAtma.cs index 1f60d31..7411c17 100644 --- a/src/Ubiety.Dns.Core/Records/NotUsed/RecordAtma.cs +++ b/src/Ubiety.Dns.Core/Records/NotUsed/RecordAtma.cs @@ -14,4 +14,4 @@ public RecordAtma(RecordReader rr) { } } -} +} \ No newline at end of file diff --git a/src/Ubiety.Dns.Core/Records/NotUsed/RecordDNSKey.cs b/src/Ubiety.Dns.Core/Records/NotUsed/RecordDNSKey.cs index c0c5e1b..29f7fb1 100644 --- a/src/Ubiety.Dns.Core/Records/NotUsed/RecordDNSKey.cs +++ b/src/Ubiety.Dns.Core/Records/NotUsed/RecordDNSKey.cs @@ -14,4 +14,4 @@ public RecordDnsKey(RecordReader rr) { } } -} +} \ No newline at end of file diff --git a/src/Ubiety.Dns.Core/Records/NotUsed/RecordDhcid.cs b/src/Ubiety.Dns.Core/Records/NotUsed/RecordDhcid.cs index b462d47..182e484 100644 --- a/src/Ubiety.Dns.Core/Records/NotUsed/RecordDhcid.cs +++ b/src/Ubiety.Dns.Core/Records/NotUsed/RecordDhcid.cs @@ -14,4 +14,4 @@ public RecordDhcid(RecordReader rr) { } } -} +} \ No newline at end of file diff --git a/src/Ubiety.Dns.Core/Records/NotUsed/RecordEid.cs b/src/Ubiety.Dns.Core/Records/NotUsed/RecordEid.cs index c59c0f5..f8a7437 100644 --- a/src/Ubiety.Dns.Core/Records/NotUsed/RecordEid.cs +++ b/src/Ubiety.Dns.Core/Records/NotUsed/RecordEid.cs @@ -14,4 +14,4 @@ public RecordEid(RecordReader rr) { } } -} +} \ No newline at end of file diff --git a/src/Ubiety.Dns.Core/Records/NotUsed/RecordGID.cs b/src/Ubiety.Dns.Core/Records/NotUsed/RecordGID.cs index ffc3db5..c55fc76 100644 --- a/src/Ubiety.Dns.Core/Records/NotUsed/RecordGID.cs +++ b/src/Ubiety.Dns.Core/Records/NotUsed/RecordGID.cs @@ -14,4 +14,4 @@ public RecordGid(RecordReader rr) { } } -} +} \ No newline at end of file diff --git a/src/Ubiety.Dns.Core/Records/NotUsed/RecordHIP.cs b/src/Ubiety.Dns.Core/Records/NotUsed/RecordHIP.cs index 05b9666..9985d90 100644 --- a/src/Ubiety.Dns.Core/Records/NotUsed/RecordHIP.cs +++ b/src/Ubiety.Dns.Core/Records/NotUsed/RecordHIP.cs @@ -14,4 +14,4 @@ public RecordHip(RecordReader rr) { } } -} +} \ No newline at end of file diff --git a/src/Ubiety.Dns.Core/Records/NotUsed/RecordIPSECKEY.cs b/src/Ubiety.Dns.Core/Records/NotUsed/RecordIPSECKEY.cs index c31905d..95df17f 100644 --- a/src/Ubiety.Dns.Core/Records/NotUsed/RecordIPSECKEY.cs +++ b/src/Ubiety.Dns.Core/Records/NotUsed/RecordIPSECKEY.cs @@ -14,4 +14,4 @@ public RecordIpsecKey(RecordReader rr) { } } -} +} \ No newline at end of file diff --git a/src/Ubiety.Dns.Core/Records/NotUsed/RecordNIMLOC.cs b/src/Ubiety.Dns.Core/Records/NotUsed/RecordNIMLOC.cs index 36d1c9f..b86deb9 100644 --- a/src/Ubiety.Dns.Core/Records/NotUsed/RecordNIMLOC.cs +++ b/src/Ubiety.Dns.Core/Records/NotUsed/RecordNIMLOC.cs @@ -14,4 +14,4 @@ public RecordNimloc(RecordReader rr) { } } -} +} \ No newline at end of file diff --git a/src/Ubiety.Dns.Core/Records/NotUsed/RecordNSEC.cs b/src/Ubiety.Dns.Core/Records/NotUsed/RecordNSEC.cs index 2d86455..6a7c8a6 100644 --- a/src/Ubiety.Dns.Core/Records/NotUsed/RecordNSEC.cs +++ b/src/Ubiety.Dns.Core/Records/NotUsed/RecordNSEC.cs @@ -14,4 +14,4 @@ public RecordNsec(RecordReader rr) { } } -} +} \ No newline at end of file diff --git a/src/Ubiety.Dns.Core/Records/NotUsed/RecordNSEC3.cs b/src/Ubiety.Dns.Core/Records/NotUsed/RecordNSEC3.cs index ca004dc..d5d41e6 100644 --- a/src/Ubiety.Dns.Core/Records/NotUsed/RecordNSEC3.cs +++ b/src/Ubiety.Dns.Core/Records/NotUsed/RecordNSEC3.cs @@ -14,4 +14,4 @@ public RecordNsec3(RecordReader rr) { } } -} +} \ No newline at end of file diff --git a/src/Ubiety.Dns.Core/Records/NotUsed/RecordNSEC3PARAM.cs b/src/Ubiety.Dns.Core/Records/NotUsed/RecordNSEC3PARAM.cs index a8d5615..bd9120a 100644 --- a/src/Ubiety.Dns.Core/Records/NotUsed/RecordNSEC3PARAM.cs +++ b/src/Ubiety.Dns.Core/Records/NotUsed/RecordNSEC3PARAM.cs @@ -14,4 +14,4 @@ public RecordNsec3Param(RecordReader rr) { } } -} +} \ No newline at end of file diff --git a/src/Ubiety.Dns.Core/Records/NotUsed/RecordOPT.cs b/src/Ubiety.Dns.Core/Records/NotUsed/RecordOPT.cs index 08d23c5..8d15060 100644 --- a/src/Ubiety.Dns.Core/Records/NotUsed/RecordOPT.cs +++ b/src/Ubiety.Dns.Core/Records/NotUsed/RecordOPT.cs @@ -14,4 +14,4 @@ public RecordOpt(RecordReader rr) { } } -} +} \ No newline at end of file diff --git a/src/Ubiety.Dns.Core/Records/NotUsed/RecordRRSIG.cs b/src/Ubiety.Dns.Core/Records/NotUsed/RecordRRSIG.cs index 23b267c..734ffcd 100644 --- a/src/Ubiety.Dns.Core/Records/NotUsed/RecordRRSIG.cs +++ b/src/Ubiety.Dns.Core/Records/NotUsed/RecordRRSIG.cs @@ -14,4 +14,4 @@ public RecordRrsig(RecordReader rr) { } } -} +} \ No newline at end of file diff --git a/src/Ubiety.Dns.Core/Records/NotUsed/RecordSINK.cs b/src/Ubiety.Dns.Core/Records/NotUsed/RecordSINK.cs index bb27756..c9ca924 100644 --- a/src/Ubiety.Dns.Core/Records/NotUsed/RecordSINK.cs +++ b/src/Ubiety.Dns.Core/Records/NotUsed/RecordSINK.cs @@ -14,4 +14,4 @@ public RecordSink(RecordReader rr) { } } -} +} \ No newline at end of file diff --git a/src/Ubiety.Dns.Core/Records/NotUsed/RecordSPF.cs b/src/Ubiety.Dns.Core/Records/NotUsed/RecordSPF.cs index 4bc7d8a..9c0cce4 100644 --- a/src/Ubiety.Dns.Core/Records/NotUsed/RecordSPF.cs +++ b/src/Ubiety.Dns.Core/Records/NotUsed/RecordSPF.cs @@ -14,4 +14,4 @@ public RecordSpf(RecordReader rr) { } } -} +} \ No newline at end of file diff --git a/src/Ubiety.Dns.Core/Records/NotUsed/RecordSSHFP.cs b/src/Ubiety.Dns.Core/Records/NotUsed/RecordSSHFP.cs index f0400d8..b3324a1 100644 --- a/src/Ubiety.Dns.Core/Records/NotUsed/RecordSSHFP.cs +++ b/src/Ubiety.Dns.Core/Records/NotUsed/RecordSSHFP.cs @@ -14,4 +14,4 @@ public RecordSshfp(RecordReader rr) { } } -} +} \ No newline at end of file diff --git a/src/Ubiety.Dns.Core/Records/NotUsed/RecordUID.cs b/src/Ubiety.Dns.Core/Records/NotUsed/RecordUID.cs index 3673941..b465b78 100644 --- a/src/Ubiety.Dns.Core/Records/NotUsed/RecordUID.cs +++ b/src/Ubiety.Dns.Core/Records/NotUsed/RecordUID.cs @@ -14,4 +14,4 @@ public RecordUid(RecordReader rr) { } } -} +} \ No newline at end of file diff --git a/src/Ubiety.Dns.Core/Records/NotUsed/RecordUINFO.cs b/src/Ubiety.Dns.Core/Records/NotUsed/RecordUINFO.cs index 060eb44..f1c1481 100644 --- a/src/Ubiety.Dns.Core/Records/NotUsed/RecordUINFO.cs +++ b/src/Ubiety.Dns.Core/Records/NotUsed/RecordUINFO.cs @@ -14,4 +14,4 @@ public RecordUinfo(RecordReader rr) { } } -} +} \ No newline at end of file diff --git a/src/Ubiety.Dns.Core/Records/NotUsed/RecordUNSPEC.cs b/src/Ubiety.Dns.Core/Records/NotUsed/RecordUNSPEC.cs index c463072..b32ff56 100644 --- a/src/Ubiety.Dns.Core/Records/NotUsed/RecordUNSPEC.cs +++ b/src/Ubiety.Dns.Core/Records/NotUsed/RecordUNSPEC.cs @@ -14,4 +14,4 @@ public RecordUnspec(RecordReader rr) { } } -} +} \ No newline at end of file diff --git a/src/Ubiety.Dns.Core/Records/NotUsed/RecordUnknown.cs b/src/Ubiety.Dns.Core/Records/NotUsed/RecordUnknown.cs index 432bd37..b4dcd93 100644 --- a/src/Ubiety.Dns.Core/Records/NotUsed/RecordUnknown.cs +++ b/src/Ubiety.Dns.Core/Records/NotUsed/RecordUnknown.cs @@ -14,4 +14,4 @@ public RecordUnknown(RecordReader rr) { } } -} +} \ No newline at end of file diff --git a/src/Ubiety.Dns.Core/Records/Obsolete/RecordGPOS.cs b/src/Ubiety.Dns.Core/Records/Obsolete/RecordGPOS.cs index 89cbc65..23404c9 100644 --- a/src/Ubiety.Dns.Core/Records/Obsolete/RecordGPOS.cs +++ b/src/Ubiety.Dns.Core/Records/Obsolete/RecordGPOS.cs @@ -1,4 +1,4 @@ -using System; + /* * http://tools.ietf.org/rfc/rfc1712.txt @@ -39,6 +39,8 @@ high degree of precision with an acceptable average encoded record */ +using System; + namespace Ubiety.Dns.Core.Records.Obsolete { /// @@ -52,25 +54,25 @@ public class RecordGpos : Record /// for the record data public RecordGpos(RecordReader rr) { - this.Longitude = rr.ReadString(); - this.Latitude = rr.ReadString(); - this.Altitude = rr.ReadString(); + Longitude = rr.ReadString(); + Latitude = rr.ReadString(); + Altitude = rr.ReadString(); } /// - /// Gets or sets the longitude + /// Gets the longitude /// - public String Longitude { get; set; } + public String Longitude { get; } /// - /// Gets or sets the latitude + /// Gets the latitude /// - public String Latitude { get; set; } + public String Latitude { get; } /// - /// Gets or sets the altitude + /// Gets the altitude /// - public String Altitude { get; set; } + public String Altitude { get; } /// /// String representation of the position @@ -78,7 +80,7 @@ public RecordGpos(RecordReader rr) /// String of the version public override String ToString() { - return $"{this.Longitude} {this.Latitude} {this.Altitude}"; + return $"{Longitude} {Latitude} {Altitude}"; } } -} +} \ No newline at end of file diff --git a/src/Ubiety.Dns.Core/Records/Obsolete/RecordMD.cs b/src/Ubiety.Dns.Core/Records/Obsolete/RecordMD.cs index 6f969bb..e5db735 100644 --- a/src/Ubiety.Dns.Core/Records/Obsolete/RecordMD.cs +++ b/src/Ubiety.Dns.Core/Records/Obsolete/RecordMD.cs @@ -1,4 +1,4 @@ -using System; + /* 3.3.4. MD RDATA format (Obsolete) @@ -22,6 +22,9 @@ record corresponding to MADNAME. a master file is to reject them, or to convert them to MX RRs with a preference of 0. * */ + +using System; + namespace Ubiety.Dns.Core.Records.Obsolete { /// @@ -35,13 +38,13 @@ public class RecordMd : Record /// for the record data public RecordMd(RecordReader rr) { - this.MadName = rr.ReadDomainName(); + MadName = rr.ReadDomainName(); } /// - /// Gets or sets the mail domain + /// Gets the mail domain /// - public String MadName { get; set; } + public String MadName { get; } /// /// String representing the mail domain @@ -49,7 +52,7 @@ public RecordMd(RecordReader rr) /// String version of the record public override String ToString() { - return this.MadName; + return MadName; } } -} +} \ No newline at end of file diff --git a/src/Ubiety.Dns.Core/Records/Obsolete/RecordMF.cs b/src/Ubiety.Dns.Core/Records/Obsolete/RecordMF.cs index 59472cb..fa518a8 100644 --- a/src/Ubiety.Dns.Core/Records/Obsolete/RecordMF.cs +++ b/src/Ubiety.Dns.Core/Records/Obsolete/RecordMF.cs @@ -1,4 +1,4 @@ -using System; + /* * @@ -22,6 +22,9 @@ record corresponding to MADNAME. the new scheme. The recommended policy for dealing with MD RRs found in a master file is to reject them, or to convert them to MX RRs with a preference of 10. */ + +using System; + namespace Ubiety.Dns.Core.Records.Obsolete { /// @@ -35,13 +38,13 @@ public class RecordMf : Record /// for the record data public RecordMf(RecordReader rr) { - this.MadName = rr.ReadDomainName(); + MadName = rr.ReadDomainName(); } /// - /// Gets or sets the mail domain + /// Gets the mail domain /// - public String MadName { get; set; } + public String MadName { get; } /// /// String representation of the record @@ -49,7 +52,7 @@ public RecordMf(RecordReader rr) /// String of the mail domain public override String ToString() { - return this.MadName; + return MadName; } } -} +} \ No newline at end of file diff --git a/src/Ubiety.Dns.Core/Records/Obsolete/RecordNSAPPTR.cs b/src/Ubiety.Dns.Core/Records/Obsolete/RecordNSAPPTR.cs index 69afd11..fc8c003 100644 --- a/src/Ubiety.Dns.Core/Records/Obsolete/RecordNSAPPTR.cs +++ b/src/Ubiety.Dns.Core/Records/Obsolete/RecordNSAPPTR.cs @@ -1,4 +1,4 @@ -using System; + /* * http://tools.ietf.org/rfc/rfc1348.txt @@ -39,6 +39,8 @@ as a . */ +using System; + namespace Ubiety.Dns.Core.Records.Obsolete { /// @@ -52,13 +54,13 @@ public class RecordNsapPtr : Record /// for the record data public RecordNsapPtr(RecordReader rr) { - this.Owner = rr.ReadString(); + Owner = rr.ReadString(); } /// /// Gets or sets the owner /// - public String Owner { get; set; } + public String Owner { get; } /// /// String representation of the record @@ -66,7 +68,7 @@ public RecordNsapPtr(RecordReader rr) /// String version of the data public override String ToString() { - return this.Owner; + return Owner; } } -} +} \ No newline at end of file diff --git a/src/Ubiety.Dns.Core/Records/Obsolete/RecordNXT.cs b/src/Ubiety.Dns.Core/Records/Obsolete/RecordNXT.cs index 654147b..714392e 100644 --- a/src/Ubiety.Dns.Core/Records/Obsolete/RecordNXT.cs +++ b/src/Ubiety.Dns.Core/Records/Obsolete/RecordNXT.cs @@ -1,4 +1,3 @@ -using System; using System.Collections.ObjectModel; using System.Text; using Ubiety.Dns.Core.Common; @@ -46,7 +45,7 @@ namespace Ubiety.Dns.Core.Records.Obsolete /// public class RecordNxt : Record { - private readonly Byte[] bitmap; + private readonly byte[] bitmap; /// /// Initializes a new instance of the class @@ -54,55 +53,46 @@ public class RecordNxt : Record /// for the record data public RecordNxt(RecordReader rr) { - UInt16 length = rr.ReadUInt16(-2); - this.NextDomainName = rr.ReadDomainName(); - length -= (UInt16)rr.Position; - this.bitmap = new byte[length]; - this.bitmap = rr.ReadBytes(length); + var length = rr.ReadUInt16(-2); + NextDomainName = rr.ReadDomainName(); + length -= (ushort) rr.Position; + bitmap = new byte[length]; + bitmap = rr.ReadBytes(length); } /// /// Gets or sets the next domain name /// - public String NextDomainName { get; set; } + public string NextDomainName { get; set; } /// /// Gets the record bitmap /// - public Collection Bitmap { get => new Collection(this.bitmap); } + public Collection Bitmap => new Collection(bitmap); /// /// String representation of the record /// /// String version of the data - public override String ToString() + public override string ToString() { - StringBuilder sb = new StringBuilder(); - for (Int32 bitNr = 1; bitNr < (this.bitmap.Length * 8); bitNr++) - { - if (this.IsSet(bitNr)) - { - sb.Append(" " + (RecordType)bitNr); - } - } + var sb = new StringBuilder(); + for (var bitNr = 1; bitNr < bitmap.Length * 8; bitNr++) + if (IsSet(bitNr)) + sb.Append(" " + (RecordType) bitNr); - return $"{this.NextDomainName}{sb.ToString()}"; + return $"{NextDomainName}{sb}"; } - private bool IsSet(Int32 bitNr) + private bool IsSet(int bitNr) { - Int32 intByte = bitNr / 8; - Int32 intOffset = bitNr % 8; - Byte b = this.bitmap[intByte]; - Int32 intTest = 1 << intOffset; + var intByte = bitNr / 8; + var intOffset = bitNr % 8; + var b = bitmap[intByte]; + var intTest = 1 << intOffset; if ((b & intTest) == 0) - { return false; - } - else - { - return true; - } + return true; } } -} +} \ No newline at end of file diff --git a/src/Ubiety.Dns.Core/Records/Record.cs b/src/Ubiety.Dns.Core/Records/Record.cs index 122f6fb..cbe8427 100644 --- a/src/Ubiety.Dns.Core/Records/Record.cs +++ b/src/Ubiety.Dns.Core/Records/Record.cs @@ -4,51 +4,46 @@ namespace Ubiety.Dns.Core.Records { /// - /// Abstract record + /// Abstract record /// public abstract class Record { /// - /// Record data - /// - private readonly List data; - - /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// protected Record() { } /// - /// Initializes a new instance of the class + /// Initializes a new instance of the class /// /// for the record data protected Record(RecordReader reader) { - UInt16 length = reader.ReadUInt16(-2); - this.data = new List(reader.ReadBytes(length)); + var length = reader.ReadUInt16(-2); + RecordData = new List(reader.ReadBytes(length)); } /// - /// Gets the record data + /// Gets the record data /// /// Byte list of the raw record data - public List RecordData { get => this.data; } + public List RecordData { get; } /// - /// Gets or sets the resource record this record is a part of + /// Gets or sets the resource record this record is a part of /// /// Resource record of the data public ResourceRecord ResourceRecord { get; set; } /// - /// String representation of the record + /// String representation of the record /// /// String version of the data - public override String ToString() + public override string ToString() { - return $"{this.GetType().Name} is not-used"; + return $"{GetType().Name} is not-used"; } } -} +} \ No newline at end of file diff --git a/src/Ubiety.Dns.Core/Records/RecordAFSDB.cs b/src/Ubiety.Dns.Core/Records/RecordAFSDB.cs index 89e4c49..dd54342 100644 --- a/src/Ubiety.Dns.Core/Records/RecordAFSDB.cs +++ b/src/Ubiety.Dns.Core/Records/RecordAFSDB.cs @@ -3,57 +3,50 @@ namespace Ubiety.Dns.Core.Records { /// - /// DNS AFSDB Record + /// DNS AFSDB Record /// /// - /// # [Description](#tab/description) - /// - /// AFS Database location resource record - /// - /// # [RFC](#tab/rfc) - /// - /// This section defines an extension of the DNS to locate servers both - /// for AFS (AFS is a registered trademark of Transarc Corporation) and - /// for the Open Source Foundation's (OSF) Distributed Computing - /// Environment (DCE) authenticated naming system using HP/Apollo's NCA, - /// both to be components of the OSF DCE. The discussion assumes that - /// the reader is familiar with AFS [5] and NCA [6]. - /// - /// The AFS (originally the Andrew File System) system uses the DNS to - /// map from a domain name to the name of an AFS cell database server. - /// The DCE Naming service uses the DNS for a similar function: mapping - /// from the domain name of a cell to authenticated name servers for that - /// cell. The method uses a new RR type with mnemonic AFSDB and type - /// code of 18 (decimal). - /// - /// AFSDB has the following format: - /// - /// [owner] [ttl] [class] AFSDB [subtype] [hostname] - /// - /// Both RDATA fields are required in all AFSDB RRs. The [subtype] field - /// is a 16 bit integer. The [hostname] field is a domain name of a host - /// that has a server for the cell named by the owner name of the RR + /// # [Description](#tab/description) + /// AFS Database location resource record + /// # [RFC](#tab/rfc) + /// This section defines an extension of the DNS to locate servers both + /// for AFS (AFS is a registered trademark of Transarc Corporation) and + /// for the Open Source Foundation's (OSF) Distributed Computing + /// Environment (DCE) authenticated naming system using HP/Apollo's NCA, + /// both to be components of the OSF DCE. The discussion assumes that + /// the reader is familiar with AFS [5] and NCA [6]. + /// The AFS (originally the Andrew File System) system uses the DNS to + /// map from a domain name to the name of an AFS cell database server. + /// The DCE Naming service uses the DNS for a similar function: mapping + /// from the domain name of a cell to authenticated name servers for that + /// cell. The method uses a new RR type with mnemonic AFSDB and type + /// code of 18 (decimal). + /// AFSDB has the following format: + /// [owner] [ttl] [class] AFSDB [subtype] [hostname] + /// Both RDATA fields are required in all AFSDB RRs. The [subtype] field + /// is a 16 bit integer. The [hostname] field is a domain name of a host + /// that has a server for the cell named by the owner name of the RR /// public class RecordAfsdb : Record { /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// for the record data public RecordAfsdb(RecordReader rr) { - this.SubType = rr.ReadUInt16(); - this.Hostname = rr.ReadDomainName(); + SubType = rr.ReadUInt16(); + Hostname = rr.ReadDomainName(); } /// - /// Gets the subtype + /// Gets the subtype /// /// AFSDB subtype as an unsigned short public UInt16 SubType { get; } /// - /// Gets the hostname + /// Gets the hostname /// /// AFSDB hostname as a string public String Hostname { get; } @@ -64,7 +57,7 @@ public RecordAfsdb(RecordReader rr) /// String version of the data public override String ToString() { - return $"{this.SubType}{this.Hostname}"; + return $"{SubType}{Hostname}"; } } -} +} \ No newline at end of file diff --git a/src/Ubiety.Dns.Core/Records/RecordCERT.cs b/src/Ubiety.Dns.Core/Records/RecordCERT.cs index 29a652a..0c535fb 100644 --- a/src/Ubiety.Dns.Core/Records/RecordCERT.cs +++ b/src/Ubiety.Dns.Core/Records/RecordCERT.cs @@ -1,5 +1,5 @@ using System; -using System.Collections.ObjectModel; +using System.Collections.Generic; /* @@ -22,7 +22,7 @@ namespace Ubiety.Dns.Core.Records /// public class RecordCert : Record { - private readonly Byte[] rawKey; + private readonly Byte[] _rawKey; /// /// Initializes a new instance of the class @@ -31,40 +31,40 @@ public class RecordCert : Record public RecordCert(RecordReader rr) { // re-read length - UInt16 recordLength = rr.ReadUInt16(-2); + var recordLength = rr.ReadUInt16(-2); - this.Type = rr.ReadUInt16(); - this.KeyTag = rr.ReadUInt16(); - this.Algorithm = rr.ReadByte(); + Type = rr.ReadUInt16(); + KeyTag = rr.ReadUInt16(); + Algorithm = rr.ReadByte(); var length = recordLength - 5; - this.rawKey = rr.ReadBytes(length); - this.PublicKey = Convert.ToBase64String(this.rawKey); + _rawKey = rr.ReadBytes(length); + PublicKey = Convert.ToBase64String(_rawKey); } /// - /// Gets or sets the record type + /// Gets the record type /// - public UInt16 Type { get; set; } + public UInt16 Type { get; } /// - /// Gets or sets the key tag + /// Gets the key tag /// - public UInt16 KeyTag { get; set; } + public UInt16 KeyTag { get; } /// - /// Gets or sets the algorithm + /// Gets the algorithm /// - public Byte Algorithm { get; set; } + public Byte Algorithm { get; } /// - /// Gets or sets the public key + /// Gets the public key /// - public String PublicKey { get; set; } + public String PublicKey { get; } /// /// Gets the raw key /// - public Collection RawKey { get => new Collection(this.rawKey); } + public List RawKey => new List(_rawKey); /// /// String version of the record @@ -72,7 +72,7 @@ public RecordCert(RecordReader rr) /// String of the public key public override String ToString() { - return this.PublicKey; + return PublicKey; } } -} +} \ No newline at end of file diff --git a/src/Ubiety.Dns.Core/Records/RecordDNAME.cs b/src/Ubiety.Dns.Core/Records/RecordDNAME.cs index 77fcdde..181eb23 100644 --- a/src/Ubiety.Dns.Core/Records/RecordDNAME.cs +++ b/src/Ubiety.Dns.Core/Records/RecordDNAME.cs @@ -1,4 +1,4 @@ -using System; + /* * http://tools.ietf.org/rfc/rfc2672.txt @@ -15,6 +15,9 @@ RDATA field is a [DNSIS]. * */ + +using System; + namespace Ubiety.Dns.Core.Records { /// @@ -28,13 +31,13 @@ public class RecordDname : Record /// for the record public RecordDname(RecordReader rr) { - this.Target = rr.ReadDomainName(); + Target = rr.ReadDomainName(); } /// - /// Gets or sets the target + /// Gets the target /// - public String Target { get; set; } + public String Target { get; } /// /// String representation of the record data @@ -42,7 +45,7 @@ public RecordDname(RecordReader rr) /// String of the target public override String ToString() { - return this.Target; + return Target; } } -} +} \ No newline at end of file diff --git a/src/Ubiety.Dns.Core/Records/RecordDS.cs b/src/Ubiety.Dns.Core/Records/RecordDS.cs index ecfb0e2..de2e7a9 100644 --- a/src/Ubiety.Dns.Core/Records/RecordDS.cs +++ b/src/Ubiety.Dns.Core/Records/RecordDS.cs @@ -1,5 +1,5 @@ using System; -using System.Collections.ObjectModel; +using System.Collections.Generic; using System.Globalization; using System.Text; @@ -38,7 +38,7 @@ namespace Ubiety.Dns.Core.Records /// public class RecordDs : Record { - private readonly Byte[] digest; + private readonly Byte[] _digest; /// /// Initializes a new instance of the class @@ -46,34 +46,34 @@ public class RecordDs : Record /// of the record data public RecordDs(RecordReader rr) { - UInt16 length = rr.ReadUInt16(-2); - this.KeyTag = rr.ReadUInt16(); - this.Algorithm = rr.ReadByte(); - this.DigestType = rr.ReadByte(); + var length = rr.ReadUInt16(-2); + KeyTag = rr.ReadUInt16(); + Algorithm = rr.ReadByte(); + DigestType = rr.ReadByte(); length -= 4; - this.digest = new Byte[length]; - this.digest = rr.ReadBytes(length); + _digest = new Byte[length]; + _digest = rr.ReadBytes(length); } /// - /// Gets or sets the key tag + /// Gets the key tag /// - public UInt16 KeyTag { get; set; } + public UInt16 KeyTag { get; } /// - /// Gets or sets the algorithm + /// Gets the algorithm /// - public Byte Algorithm { get; set; } + public Byte Algorithm { get; } /// - /// Gets or sets the digest type + /// Gets the digest type /// - public Byte DigestType { get; set; } + public Byte DigestType { get; } /// /// Gets the digest /// - public Collection Digest { get => new Collection(this.digest); } + public List Digest => new List(_digest); /// /// String version of the record @@ -81,13 +81,13 @@ public RecordDs(RecordReader rr) /// String of the data public override string ToString() { - StringBuilder sb = new StringBuilder(); - for (Int32 i = 0; i < this.digest.Length; i++) + var sb = new StringBuilder(); + foreach (var t in _digest) { - sb.AppendFormat(CultureInfo.InvariantCulture, "{0:x2}", this.digest[i]); + sb.AppendFormat(CultureInfo.InvariantCulture, "{0:x2}", t); } - return $"{this.KeyTag} {this.Algorithm} {this.DigestType} {sb.ToString()}"; + return $"{KeyTag} {Algorithm} {DigestType} {sb}"; } } -} +} \ No newline at end of file diff --git a/src/Ubiety.Dns.Core/Records/RecordHINFO.cs b/src/Ubiety.Dns.Core/Records/RecordHINFO.cs index e479010..cb939e5 100644 --- a/src/Ubiety.Dns.Core/Records/RecordHINFO.cs +++ b/src/Ubiety.Dns.Core/Records/RecordHINFO.cs @@ -1,4 +1,4 @@ -using System; + /* 3.3.2. HINFO RDATA format @@ -23,6 +23,8 @@ HINFO records are used to acquire general information about a host. The when talking between machines or operating systems of the same type. */ +using System; + namespace Ubiety.Dns.Core.Records { /// @@ -36,27 +38,27 @@ public class RecordHinfo : Record /// for the record data public RecordHinfo(RecordReader rr) { - this.Cpu = rr.ReadString(); - this.Os = rr.ReadString(); + Cpu = rr.ReadString(); + Os = rr.ReadString(); } /// - /// Gets or sets the CPU + /// Gets the CPU /// - public String Cpu { get; set; } + public String Cpu { get; } /// - /// Gets or sets the OS + /// Gets the OS /// - public string Os { get; set; } + public String Os { get; } /// /// String representation of the record data /// /// String version of the record - public override string ToString() + public override String ToString() { - return $"CPU={this.Cpu} OS={this.Os}"; + return $"CPU={Cpu} OS={Os}"; } } -} +} \ No newline at end of file diff --git a/src/Ubiety.Dns.Core/Records/RecordISDN.cs b/src/Ubiety.Dns.Core/Records/RecordISDN.cs index 4c30dce..cee3111 100644 --- a/src/Ubiety.Dns.Core/Records/RecordISDN.cs +++ b/src/Ubiety.Dns.Core/Records/RecordISDN.cs @@ -1,4 +1,4 @@ -using System; + /* http://tools.ietf.org/rfc/rfc1183.txt @@ -81,27 +81,27 @@ public class RecordIsdn : Record /// for the record data public RecordIsdn(RecordReader rr) { - this.IsdnAddress = rr.ReadString(); - this.SA = rr.ReadString(); + IsdnAddress = rr.ReadString(); + SA = rr.ReadString(); } /// /// Gets or sets the ISDN address /// - public String IsdnAddress { get; set; } + public string IsdnAddress { get; set; } /// /// Gets or sets SA /// - public String SA { get; set; } + public string SA { get; set; } /// /// String representation of the record data /// /// String version of the data - public override String ToString() + public override string ToString() { - return $"{this.IsdnAddress} {this.SA}"; + return $"{IsdnAddress} {SA}"; } } -} +} \ No newline at end of file diff --git a/src/Ubiety.Dns.Core/Records/RecordKEY.cs b/src/Ubiety.Dns.Core/Records/RecordKEY.cs index 6ae32b6..c46115e 100644 --- a/src/Ubiety.Dns.Core/Records/RecordKEY.cs +++ b/src/Ubiety.Dns.Core/Records/RecordKEY.cs @@ -1,4 +1,4 @@ -using System; + /* http://www.ietf.org/rfc/rfc2535.txt * @@ -46,39 +46,39 @@ public class RecordKey : Record /// for the record data public RecordKey(RecordReader rr) { - this.Flags = rr.ReadUInt16(); - this.Protocol = rr.ReadByte(); - this.Algorithm = rr.ReadByte(); - this.PublicKey = rr.ReadString(); + Flags = rr.ReadUInt16(); + Protocol = rr.ReadByte(); + Algorithm = rr.ReadByte(); + PublicKey = rr.ReadString(); } /// /// Gets or sets the flags /// - public UInt16 Flags { get; set; } + public ushort Flags { get; set; } /// /// Gets or sets the protocol /// - public Byte Protocol { get; set; } + public byte Protocol { get; set; } /// /// Gets or sets the algorithm /// - public Byte Algorithm { get; set; } + public byte Algorithm { get; set; } /// /// Gets or sets the public key /// - public String PublicKey { get; set; } + public string PublicKey { get; set; } /// /// String representation of the record data /// /// String version of the record - public override String ToString() + public override string ToString() { - return $"{this.Flags} {this.Protocol} {this.Algorithm} \"{this.PublicKey}\""; + return $"{Flags} {Protocol} {Algorithm} \"{PublicKey}\""; } } -} +} \ No newline at end of file diff --git a/src/Ubiety.Dns.Core/Records/RecordKX.cs b/src/Ubiety.Dns.Core/Records/RecordKX.cs index 5800e92..7d8a7ce 100644 --- a/src/Ubiety.Dns.Core/Records/RecordKX.cs +++ b/src/Ubiety.Dns.Core/Records/RecordKX.cs @@ -46,168 +46,162 @@ public sealed class RecordKx : Record, IComparable, IEquatable /// for the data public RecordKx(RecordReader rr) { - this.Preference = rr.ReadUInt16(); - this.Exchanger = rr.ReadDomainName(); + Preference = rr.ReadUInt16(); + Exchanger = rr.ReadDomainName(); } /// - /// Gets or sets the preference + /// Gets the preference /// - public UInt16 Preference { get; set; } + public UInt16 Preference { get; } /// - /// Gets or sets the exchanger + /// Gets the exchanger /// - public String Exchanger { get; set; } + public String Exchanger { get; } /// - /// String representation of the record data /// - /// String version of the record - public override String ToString() + /// + /// + public static bool operator <(RecordKx x, RecordKx y) { - return $"{this.Preference} {this.Exchanger}"; + return CompareTo(x, y) < 0; } /// - /// Compares instance to an object /// - /// Object to compare to - /// Integer representing the comparison - public Int32 CompareTo(Object obj) + /// + /// + public static bool operator >(RecordKx x, RecordKx y) { - return CompareTo(this, (RecordKx)obj); + return CompareTo(x, y) > 0; } /// - /// Overrides equals /// - /// Object to compare to - /// Boolean indicating whether the instances are equal - public override Boolean Equals(Object obj) + /// + /// + public static bool operator <=(RecordKx x, RecordKx y) { - if (this.GetType() != obj.GetType()) - { - return false; - } - - if (obj is null) - { - return false; - } - - if (ReferenceEquals(this, obj)) - { - return true; - } - - return this.Equals(obj as RecordKx); + return CompareTo(x, y) <= 0; } /// - /// Are two instances of equal /// - /// to compare to - /// Boolean indicating whether the two instances are equal - public Boolean Equals(RecordKx other) + /// + /// + public static bool operator >=(RecordKx x, RecordKx y) { - if (other == null) - { - return false; - } - - return this.CompareTo(other) == 0; + return CompareTo(x, y) >= 0; } /// - /// Gets the hash code /// - /// Integer value of the hash - public override Int32 GetHashCode() + /// + /// + public static bool operator ==(RecordKx x, RecordKx y) { - unchecked - { - var hashcode = 13; - hashcode = (hashcode * 397) ^ this.Preference; - var exHash = !String.IsNullOrEmpty(this.Exchanger) ? this.Exchanger.GetHashCode() : 0; - hashcode = (hashcode * 397) ^ exHash; - return hashcode; - } + return CompareTo(x, y) == 0; } /// /// /// /// - public static Boolean operator <(RecordKx x, RecordKx y) + public static bool operator !=(RecordKx x, RecordKx y) { - return CompareTo(x, y) < 0; + return CompareTo(x, y) != 0; } /// + /// Compares instance to an object /// - /// - /// - public static Boolean operator >(RecordKx x, RecordKx y) + /// Object to compare to + /// Integer representing the comparison + public Int32 CompareTo(Object obj) { - return CompareTo(x, y) > 0; + return CompareTo(this, (RecordKx)obj); } /// + /// Are two instances of equal /// - /// - /// - public static Boolean operator <=(RecordKx x, RecordKx y) + /// to compare to + /// Boolean indicating whether the two instances are equal + public Boolean Equals(RecordKx other) { - return CompareTo(x, y) <= 0; + if (other == null) + { + return false; + } + + return CompareTo(other) == 0; } /// + /// String representation of the record data /// - /// - /// - public static Boolean operator >=(RecordKx x, RecordKx y) + /// String version of the record + public override String ToString() { - return CompareTo(x, y) >= 0; + return $"{Preference} {Exchanger}"; } /// + /// Overrides equals /// - /// - /// - public static Boolean operator ==(RecordKx x, RecordKx y) + /// Object to compare to + /// Boolean indicating whether the instances are equal + public override Boolean Equals(Object obj) { - return CompareTo(x, y) == 0; + if (obj is null) + { + return false; + } + + if (GetType() != obj.GetType()) + { + return false; + } + + return ReferenceEquals(this, obj) || Equals(obj as RecordKx); } /// + /// Gets the hash code /// - /// - /// - public static Boolean operator !=(RecordKx x, RecordKx y) + /// Integer value of the hash + public override Int32 GetHashCode() { - return CompareTo(x, y) != 0; + unchecked + { + var hashcode = 13; + hashcode = (hashcode * 397) ^ Preference; + var exHash = !String.IsNullOrEmpty(Exchanger) ? Exchanger.GetHashCode() : 0; + hashcode = (hashcode * 397) ^ exHash; + return hashcode; + } } - private static Int32 CompareTo(RecordKx x, RecordKx y) + private static int CompareTo(RecordKx x, RecordKx y) { if (y == null) { return -1; } - else if (x.Preference > y.Preference) + + if (x.Preference > y.Preference) { return 1; } - else if (x.Preference < y.Preference) + + if (x.Preference < y.Preference) { return -1; } - else - { - // they are the same, now compare case insensitive names - return String.Compare(x.Exchanger, y.Exchanger, true, CultureInfo.InvariantCulture); - } + + return string.Compare(x.Exchanger, y.Exchanger, true, CultureInfo.InvariantCulture); } } -} +} \ No newline at end of file diff --git a/src/Ubiety.Dns.Core/Records/RecordLOC.cs b/src/Ubiety.Dns.Core/Records/RecordLOC.cs index 537f94f..7bdf503 100644 --- a/src/Ubiety.Dns.Core/Records/RecordLOC.cs +++ b/src/Ubiety.Dns.Core/Records/RecordLOC.cs @@ -1,4 +1,3 @@ -using System; using System.Globalization; using System.Text; @@ -110,99 +109,96 @@ public class RecordLoc : Record /// Record reader of the record data public RecordLoc(RecordReader rr) { - this.Version = rr.ReadByte(); // must be 0! - this.Size = rr.ReadByte(); - this.HorizontalPrecision = rr.ReadByte(); - this.VerticalPrecision = rr.ReadByte(); - this.Latitude = rr.ReadUInt32(); - this.Longitude = rr.ReadUInt32(); - this.Altitude = rr.ReadUInt32(); + Version = rr.ReadByte(); // must be 0! + Size = rr.ReadByte(); + HorizontalPrecision = rr.ReadByte(); + VerticalPrecision = rr.ReadByte(); + Latitude = rr.ReadUInt32(); + Longitude = rr.ReadUInt32(); + Altitude = rr.ReadUInt32(); } /// /// Gets the version of the representation /// - public Byte Version { get; } + public byte Version { get; } /// /// Gets the diameter of the sphere enclosing the entity /// - public Byte Size { get; } + public byte Size { get; } /// /// Gets the horizontal precision of the data /// - public Byte HorizontalPrecision { get; } + public byte HorizontalPrecision { get; } /// /// Gets the vertical precision or the data /// - public Byte VerticalPrecision { get; } + public byte VerticalPrecision { get; } /// /// Gets the latitude of the location /// - public UInt32 Latitude { get; } + public uint Latitude { get; } /// /// Gets the longitude of the location /// - public UInt32 Longitude { get; } + public uint Longitude { get; } /// /// Gets the altitude of the location /// - public UInt32 Altitude { get; } + public uint Altitude { get; } /// /// Gets a string of the location /// /// String of the location - public override String ToString() + public override string ToString() { return string.Format( CultureInfo.InvariantCulture, "{0} {1} {2} {3} {4} {5}", - ToTime(this.Latitude, 'S', 'N'), - ToTime(this.Longitude, 'W', 'E'), - ToAlt(this.Altitude), - SizeToString(this.Size), - SizeToString(this.HorizontalPrecision), - SizeToString(this.VerticalPrecision)); + ToTime(Latitude, 'S', 'N'), + ToTime(Longitude, 'W', 'E'), + ToAlt(Altitude), + SizeToString(Size), + SizeToString(HorizontalPrecision), + SizeToString(VerticalPrecision)); } - private static String ToAlt(UInt32 a) + private static string ToAlt(uint a) { - Double alt = (a / 100.0) - 100000.00; + var alt = a / 100.0 - 100000.00; return string.Format(CultureInfo.InvariantCulture, "{0:0.00}m", alt); } - private static String SizeToString(Byte size) + private static string SizeToString(byte size) { - String unit = "cm"; - Int32 prime = size >> 4; - Int32 power = size & 0x0f; + var unit = "cm"; + var prime = size >> 4; + var power = size & 0x0f; if (power >= 2) { power -= 2; unit = "m"; } - StringBuilder sb = new StringBuilder(); + var sb = new StringBuilder(); sb.AppendFormat(CultureInfo.InvariantCulture, "{0}", prime); - for (; power > 0; power--) - { - sb.Append('0'); - } + for (; power > 0; power--) sb.Append('0'); sb.Append(unit); return sb.ToString(); } - private static String ToTime(UInt32 r, Char below, Char above) + private static string ToTime(uint r, char below, char above) { - UInt32 mid = 2147483648; // 2^31 - Char dir; + var mid = 2147483648; // 2^31 + char dir; if (r > mid) { dir = above; @@ -214,10 +210,10 @@ private static String ToTime(UInt32 r, Char below, Char above) r = mid - r; } - Double h = r / (360000.0 * 10.0); - Double m = 60.0 * (h - (Int32)h); - Double s = 60.0 * (m - (Int32)m); - return string.Format(CultureInfo.InvariantCulture, "{0} {1} {2:0.000} {3}", (Int32)h, (Int32)m, s, dir); + var h = r / (360000.0 * 10.0); + var m = 60.0 * (h - (int) h); + var s = 60.0 * (m - (int) m); + return string.Format(CultureInfo.InvariantCulture, "{0} {1} {2:0.000} {3}", (int) h, (int) m, s, dir); } } -} +} \ No newline at end of file diff --git a/src/Ubiety.Dns.Core/Records/RecordNAPTR.cs b/src/Ubiety.Dns.Core/Records/RecordNAPTR.cs index 4aac0c0..12785a8 100644 --- a/src/Ubiety.Dns.Core/Records/RecordNAPTR.cs +++ b/src/Ubiety.Dns.Core/Records/RecordNAPTR.cs @@ -1,4 +1,4 @@ -using System; + /* * http://www.faqs.org/rfcs/rfc2915.html @@ -55,51 +55,51 @@ public class RecordNaptr : Record /// for the record data public RecordNaptr(RecordReader rr) { - this.Order = rr.ReadUInt16(); - this.Preference = rr.ReadUInt16(); - this.Flags = rr.ReadString(); - this.Services = rr.ReadString(); - this.Regexp = rr.ReadString(); - this.Replacement = rr.ReadDomainName(); + Order = rr.ReadUInt16(); + Preference = rr.ReadUInt16(); + Flags = rr.ReadString(); + Services = rr.ReadString(); + Regexp = rr.ReadString(); + Replacement = rr.ReadDomainName(); } /// /// Gets or sets the order /// - public UInt16 Order { get; set; } + public ushort Order { get; set; } /// /// Gets or sets the preference /// - public UInt16 Preference { get; set; } + public ushort Preference { get; set; } /// /// Gets or sets the flags /// - public String Flags { get; set; } + public string Flags { get; set; } /// /// Gets or sets the services /// - public String Services { get; set; } + public string Services { get; set; } /// /// Gets or sets the regexp /// - public String Regexp { get; set; } + public string Regexp { get; set; } /// /// Gets or sets the replacement /// - public String Replacement { get; set; } + public string Replacement { get; set; } /// /// String representation of the record data /// /// Data as a string - public override String ToString() + public override string ToString() { - return $"{this.Order} {this.Preference} \"{this.Flags}\" \"{this.Services}\" \"{this.Regexp}\" {this.Replacement}"; + return $"{Order} {Preference} \"{Flags}\" \"{Services}\" \"{Regexp}\" {Replacement}"; } } -} +} \ No newline at end of file diff --git a/src/Ubiety.Dns.Core/Records/RecordNS.cs b/src/Ubiety.Dns.Core/Records/RecordNS.cs index 3c7b6c3..8af1d33 100644 --- a/src/Ubiety.Dns.Core/Records/RecordNS.cs +++ b/src/Ubiety.Dns.Core/Records/RecordNS.cs @@ -1,4 +1,4 @@ -using System; + /* 3.3.11. NS RDATA format @@ -38,21 +38,21 @@ public class RecordNs : Record /// for the record data public RecordNs(RecordReader rr) { - this.NameserverDomain = rr.ReadDomainName(); + NameserverDomain = rr.ReadDomainName(); } /// /// Gets or sets the nameserver domain /// - public String NameserverDomain { get; set; } + public string NameserverDomain { get; set; } /// /// String representation of the record data /// /// Nameserver domain as a string - public override String ToString() + public override string ToString() { - return this.NameserverDomain; + return NameserverDomain; } } -} +} \ No newline at end of file diff --git a/src/Ubiety.Dns.Core/Records/RecordNSAP.cs b/src/Ubiety.Dns.Core/Records/RecordNSAP.cs index 73e1592..43ba5c8 100644 --- a/src/Ubiety.Dns.Core/Records/RecordNSAP.cs +++ b/src/Ubiety.Dns.Core/Records/RecordNSAP.cs @@ -1,4 +1,3 @@ -using System; using System.Collections.ObjectModel; using System.Globalization; using System.Text; @@ -40,7 +39,7 @@ namespace Ubiety.Dns.Core.Records /// public class RecordNsap : Record { - private readonly Byte[] address; + private readonly byte[] address; /// /// Initializes a new instance of the class @@ -48,32 +47,30 @@ public class RecordNsap : Record /// for the record data public RecordNsap(RecordReader rr) { - this.Length = rr.ReadUInt16(); - this.address = rr.ReadBytes(this.Length); + Length = rr.ReadUInt16(); + address = rr.ReadBytes(Length); } /// /// Gets or sets the length /// - public UInt16 Length { get; set; } + public ushort Length { get; set; } /// /// Gets the address as a byte collection /// - public Collection NsapAddress { get => new Collection(this.address); } + public Collection NsapAddress => new Collection(address); /// /// String representation of the record data /// /// NSAP address as a string - public override String ToString() + public override string ToString() { - StringBuilder sb = new StringBuilder(); - sb.AppendFormat(CultureInfo.InvariantCulture, "{0} ", this.Length); - for (Int32 i = 0; i < this.address.Length; i++) - { - sb.AppendFormat(CultureInfo.InvariantCulture, "{0:X00}", this.address[i]); - } + var sb = new StringBuilder(); + sb.AppendFormat(CultureInfo.InvariantCulture, "{0} ", Length); + for (var i = 0; i < address.Length; i++) + sb.AppendFormat(CultureInfo.InvariantCulture, "{0:X00}", address[i]); return sb.ToString(); } @@ -82,20 +79,20 @@ public override String ToString() /// Converts the address to a readable string /// /// String of the address in IPv2 format - public String ToGOSIPV2() + public string ToGOSIPV2() { return string.Format( CultureInfo.InvariantCulture, "{0:X}.{1:X}.{2:X}.{3:X}.{4:X}.{5:X}.{6:X}{7:X}.{8:X}", - this.address[0], - this.address[1] << 8 | this.address[2], - this.address[3], - this.address[4] << 16 | this.address[5] << 8 | this.address[6], - this.address[7] << 8 | this.address[8], - this.address[9] << 8 | this.address[10], - this.address[11] << 8 | this.address[12], - this.address[13] << 16 | this.address[14] << 8 | this.address[15], - this.address[16] << 16 | this.address[17] << 8 | this.address[18]); + address[0], + (address[1] << 8) | address[2], + address[3], + (address[4] << 16) | (address[5] << 8) | address[6], + (address[7] << 8) | address[8], + (address[9] << 8) | address[10], + (address[11] << 8) | address[12], + (address[13] << 16) | (address[14] << 8) | address[15], + (address[16] << 16) | (address[17] << 8) | address[18]); } } -} +} \ No newline at end of file diff --git a/src/Ubiety.Dns.Core/Records/RecordNULL.cs b/src/Ubiety.Dns.Core/Records/RecordNULL.cs index 0babc44..0139e92 100644 --- a/src/Ubiety.Dns.Core/Records/RecordNULL.cs +++ b/src/Ubiety.Dns.Core/Records/RecordNULL.cs @@ -1,5 +1,5 @@ using System; -using System.Collections.ObjectModel; +using System.Collections.Generic; /* 3.3.10. NULL RDATA format (EXPERIMENTAL) @@ -24,7 +24,7 @@ namespace Ubiety.Dns.Core.Records /// public class RecordNull : Record { - private readonly Byte[] data; + private readonly Byte[] _data; /// /// Initializes a new instance of the class @@ -33,15 +33,15 @@ public class RecordNull : Record public RecordNull(RecordReader rr) { rr.Position -= 2; - UInt16 recordLength = rr.ReadUInt16(); - this.data = new Byte[recordLength]; - this.data = rr.ReadBytes(recordLength); + var recordLength = rr.ReadUInt16(); + _data = new Byte[recordLength]; + _data = rr.ReadBytes(recordLength); } /// /// Gets the record data /// - public Collection Data { get => new Collection(this.data); } + public List Data => new List(_data); /// /// String representation of the data @@ -49,7 +49,7 @@ public RecordNull(RecordReader rr) /// Record data as a string public override String ToString() { - return $"...binary data... ({this.data.Length}) bytes"; + return $"...binary data... ({_data.Length}) bytes"; } } -} +} \ No newline at end of file diff --git a/src/Ubiety.Dns.Core/Records/RecordPTR.cs b/src/Ubiety.Dns.Core/Records/RecordPTR.cs index 4b6e82f..d441915 100644 --- a/src/Ubiety.Dns.Core/Records/RecordPTR.cs +++ b/src/Ubiety.Dns.Core/Records/RecordPTR.cs @@ -1,4 +1,4 @@ -using System; + /* 3.3.12. PTR RDATA format @@ -32,13 +32,13 @@ public class RecordPtr : Record /// for the record data public RecordPtr(RecordReader rr) { - this.PointerDomain = rr.ReadDomainName(); + PointerDomain = rr.ReadDomainName(); } /// /// Gets or sets the pointer domain /// - public String PointerDomain { get; set; } + public string PointerDomain { get; set; } /// /// String representation of the record data @@ -46,7 +46,7 @@ public RecordPtr(RecordReader rr) /// Pointer domain as a string public override string ToString() { - return this.PointerDomain; + return PointerDomain; } } -} +} \ No newline at end of file diff --git a/src/Ubiety.Dns.Core/Records/RecordPX.cs b/src/Ubiety.Dns.Core/Records/RecordPX.cs index 5b8e7d9..1e8de1b 100644 --- a/src/Ubiety.Dns.Core/Records/RecordPX.cs +++ b/src/Ubiety.Dns.Core/Records/RecordPX.cs @@ -1,4 +1,4 @@ -using System; + /* * http://tools.ietf.org/rfc/rfc2163.txt @@ -82,33 +82,33 @@ public class RecordPx : Record /// for the record data public RecordPx(RecordReader rr) { - this.Preference = rr.ReadUInt16(); - this.Map822 = rr.ReadDomainName(); - this.MapX400 = rr.ReadDomainName(); + Preference = rr.ReadUInt16(); + Map822 = rr.ReadDomainName(); + MapX400 = rr.ReadDomainName(); } /// /// Gets or sets the preference /// - public UInt16 Preference { get; set; } + public ushort Preference { get; set; } /// /// Gets or sets the map to 822 /// - public String Map822 { get; set; } + public string Map822 { get; set; } /// /// Gets or sets the map to X.400 /// - public String MapX400 { get; set; } + public string MapX400 { get; set; } /// /// String representation of the record data /// /// Mappings as a string - public override String ToString() + public override string ToString() { - return $"{this.Preference} {this.Map822} {this.MapX400}"; + return $"{Preference} {Map822} {MapX400}"; } } -} +} \ No newline at end of file diff --git a/src/Ubiety.Dns.Core/Records/RecordRP.cs b/src/Ubiety.Dns.Core/Records/RecordRP.cs index c8a1b9f..8844a9e 100644 --- a/src/Ubiety.Dns.Core/Records/RecordRP.cs +++ b/src/Ubiety.Dns.Core/Records/RecordRP.cs @@ -1,4 +1,4 @@ -using System; + /* http://tools.ietf.org/rfc/rfc1183.txt @@ -43,27 +43,27 @@ public class RecordRp : Record /// for the record data public RecordRp(RecordReader rr) { - this.MailboxDomain = rr.ReadDomainName(); - this.TxtDomain = rr.ReadDomainName(); + MailboxDomain = rr.ReadDomainName(); + TxtDomain = rr.ReadDomainName(); } /// /// Gets or sets the mailbox domain /// - public String MailboxDomain { get; set; } + public string MailboxDomain { get; set; } /// /// Gets or sets the text domain /// - public String TxtDomain { get; set; } + public string TxtDomain { get; set; } /// /// String representation of the record data /// /// Domains as a string - public override String ToString() + public override string ToString() { - return $"{this.MailboxDomain} {this.TxtDomain}"; + return $"{MailboxDomain} {TxtDomain}"; } } -} +} \ No newline at end of file diff --git a/src/Ubiety.Dns.Core/Records/RecordRT.cs b/src/Ubiety.Dns.Core/Records/RecordRT.cs index 2cc28d3..f4559c4 100644 --- a/src/Ubiety.Dns.Core/Records/RecordRT.cs +++ b/src/Ubiety.Dns.Core/Records/RecordRT.cs @@ -1,4 +1,4 @@ -using System; + /* http://tools.ietf.org/rfc/rfc1183.txt @@ -66,27 +66,27 @@ public class RecordRt : Record /// for the record data public RecordRt(RecordReader rr) { - this.Preference = rr.ReadUInt16(); - this.IntermediateHost = rr.ReadDomainName(); + Preference = rr.ReadUInt16(); + IntermediateHost = rr.ReadDomainName(); } /// /// Gets or sets the route preference /// - public UInt16 Preference { get; set; } + public ushort Preference { get; set; } /// /// Gets or sets the intermediate host /// - public String IntermediateHost { get; set; } + public string IntermediateHost { get; set; } /// /// String representation of the record data /// /// Preference and host as a string - public override String ToString() + public override string ToString() { - return $"{this.Preference} {this.IntermediateHost}"; + return $"{Preference} {IntermediateHost}"; } } -} +} \ No newline at end of file diff --git a/src/Ubiety.Dns.Core/Records/RecordSIG.cs b/src/Ubiety.Dns.Core/Records/RecordSIG.cs index 28058e5..3fd34fc 100644 --- a/src/Ubiety.Dns.Core/Records/RecordSIG.cs +++ b/src/Ubiety.Dns.Core/Records/RecordSIG.cs @@ -1,4 +1,3 @@ -using System; using System.Globalization; namespace Ubiety.Dns.Core.Records @@ -14,21 +13,21 @@ public class RecordSig : Record /// Record reader for the record data public RecordSig(RecordReader rr) { - this.TypeCovered = rr.ReadUInt16(); - this.Algorithm = rr.ReadByte(); - this.Labels = rr.ReadByte(); - this.OriginalTTL = rr.ReadUInt32(); - this.SignatureExpiration = rr.ReadUInt32(); - this.SignatureInception = rr.ReadUInt32(); - this.KeyTag = rr.ReadUInt16(); - this.SignersName = rr.ReadDomainName(); - this.Signature = rr.ReadString(); + TypeCovered = rr.ReadUInt16(); + Algorithm = rr.ReadByte(); + Labels = rr.ReadByte(); + OriginalTTL = rr.ReadUInt32(); + SignatureExpiration = rr.ReadUInt32(); + SignatureInception = rr.ReadUInt32(); + KeyTag = rr.ReadUInt16(); + SignersName = rr.ReadDomainName(); + Signature = rr.ReadString(); } /// /// Gets or sets the type covered /// - public UInt16 TypeCovered { get; set; } + public ushort TypeCovered { get; set; } /// /// Gets or sets the signature algorithm @@ -43,22 +42,22 @@ public RecordSig(RecordReader rr) /// /// Gets or sets the original TTL /// - public UInt32 OriginalTTL { get; set; } + public uint OriginalTTL { get; set; } /// /// Gets or sets the signature expiration /// - public UInt32 SignatureExpiration { get; set; } + public uint SignatureExpiration { get; set; } /// /// Gets or sets the signature inception /// - public UInt32 SignatureInception { get; set; } + public uint SignatureInception { get; set; } /// /// Gets or sets the key tag /// - public UInt16 KeyTag { get; set; } + public ushort KeyTag { get; set; } /// /// Gets or sets the signers name @@ -79,15 +78,15 @@ public override string ToString() return string.Format( CultureInfo.InvariantCulture, "{0} {1} {2} {3} {4} {5} {6} {7} \"{8}\"", - this.TypeCovered, - this.Algorithm, - this.Labels, - this.OriginalTTL, - this.SignatureExpiration, - this.SignatureInception, - this.KeyTag, - this.SignersName, - this.Signature); + TypeCovered, + Algorithm, + Labels, + OriginalTTL, + SignatureExpiration, + SignatureInception, + KeyTag, + SignersName, + Signature); } } } \ No newline at end of file diff --git a/src/Ubiety.Dns.Core/Records/RecordSOA.cs b/src/Ubiety.Dns.Core/Records/RecordSOA.cs index 1c66b53..80e8fce 100644 --- a/src/Ubiety.Dns.Core/Records/RecordSOA.cs +++ b/src/Ubiety.Dns.Core/Records/RecordSOA.cs @@ -1,4 +1,4 @@ -using System; + /* 3.3.13. SOA RDATA format @@ -80,49 +80,49 @@ public class RecordSoa : Record /// for the record data public RecordSoa(RecordReader rr) { - this.PrimaryNameserver = rr.ReadDomainName(); - this.ResponsibleDomain = rr.ReadDomainName(); - this.Serial = rr.ReadUInt32(); - this.Refresh = rr.ReadUInt32(); - this.Retry = rr.ReadUInt32(); - this.Expire = rr.ReadUInt32(); - this.Minimum = rr.ReadUInt32(); + PrimaryNameserver = rr.ReadDomainName(); + ResponsibleDomain = rr.ReadDomainName(); + Serial = rr.ReadUInt32(); + Refresh = rr.ReadUInt32(); + Retry = rr.ReadUInt32(); + Expire = rr.ReadUInt32(); + Minimum = rr.ReadUInt32(); } /// /// Gets or sets the primary nameserver /// - public String PrimaryNameserver { get; set; } + public string PrimaryNameserver { get; set; } /// /// Gets or sets the responsible domain /// - public String ResponsibleDomain { get; set; } + public string ResponsibleDomain { get; set; } /// /// Gets or sets the serial /// - public UInt32 Serial { get; set; } + public uint Serial { get; set; } /// /// Gets or sets the refresh interval /// - public UInt32 Refresh { get; set; } + public uint Refresh { get; set; } /// /// Gets or sets the retry interval /// - public UInt32 Retry { get; set; } + public uint Retry { get; set; } /// /// Gets or sets the expiration time /// - public UInt32 Expire { get; set; } + public uint Expire { get; set; } /// /// Gets or sets the minimum TTL /// - public UInt32 Minimum { get; set; } + public uint Minimum { get; set; } /// /// String representation of the record data @@ -130,7 +130,7 @@ public RecordSoa(RecordReader rr) /// Record data as the string public override string ToString() { - return $"{this.PrimaryNameserver} {this.ResponsibleDomain} {this.Serial} {this.Refresh} {this.Retry} {this.Expire} {this.Minimum}"; + return $"{PrimaryNameserver} {ResponsibleDomain} {Serial} {Refresh} {Retry} {Expire} {Minimum}"; } } -} +} \ No newline at end of file diff --git a/src/Ubiety.Dns.Core/Records/RecordSRV.cs b/src/Ubiety.Dns.Core/Records/RecordSRV.cs index 291f39c..2082eb7 100644 --- a/src/Ubiety.Dns.Core/Records/RecordSRV.cs +++ b/src/Ubiety.Dns.Core/Records/RecordSRV.cs @@ -1,4 +1,4 @@ -using System; + /* * http://www.ietf.org/rfc/rfc2782.txt @@ -77,39 +77,39 @@ public class RecordSrv : Record /// of the record data public RecordSrv(RecordReader rr) { - this.Priority = rr.ReadUInt16(); - this.Weight = rr.ReadUInt16(); - this.Port = rr.ReadUInt16(); - this.Target = rr.ReadDomainName(); + Priority = rr.ReadUInt16(); + Weight = rr.ReadUInt16(); + Port = rr.ReadUInt16(); + Target = rr.ReadDomainName(); } /// /// Gets or sets the record priority /// - public UInt16 Priority { get; set; } + public ushort Priority { get; set; } /// /// Gets or sets the record weight /// - public UInt16 Weight { get; set; } + public ushort Weight { get; set; } /// /// Gets or sets the service port /// - public UInt16 Port { get; set; } + public ushort Port { get; set; } /// /// Gets or sets the target domain /// - public String Target { get; set; } + public string Target { get; set; } /// /// String representation of the record data /// /// Record as a string - public override String ToString() + public override string ToString() { - return $"{this.Priority} {this.Weight} {this.Port} {this.Target}"; + return $"{Priority} {Weight} {Port} {Target}"; } } -} +} \ No newline at end of file diff --git a/src/Ubiety.Dns.Core/Records/RecordTKEY.cs b/src/Ubiety.Dns.Core/Records/RecordTKEY.cs index 874f8f1..1042331 100644 --- a/src/Ubiety.Dns.Core/Records/RecordTKEY.cs +++ b/src/Ubiety.Dns.Core/Records/RecordTKEY.cs @@ -1,4 +1,3 @@ -using System; using System.Collections.Generic; using System.Globalization; @@ -31,8 +30,8 @@ namespace Ubiety.Dns.Core.Records /// public class RecordTkey : Record { - private readonly Byte[] keyData; - private readonly Byte[] otherData; + private readonly byte[] keyData; + private readonly byte[] otherData; /// /// Initializes a new instance of the class @@ -40,76 +39,76 @@ public class RecordTkey : Record /// for the record data public RecordTkey(RecordReader rr) { - this.Algorithm = rr.ReadDomainName(); - this.Inception = rr.ReadUInt32(); - this.Expiration = rr.ReadUInt32(); - this.Mode = rr.ReadUInt16(); - this.Error = rr.ReadUInt16(); - this.KeySize = rr.ReadUInt16(); - this.keyData = rr.ReadBytes(this.KeySize); - this.OtherSize = rr.ReadUInt16(); - this.otherData = rr.ReadBytes(this.OtherSize); + Algorithm = rr.ReadDomainName(); + Inception = rr.ReadUInt32(); + Expiration = rr.ReadUInt32(); + Mode = rr.ReadUInt16(); + Error = rr.ReadUInt16(); + KeySize = rr.ReadUInt16(); + keyData = rr.ReadBytes(KeySize); + OtherSize = rr.ReadUInt16(); + otherData = rr.ReadBytes(OtherSize); } /// /// Gets the key algorithm /// - public String Algorithm { get; } + public string Algorithm { get; } /// /// Gets the inception time of the key /// - public UInt32 Inception { get; } + public uint Inception { get; } /// /// Gets the expiration time of the key /// - public UInt32 Expiration { get; } + public uint Expiration { get; } /// /// Gets the key agreement mode /// - public UInt16 Mode { get; } + public ushort Mode { get; } /// /// Gets the error code of the record /// - public UInt16 Error { get; } + public ushort Error { get; } /// /// Gets the key size from the record /// - public UInt16 KeySize { get; } + public ushort KeySize { get; } /// /// Gets the key data /// - public List KeyData { get => new List(this.keyData); } + public List KeyData => new List(keyData); /// /// Gets the other size from the record (Future use) /// - public UInt16 OtherSize { get; } + public ushort OtherSize { get; } /// /// Gets the other data from the record (Future use) /// - public List OtherData { get => new List(this.otherData); } + public List OtherData => new List(otherData); /// /// String representation of the record data /// /// Key data as a string - public override String ToString() + public override string ToString() { return string.Format( CultureInfo.InvariantCulture, "{0} {1} {2} {3} {4}", - this.Algorithm, - this.Inception, - this.Expiration, - this.Mode, - this.Error); + Algorithm, + Inception, + Expiration, + Mode, + Error); } } -} +} \ No newline at end of file diff --git a/src/Ubiety.Dns.Core/Records/RecordTSIG.cs b/src/Ubiety.Dns.Core/Records/RecordTSIG.cs index 0b7f980..bf7f886 100644 --- a/src/Ubiety.Dns.Core/Records/RecordTSIG.cs +++ b/src/Ubiety.Dns.Core/Records/RecordTSIG.cs @@ -30,8 +30,8 @@ namespace Ubiety.Dns.Core.Records /// public class RecordTsig : Record { - private readonly Byte[] mac; - private readonly Byte[] otherData; + private readonly byte[] mac; + private readonly byte[] otherData; /// /// Initializes a new instance of the class @@ -39,79 +39,79 @@ public class RecordTsig : Record /// for the record data public RecordTsig(RecordReader rr) { - this.AlgorithmName = rr.ReadDomainName(); - this.TimeSigned = rr.ReadUInt32() << 32 | rr.ReadUInt32(); - this.Fudge = rr.ReadUInt16(); - this.MacSize = rr.ReadUInt16(); - this.mac = rr.ReadBytes(this.MacSize); - this.OriginalId = rr.ReadUInt16(); - this.Error = rr.ReadUInt16(); - this.OtherLength = rr.ReadUInt16(); - this.otherData = rr.ReadBytes(this.OtherLength); + AlgorithmName = rr.ReadDomainName(); + TimeSigned = (rr.ReadUInt32() << 32) | rr.ReadUInt32(); + Fudge = rr.ReadUInt16(); + MacSize = rr.ReadUInt16(); + mac = rr.ReadBytes(MacSize); + OriginalId = rr.ReadUInt16(); + Error = rr.ReadUInt16(); + OtherLength = rr.ReadUInt16(); + otherData = rr.ReadBytes(OtherLength); } /// /// Gets or sets the algorithm name /// - public String AlgorithmName { get; set; } + public string AlgorithmName { get; set; } /// /// Gets or sets the time signed /// - public Int64 TimeSigned { get; set; } + public long TimeSigned { get; set; } /// /// Gets or sets the number of seconds of error /// - public UInt16 Fudge { get; set; } + public ushort Fudge { get; set; } /// /// Gets or sets the MAC size /// - public UInt16 MacSize { get; set; } + public ushort MacSize { get; set; } /// /// Gets the MAC /// - public List Mac { get => new List(this.mac); } + public List Mac => new List(mac); /// /// Gets or sets the original id /// - public UInt16 OriginalId { get; set; } + public ushort OriginalId { get; set; } /// /// Gets or sets the record error /// - public UInt16 Error { get; set; } + public ushort Error { get; set; } /// /// Gets or sets the length of other data /// - public UInt16 OtherLength { get; set; } + public ushort OtherLength { get; set; } /// /// Gets the other record data /// - public List OtherData { get => new List(this.otherData); } + public List OtherData => new List(otherData); /// /// String representation of the record data /// /// Signature as a string - public override String ToString() + public override string ToString() { - DateTime dateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0); - dateTime = dateTime.AddSeconds(this.TimeSigned); - String printDate = dateTime.ToShortDateString() + " " + dateTime.ToShortTimeString(); + var dateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0); + dateTime = dateTime.AddSeconds(TimeSigned); + var printDate = dateTime.ToShortDateString() + " " + dateTime.ToShortTimeString(); return string.Format( CultureInfo.InvariantCulture, "{0} {1} {2} {3} {4}", - this.AlgorithmName, + AlgorithmName, printDate, - this.Fudge, - this.OriginalId, - this.Error); + Fudge, + OriginalId, + Error); } } -} +} \ No newline at end of file diff --git a/src/Ubiety.Dns.Core/Records/RecordTXT.cs b/src/Ubiety.Dns.Core/Records/RecordTXT.cs index 97cda53..4bef39b 100644 --- a/src/Ubiety.Dns.Core/Records/RecordTXT.cs +++ b/src/Ubiety.Dns.Core/Records/RecordTXT.cs @@ -1,4 +1,4 @@ -using System; + /* 3.3.14. TXT RDATA format @@ -29,21 +29,21 @@ public class RecordTxt : Record /// for the record data public RecordTxt(RecordReader rr) { - this.Text = rr.ReadString(); + Text = rr.ReadString(); } /// /// Gets or sets the text /// - public String Text { get; set; } + public string Text { get; set; } /// /// String representation of the record data /// /// Text as a string - public override String ToString() + public override string ToString() { - return $"\"{this.Text}\""; + return $"\"{Text}\""; } } -} +} \ No newline at end of file diff --git a/src/Ubiety.Dns.Core/Records/RecordWKS.cs b/src/Ubiety.Dns.Core/Records/RecordWKS.cs index 597fa43..3f0a55b 100644 --- a/src/Ubiety.Dns.Core/Records/RecordWKS.cs +++ b/src/Ubiety.Dns.Core/Records/RecordWKS.cs @@ -1,4 +1,3 @@ -using System; using System.Collections.ObjectModel; using System.Globalization; @@ -54,7 +53,7 @@ namespace Ubiety.Dns.Core.Records /// public class RecordWks : Record { - private readonly Byte[] bitmap; + private readonly byte[] bitmap; /// /// Initializes a new instance of the class @@ -62,42 +61,42 @@ public class RecordWks : Record /// Record reader for record data public RecordWks(RecordReader rr) { - UInt16 length = rr.ReadUInt16(-2); - this.Address = string.Format( + var length = rr.ReadUInt16(-2); + Address = string.Format( CultureInfo.InvariantCulture, "{0}.{1}.{2}.{3}", rr.ReadByte(), rr.ReadByte(), rr.ReadByte(), rr.ReadByte()); - this.Protocol = (Int32)rr.ReadByte(); + Protocol = rr.ReadByte(); length -= 5; - this.bitmap = new Byte[length]; - this.bitmap = rr.ReadBytes(length); + bitmap = new byte[length]; + bitmap = rr.ReadBytes(length); } /// /// Gets or sets the address of the server /// - public String Address { get; set; } + public string Address { get; set; } /// /// Gets or sets the protocol of the service /// - public Int32 Protocol { get; set; } + public int Protocol { get; set; } /// /// Gets the service bitmap /// - public Collection Bitmap { get => new Collection(this.bitmap); } + public Collection Bitmap => new Collection(bitmap); /// /// Return a string of the well known service record /// /// String of the record - public override String ToString() + public override string ToString() { - return string.Format(CultureInfo.InvariantCulture, "{0} {1}", this.Address, this.Protocol); + return string.Format(CultureInfo.InvariantCulture, "{0} {1}", Address, Protocol); } } -} +} \ No newline at end of file diff --git a/src/Ubiety.Dns.Core/Records/RecordX25.cs b/src/Ubiety.Dns.Core/Records/RecordX25.cs index 5a545e9..7e8f45e 100644 --- a/src/Ubiety.Dns.Core/Records/RecordX25.cs +++ b/src/Ubiety.Dns.Core/Records/RecordX25.cs @@ -1,4 +1,4 @@ -using System; + /* http://tools.ietf.org/rfc/rfc1183.txt @@ -44,21 +44,21 @@ public class RecordX25 : Record /// for the record data public RecordX25(RecordReader rr) { - this.PSDNAdress = rr.ReadString(); + PSDNAdress = rr.ReadString(); } /// /// Gets or sets the PSDN address /// - public String PSDNAdress { get; set; } + public string PSDNAdress { get; set; } /// /// String representation of the record data /// /// PSDN address as a string - public override String ToString() + public override string ToString() { - return this.PSDNAdress; + return PSDNAdress; } } -} +} \ No newline at end of file diff --git a/src/Ubiety.Dns.Core/Request.cs b/src/Ubiety.Dns.Core/Request.cs index 21342ac..80c313c 100644 --- a/src/Ubiety.Dns.Core/Request.cs +++ b/src/Ubiety.Dns.Core/Request.cs @@ -1,6 +1,4 @@ -using System; using System.Collections.Generic; -using System.Text; using Ubiety.Dns.Core.Common; namespace Ubiety.Dns.Core @@ -10,40 +8,42 @@ namespace Ubiety.Dns.Core /// public class Request { - private readonly List questions; + private readonly List _questions; /// /// Initializes a new instance of the class /// public Request() { - this.Header = new Header(); - this.Header.OpCode = OperationCode.Query; - this.Header.QuestionCount = 0; + Header = new Header + { + OpCode = OperationCode.Query, + QuestionCount = 0 + }; - this.questions = new List(); + _questions = new List(); } /// - /// Gets or sets the DNS record header + /// Gets the DNS record header /// - public Header Header { get; set; } + public Header Header { get; } /// /// Gets the request as a byte array /// /// Byte array of the data - public Byte[] GetData() + public byte[] GetData() { - List data = new List(); - this.Header.QuestionCount = (UInt16)this.questions.Count; - data.AddRange(this.Header.GetData()); - foreach (Question q in this.questions) - { - data.AddRange(q.GetData()); - } + var data = new List(); + Header.QuestionCount = (ushort)_questions.Count; + data.AddRange(Header.GetData()); + foreach (var q in _questions) + { + data.AddRange(q.GetData()); + } - return data.ToArray(); + return data.ToArray(); } /// @@ -52,7 +52,7 @@ public Byte[] GetData() /// Question to add to the request public void AddQuestion(Question question) { - this.questions.Add(question); + _questions.Add(question); } } -} +} \ No newline at end of file diff --git a/src/Ubiety.Dns.Core/Resolver.cs b/src/Ubiety.Dns.Core/Resolver.cs index 64383b9..c53ea8e 100644 --- a/src/Ubiety.Dns.Core/Resolver.cs +++ b/src/Ubiety.Dns.Core/Resolver.cs @@ -1,12 +1,13 @@ using System; using System.Collections.Generic; -using System.Diagnostics; using System.Globalization; using System.IO; using System.Net; using System.Net.NetworkInformation; using System.Net.Sockets; +using System.Reflection; using System.Text; +using System.Text.RegularExpressions; using System.Threading.Tasks; using Ubiety.Dns.Core.Common; @@ -20,38 +21,33 @@ public class Resolver /// /// Default DNS port /// - public const Int32 DefaultPort = 53; + public const int DefaultPort = 53; - private readonly List dnsServers; - private readonly IPEndPoint[] defaultDnsServers = - { - new IPEndPoint(IPAddress.Parse("208.67.222.222"), DefaultPort), - new IPEndPoint(IPAddress.Parse("208.67.220.220"), DefaultPort) - }; + private readonly List _dnsServers; - private readonly Dictionary responseCache; + private readonly Dictionary _responseCache; + private int _retries; + private int _timeout; - private UInt16 unique; - private Boolean useCache; - private Int32 retries; - private Int32 timeout; + private ushort _unique; + private bool _useCache; /// /// Initializes a new instance of the class /// /// Set of DNS servers - public Resolver(IPEndPoint[] dnsServers) + public Resolver(IEnumerable dnsServers) { - this.responseCache = new Dictionary(); - this.dnsServers = new List(); - this.dnsServers.AddRange(dnsServers); - - this.unique = (UInt16)new Random().Next(); - this.retries = 3; - this.timeout = 1; - this.Recursion = true; - this.useCache = true; - this.TransportType = TransportType.Udp; + _responseCache = new Dictionary(); + _dnsServers = new List(); + _dnsServers.AddRange(dnsServers); + + _unique = (ushort)new Random().Next(); + _retries = 3; + _timeout = 1; + Recursion = true; + _useCache = true; + TransportType = TransportType.Udp; } /// @@ -59,7 +55,7 @@ public Resolver(IPEndPoint[] dnsServers) /// /// DNS server to use public Resolver(IPEndPoint dnsServer) - : this(new IPEndPoint[] { dnsServer }) + : this(new[] {dnsServer}) { } @@ -68,7 +64,7 @@ public Resolver(IPEndPoint dnsServer) /// /// DNS server to use /// DNS port to use - public Resolver(IPAddress serverIpAddress, Int32 serverPortNumber) + public Resolver(IPAddress serverIpAddress, int serverPortNumber) : this(new IPEndPoint(serverIpAddress, serverPortNumber)) { } @@ -78,7 +74,7 @@ public Resolver(IPAddress serverIpAddress, Int32 serverPortNumber) /// /// DNS server address to use /// DNS port to use - public Resolver(String serverIpAddress, Int32 serverPortNumber) + public Resolver(string serverIpAddress, int serverPortNumber) : this(IPAddress.Parse(serverIpAddress), serverPortNumber) { } @@ -87,7 +83,7 @@ public Resolver(String serverIpAddress, Int32 serverPortNumber) /// Initializes a new instance of the class /// /// DNS server address to use - public Resolver(String serverIpAddress) + public Resolver(string serverIpAddress) : this(IPAddress.Parse(serverIpAddress), DefaultPort) { } @@ -105,40 +101,35 @@ public Resolver() /// /// Object sending the event /// Event arguments - public delegate void VerboseEventHandler(Object sender, VerboseEventArgs e); + public delegate void VerboseEventHandler(object sender, VerboseEventArgs e); /// - /// Verbose messages from internal operations + /// Verbose messages from internal operations /// public event VerboseEventHandler OnVerbose; /// /// Gets the current version of the library /// - public static string Version - { - get => System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(); - } + public static string Version => Assembly.GetExecutingAssembly().GetName().Version.ToString(); /// /// Gets the default OpenDNS servers /// - public IPEndPoint[] DefaultDnsServers + public IPEndPoint[] DefaultDnsServers { get; } = { - get => this.defaultDnsServers; - } + new IPEndPoint(IPAddress.Parse("208.67.222.222"), DefaultPort), + new IPEndPoint(IPAddress.Parse("208.67.220.220"), DefaultPort) + }; /// /// Gets or sets timeout in milliseconds /// public int Timeout { - get => this.timeout; + get => _timeout; - set - { - this.timeout = value * 1000; - } + set => _timeout = value * 1000; } /// @@ -146,14 +137,11 @@ public int Timeout /// public int Retries { - get => this.retries; + get => _retries; set { - if (value >= 1) - { - this.retries = value; - } + if (value >= 1) _retries = value; } } @@ -172,15 +160,12 @@ public int Retries /// public IPEndPoint[] DnsServers { - get - { - return this.dnsServers.ToArray(); - } + get => _dnsServers.ToArray(); set { - this.dnsServers.Clear(); - this.dnsServers.AddRange(value); + _dnsServers.Clear(); + _dnsServers.AddRange(value); } } @@ -189,27 +174,26 @@ public IPEndPoint[] DnsServers /// public string DnsServer { - get - { - return this.dnsServers[0].Address.ToString(); - } + get => _dnsServers[0].Address.ToString(); set { IPAddress ip; if (IPAddress.TryParse(value, out ip)) { - this.dnsServers.Clear(); - this.dnsServers.Add(new IPEndPoint(ip, DefaultPort)); + _dnsServers.Clear(); + _dnsServers.Add(new IPEndPoint(ip, DefaultPort)); return; } - Response response = this.Query(value, QuestionType.A); - if (response.RecordA.Count > 0) + var response = Query(value, QuestionType.A); + if (response.RecordA.Count <= 0) { - this.dnsServers.Clear(); - this.dnsServers.Add(new IPEndPoint(response.RecordA[0].Address, DefaultPort)); + return; } + + _dnsServers.Clear(); + _dnsServers.Add(new IPEndPoint(response.RecordA[0].Address, DefaultPort)); } } @@ -218,17 +202,14 @@ public string DnsServer /// public bool UseCache { - get - { - return this.useCache; - } + get => _useCache; set { - this.useCache = value; - if (!this.useCache) + _useCache = value; + if (!_useCache) { - this.responseCache.Clear(); + _responseCache.Clear(); } } } @@ -237,25 +218,27 @@ public bool UseCache /// Gets a list of default DNS servers used on the Windows machine. /// /// Array of DNS servers - public static IPEndPoint[] GetDnsServers() + public static IEnumerable GetDnsServers() { - List list = new List(); + var list = new List(); - NetworkInterface[] adapters = NetworkInterface.GetAllNetworkInterfaces(); - foreach (NetworkInterface n in adapters) + var adapters = NetworkInterface.GetAllNetworkInterfaces(); + foreach (var n in adapters) { - if (n.OperationalStatus == OperationalStatus.Up) + if (n.OperationalStatus != OperationalStatus.Up) { - IPInterfaceProperties ipProps = n.GetIPProperties(); + continue; + } - // thanks to Jon Webster on May 20, 2008 - foreach (IPAddress ipAddr in ipProps.DnsAddresses) + var ipProps = n.GetIPProperties(); + + // thanks to Jon Webster on May 20, 2008 + foreach (var ipAddr in ipProps.DnsAddresses) + { + var entry = new IPEndPoint(ipAddr, DefaultPort); + if (!list.Contains(entry)) { - IPEndPoint entry = new IPEndPoint(ipAddr, DefaultPort); - if (!list.Contains(entry)) - { - list.Add(entry); - } + list.Add(entry); } } } @@ -268,31 +251,33 @@ public static IPEndPoint[] GetDnsServers() /// /// IP address to get the arpa address form /// The 'mirrored' IPV4 or IPV6 arpa address - public static String GetArpaFromIp(IPAddress ip) + public static string GetArpaFromIp(IPAddress ip) { - if (ip.AddressFamily == AddressFamily.InterNetwork) + switch (ip.AddressFamily) { - StringBuilder sb = new StringBuilder(); - sb.Append("in-addr.arpa."); - foreach (Byte b in ip.GetAddressBytes()) + case AddressFamily.InterNetwork: { - sb.Insert(0, $"{b}."); - } - - return sb.ToString(); - } + var sb = new StringBuilder(); + sb.Append("in-addr.arpa."); + foreach (var b in ip.GetAddressBytes()) + { + sb.Insert(0, $"{b}."); + } - if (ip.AddressFamily == AddressFamily.InterNetworkV6) - { - StringBuilder sb = new StringBuilder(); - sb.Append("ip6.arpa."); - foreach (byte b in ip.GetAddressBytes()) - { - sb.Insert(0, $"{(b >> 4) & 0xf:x}."); - sb.Insert(0, $"{(b >> 0) & 0xf:x}."); + return sb.ToString(); } + case AddressFamily.InterNetworkV6: + { + var sb = new StringBuilder(); + sb.Append("ip6.arpa."); + foreach (var b in ip.GetAddressBytes()) + { + sb.Insert(0, $"{(b >> 4) & 0xf:x}."); + sb.Insert(0, $"{(b >> 0) & 0xf:x}."); + } - return sb.ToString(); + return sb.ToString(); + } } return "?"; @@ -303,12 +288,12 @@ public static String GetArpaFromIp(IPAddress ip) /// /// Enum for the address /// String of the ARPA address - public static String GetArpaFromEnum(String enumerator) + public static string GetArpaFromEnum(string enumerator) { - StringBuilder sb = new StringBuilder(); - String number = System.Text.RegularExpressions.Regex.Replace(enumerator, "[^0-9]", String.Empty); + var sb = new StringBuilder(); + var number = Regex.Replace(enumerator, "[^0-9]", string.Empty); sb.Append("e164.arpa."); - foreach (Char c in number) + foreach (var c in number) { sb.Insert(0, $"{c}."); } @@ -321,7 +306,7 @@ public static String GetArpaFromEnum(String enumerator) /// public void ClearCache() { - this.responseCache.Clear(); + _responseCache.Clear(); } /// @@ -331,18 +316,18 @@ public void ClearCache() /// Question type /// Class type /// Response of the query - public Response Query(String name, QuestionType qtype, QuestionClass qclass) + public Response Query(string name, QuestionType qtype, QuestionClass qclass) { - Question question = new Question(name, qtype, qclass); - Response response = this.SearchInCache(question); + var question = new Question(name, qtype, qclass); + var response = SearchInCache(question); if (response != null) { return response; } - Request request = new Request(); + var request = new Request(); request.AddQuestion(question); - return this.GetResponse(request); + return GetResponse(request); } /// @@ -353,74 +338,77 @@ public Response Query(String name, QuestionType qtype, QuestionClass qclass) /// Response of the query public Response Query(string name, QuestionType qtype) { - Question question = new Question(name, qtype, QuestionClass.IN); - Response response = this.SearchInCache(question); + var question = new Question(name, qtype, QuestionClass.IN); + var response = SearchInCache(question); if (response != null) { return response; } - Request request = new Request(); + var request = new Request(); request.AddQuestion(question); - return this.GetResponse(request); + return GetResponse(request); } - private Response GetResponse(Request request) + private static void WriteRequest(Stream stream, Request request) { - request.Header.Id = this.unique; - request.Header.Recursion = this.Recursion; + var data = request.GetData(); + stream.WriteByte((byte)((data.Length >> 8) & 0xFF)); + stream.WriteByte((byte)(data.Length & 0xFF)); + stream.Write(data, 0, data.Length); + stream.Flush(); + } - if (this.TransportType == TransportType.Udp) - { - return this.UdpRequest(request); - } + private Response GetResponse(Request request) + { + request.Header.Id = _unique; + request.Header.Recursion = Recursion; - if (this.TransportType == TransportType.Tcp) + switch (TransportType) { - return this.TcpRequest(request).Result; + case TransportType.Udp: + return UdpRequest(request); + case TransportType.Tcp: + return TcpRequest(request).Result; } - Response response = new Response(); - response.Error = "Unknown TransportType"; + var response = new Response {Error = "Unknown TransportType"}; return response; } private void Verbose(string format, params object[] args) { - if (this.OnVerbose != null) - { - this.OnVerbose(this, new VerboseEventArgs(string.Format(CultureInfo.CurrentCulture, format, args))); - } + OnVerbose?.Invoke(this, new VerboseEventArgs(string.Format(CultureInfo.CurrentCulture, format, args))); } private Response SearchInCache(Question question) { - if (!this.useCache) + if (!_useCache) { return null; } - string strKey = question.QuestionClass + "-" + question.QuestionType + "-" + question.QuestionName; + var strKey = question.QuestionClass + "-" + question.QuestionType + "-" + question.QuestionName; - Response response = null; + Response response; - lock (this.responseCache) + lock (_responseCache) { - if (!this.responseCache.ContainsKey(strKey)) + if (!_responseCache.ContainsKey(strKey)) { return null; } - response = this.responseCache[strKey]; + response = _responseCache[strKey]; } - int timeLived = (int)((DateTime.Now.Ticks - response.TimeStamp.Ticks) / TimeSpan.TicksPerSecond); - foreach (ResourceRecord rr in response.ResourceRecords) + var timeLived = (int)((DateTime.Now.Ticks - response.TimeStamp.Ticks) / TimeSpan.TicksPerSecond); + foreach (var rr in response.ResourceRecords) { rr.TimeLived = timeLived; // The TTL property calculates its actual time to live - if (rr.TTL == 0) + if (rr.Ttl == 0) { return null; // out of date } @@ -431,7 +419,7 @@ private Response SearchInCache(Question question) private void AddToCache(Response response) { - if (!this.useCache) + if (!_useCache) { return; } @@ -448,71 +436,62 @@ private void AddToCache(Response response) return; } - Question question = response.Questions[0]; + var question = response.Questions[0]; - string strKey = question.QuestionClass + "-" + question.QuestionType + "-" + question.QuestionName; + var strKey = question.QuestionClass + "-" + question.QuestionType + "-" + question.QuestionName; - lock (this.responseCache) + lock (_responseCache) { - if (this.responseCache.ContainsKey(strKey)) - { - this.responseCache.Remove(strKey); - } + if (_responseCache.ContainsKey(strKey)) _responseCache.Remove(strKey); - this.responseCache.Add(strKey, response); + _responseCache.Add(strKey, response); } } private Response UdpRequest(Request request) { // RFC1035 max. size of a UDP datagram is 512 bytes - byte[] responseMessage = new byte[512]; + var responseMessage = new byte[512]; - for (int intAttempts = 0; intAttempts < this.retries; intAttempts++) + for (var intAttempts = 0; intAttempts < _retries; intAttempts++) + for (var intDnsServer = 0; intDnsServer < _dnsServers.Count; intDnsServer++) { - for (int intDnsServer = 0; intDnsServer < this.dnsServers.Count; intDnsServer++) - { - Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); - socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveTimeout, this.Timeout); + var socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); + socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveTimeout, Timeout); - try - { - socket.SendTo(request.GetData(), this.dnsServers[intDnsServer]); - int intReceived = socket.Receive(responseMessage); - byte[] data = new byte[intReceived]; - Array.Copy(responseMessage, data, intReceived); - Response response = new Response(this.dnsServers[intDnsServer], data); - this.AddToCache(response); - return response; - } - catch (SocketException) - { - this.Verbose($";; Connection to nameserver {intDnsServer + 1} failed"); - continue; // next try - } - finally - { - this.unique++; + try + { + socket.SendTo(request.GetData(), _dnsServers[intDnsServer]); + var intReceived = socket.Receive(responseMessage); + var data = new byte[intReceived]; + Array.Copy(responseMessage, data, intReceived); + var response = new Response(_dnsServers[intDnsServer], data); + AddToCache(response); + return response; + } + catch (SocketException) + { + Verbose($";; Connection to nameserver {intDnsServer + 1} failed"); + } + finally + { + _unique++; - // close the socket - socket.Close(); - } + // close the socket + socket.Close(); } } - Response responseTimeout = new Response(); - responseTimeout.Error = "Timeout Error"; + var responseTimeout = new Response {Error = "Timeout Error"}; return responseTimeout; } private async Task TcpRequest(Request request) { - for (int intAttempts = 0; intAttempts < this.retries; intAttempts++) - { - foreach (var server in this.dnsServers) + for (var intAttempts = 0; intAttempts < _retries; intAttempts++) + foreach (var server in _dnsServers) { - TcpClient client = new TcpClient(); - client.ReceiveTimeout = this.timeout; + var client = new TcpClient {ReceiveTimeout = _timeout}; try { @@ -521,7 +500,7 @@ private async Task TcpRequest(Request request) if (!client.Connected) { client.Close(); - this.Verbose($";; Connection to nameserver {server.Address} failed"); + Verbose($";; Connection to nameserver {server.Address} failed"); continue; } @@ -529,55 +508,43 @@ private async Task TcpRequest(Request request) WriteRequest(stream, request); - return this.ReceiveResponse(stream, server); + return ReceiveResponse(stream, server); } - catch(SocketException) + catch (SocketException) { - continue; } finally { - this.unique++; + _unique++; client.Close(); } } - } - Response responseTimeout = new Response(); - responseTimeout.Error = "Timeout Error"; + var responseTimeout = new Response {Error = "Timeout Error"}; return responseTimeout; } - private static void WriteRequest(BufferedStream stream, Request request) + private Response ReceiveResponse(Stream stream, IPEndPoint server) { - Byte[] data = request.GetData(); - stream.WriteByte((Byte)((data.Length >> 8) & 0xFF)); - stream.WriteByte((Byte)(data.Length & 0xFF)); - stream.Write(data, 0, data.Length); - stream.Flush(); - } - - private Response ReceiveResponse(BufferedStream stream, IPEndPoint server) - { - Response transferResponse = new Response(); - Int32 soa = 0; - Int32 messageSize = 0; + var transferResponse = new Response(); + var soa = 0; + var messageSize = 0; while (true) { - Int32 length = stream.ReadByte() << 8 | stream.ReadByte(); + var length = (stream.ReadByte() << 8) | stream.ReadByte(); if (length <= 0) { - this.Verbose($"Connection to nameserver {server.Address} failed"); + Verbose($"Connection to nameserver {server.Address} failed"); throw new SocketException(); } messageSize += length; - Byte[] data = new Byte[length]; + var data = new byte[length]; stream.Read(data, 0, length); - Response response = new Response(server, data); + var response = new Response(server, data); if (response.Header.ResponseCode != ResponseCode.NoError) { @@ -586,7 +553,7 @@ private Response ReceiveResponse(BufferedStream stream, IPEndPoint server) if (response.Questions[0].QuestionType != QuestionType.AXFR) { - this.AddToCache(response); + AddToCache(response); return response; } @@ -604,16 +571,18 @@ private Response ReceiveResponse(BufferedStream stream, IPEndPoint server) soa++; } - if (soa == 2) + if (soa != 2) { - transferResponse.Header.QuestionCount = (UInt16)transferResponse.Questions.Count; - transferResponse.Header.AnswerCount = (UInt16)transferResponse.Answers.Count; - transferResponse.Header.NameserverCount = (UInt16)transferResponse.Authorities.Count; - transferResponse.Header.AdditionalRecordsCount = (UInt16)transferResponse.Additionals.Count; - transferResponse.MessageSize = messageSize; - - return transferResponse; + continue; } + + transferResponse.Header.QuestionCount = (ushort)transferResponse.Questions.Count; + transferResponse.Header.AnswerCount = (ushort)transferResponse.Answers.Count; + transferResponse.Header.NameserverCount = (ushort)transferResponse.Authorities.Count; + transferResponse.Header.AdditionalRecordsCount = (ushort)transferResponse.Additionals.Count; + transferResponse.MessageSize = messageSize; + + return transferResponse; } } } // class diff --git a/src/Ubiety.Dns.Core/ResourceRecord.cs b/src/Ubiety.Dns.Core/ResourceRecord.cs index 92c8e86..5411a3c 100644 --- a/src/Ubiety.Dns.Core/ResourceRecord.cs +++ b/src/Ubiety.Dns.Core/ResourceRecord.cs @@ -60,68 +60,62 @@ according to the TYPE and CLASS of the resource record. */ /// - /// Resource Record (rfc1034 3.6.) + /// Resource Record (rfc1034 3.6.) /// public class ResourceRecord { - private UInt32 ttl; + private uint _ttl; /// /// Initializes a new instance of the class /// /// Record reader of the record data - public ResourceRecord(RecordReader rr) + protected ResourceRecord(RecordReader rr) { - this.TimeLived = 0; - this.Name = rr.ReadDomainName(); - this.Type = (RecordType)rr.ReadUInt16(); - this.Class = (OperationClass)rr.ReadUInt16(); - this.TTL = rr.ReadUInt32(); - this.RecordLength = rr.ReadUInt16(); - this.Record = rr.ReadRecord(this.Type); - this.Record.ResourceRecord = this; + TimeLived = 0; + Name = rr.ReadDomainName(); + Type = (RecordType)rr.ReadUInt16(); + Class = (OperationClass)rr.ReadUInt16(); + Ttl = rr.ReadUInt32(); + RecordLength = rr.ReadUInt16(); + Record = rr.ReadRecord(Type); + Record.ResourceRecord = this; } /// - /// Gets or sets the name of the node to which this resource record pertains + /// Gets the name of the node to which this resource record pertains /// - public String Name { get; set; } + public String Name { get; } /// - /// Gets or sets the type of resource record + /// Gets the type of resource record /// - public RecordType Type { get; set; } + public RecordType Type { get; } /// - /// Gets or sets the type class of resource record, mostly IN but can be CS, CH or HS + /// Gets the type class of resource record, mostly IN but can be CS, CH or HS /// - public OperationClass Class { get; set; } + public OperationClass Class { get; } /// - /// Gets or sets the time to live, the time interval that the resource record may be cached + /// Gets the time to live, the time interval that the resource record may be cached /// - public UInt32 TTL + public UInt32 Ttl { - get - { - return (UInt32)Math.Max(0, this.ttl - this.TimeLived); - } - - set - { - this.ttl = value; - } + get => (UInt32)Math.Max(0, _ttl - TimeLived); + + private set => _ttl = value; } /// - /// Gets or sets the record length + /// Gets the record length /// - public UInt16 RecordLength { get; set; } + public UInt16 RecordLength { get; } /// - /// Gets or sets one of the Record* classes + /// Gets one of the Record* classes /// - public Record Record { get; set; } + public Record Record { get; } /// /// Gets or sets the time lived @@ -134,7 +128,7 @@ public UInt32 TTL /// String of the resource public override String ToString() { - return $"{this.Name, -32} {this.TTL}\t{this.Class}\t{this.Type}\t{this.Record}"; + return $"{Name,-32} {Ttl}\t{Class}\t{Type}\t{Record}"; } } -} +} \ No newline at end of file diff --git a/src/Ubiety.Dns.Core/Response.cs b/src/Ubiety.Dns.Core/Response.cs index b59b75b..6f49b8c 100644 --- a/src/Ubiety.Dns.Core/Response.cs +++ b/src/Ubiety.Dns.Core/Response.cs @@ -1,9 +1,6 @@ using System; -using System.Collections; using System.Collections.Generic; -using System.IO; using System.Net; -using System.Text; using Ubiety.Dns.Core.Records; using Ubiety.Dns.Core.Records.General; using Ubiety.Dns.Core.Records.Mail; @@ -20,16 +17,16 @@ public class Response /// public Response() { - this.Questions = new List(); - this.Answers = new List(); - this.Authorities = new List(); - this.Additionals = new List(); - - this.Server = new IPEndPoint(0, 0); - this.Error = String.Empty; - this.MessageSize = 0; - this.TimeStamp = DateTime.Now; - this.Header = new Header(); + Questions = new List(); + Answers = new List(); + Authorities = new List(); + Additionals = new List(); + + Server = new IPEndPoint(0, 0); + Error = string.Empty; + MessageSize = 0; + TimeStamp = DateTime.Now; + Header = new Header(); } /// @@ -37,40 +34,28 @@ public Response() /// /// Address of the response /// Response data - public Response(IPEndPoint iPEndPoint, Byte[] data) + public Response(IPEndPoint iPEndPoint, byte[] data) { - this.Error = String.Empty; - this.Server = iPEndPoint; - this.TimeStamp = DateTime.Now; - this.MessageSize = data.Length; - RecordReader rr = new RecordReader(data); + Error = string.Empty; + Server = iPEndPoint; + TimeStamp = DateTime.Now; + MessageSize = data.Length; + var rr = new RecordReader(data); - this.Questions = new List(); - this.Answers = new List(); - this.Authorities = new List(); - this.Additionals = new List(); + Questions = new List(); + Answers = new List(); + Authorities = new List(); + Additionals = new List(); - this.Header = new Header(rr); + Header = new Header(rr); - for (Int32 i = 0; i < this.Header.QuestionCount; i++) - { - this.Questions.Add(new Question(rr)); - } + for (var i = 0; i < Header.QuestionCount; i++) Questions.Add(new Question(rr)); - for (Int32 i = 0; i < this.Header.AnswerCount; i++) - { - this.Answers.Add(new AnswerRR(rr)); - } + for (var i = 0; i < Header.AnswerCount; i++) Answers.Add(new AnswerRR(rr)); - for (Int32 i = 0; i < this.Header.NameserverCount; i++) - { - this.Authorities.Add(new AuthorityRR(rr)); - } + for (var i = 0; i < Header.NameserverCount; i++) Authorities.Add(new AuthorityRR(rr)); - for (Int32 i = 0; i < this.Header.AdditionalRecordsCount; i++) - { - this.Additionals.Add(new AdditionalRR(rr)); - } + for (var i = 0; i < Header.AdditionalRecordsCount; i++) Additionals.Add(new AdditionalRR(rr)); } /// @@ -94,29 +79,29 @@ public Response(IPEndPoint iPEndPoint, Byte[] data) public List Additionals { get; } /// - /// Gets or sets the response header + /// Gets the response header /// - public Header Header { get; set; } + public Header Header { get; } /// /// Gets or sets the error message, empty when no error /// - public String Error { get; set; } + public string Error { get; set; } /// /// Gets or sets the size of the message /// - public Int32 MessageSize { get; set; } + public int MessageSize { get; set; } /// /// Gets or sets the timestamp when cached /// - public DateTime TimeStamp { get; set; } + public DateTime TimeStamp { get; } /// - /// Gets or sets the server which delivered this response + /// Gets the server which delivered this response /// - public IPEndPoint Server { get; set; } + public IPEndPoint Server { get; } /// /// Gets a list of MX records in the answers @@ -125,10 +110,10 @@ public List RecordMx { get { - List list = new List(); - foreach (AnswerRR answerRR in this.Answers) + var list = new List(); + foreach (var rr in Answers) { - RecordMx record = answerRR.Record as RecordMx; + var record = rr.Record as RecordMx; if (record != null) { list.Add(record); @@ -147,11 +132,10 @@ public List RecordTxt { get { - List list = new List(); - foreach (AnswerRR answerRR in this.Answers) + var list = new List(); + foreach (var rr in Answers) { - RecordTxt record = answerRR.Record as RecordTxt; - if (record != null) + if (rr.Record is RecordTxt record) { list.Add(record); } @@ -168,11 +152,10 @@ public List RecordA { get { - List list = new List(); - foreach (AnswerRR answerRR in this.Answers) + var list = new List(); + foreach (var rr in Answers) { - RecordA record = answerRR.Record as RecordA; - if (record != null) + if (rr.Record is RecordA record) { list.Add(record); } @@ -189,11 +172,10 @@ public List RecordPtr { get { - List list = new List(); - foreach (AnswerRR answerRR in this.Answers) + var list = new List(); + foreach (var rr in Answers) { - RecordPtr record = answerRR.Record as RecordPtr; - if (record != null) + if (rr.Record is RecordPtr record) { list.Add(record); } @@ -210,11 +192,10 @@ public List RecordCname { get { - List list = new List(); - foreach (AnswerRR answerRR in this.Answers) + var list = new List(); + foreach (var rr in Answers) { - RecordCname record = answerRR.Record as RecordCname; - if (record != null) + if (rr.Record is RecordCname record) { list.Add(record); } @@ -231,11 +212,10 @@ public List RecordAAAA { get { - List list = new List(); - foreach (AnswerRR answerRR in this.Answers) + var list = new List(); + foreach (var rr in Answers) { - RecordAaaa record = answerRR.Record as RecordAaaa; - if (record != null) + if (rr.Record is RecordAaaa record) { list.Add(record); } @@ -252,11 +232,10 @@ public List RecordNS { get { - List list = new List(); - foreach (AnswerRR answerRR in this.Answers) + var list = new List(); + foreach (var rr in Answers) { - RecordNs record = answerRR.Record as RecordNs; - if (record != null) + if (rr.Record is RecordNs record) { list.Add(record); } @@ -273,11 +252,10 @@ public List RecordSOA { get { - List list = new List(); - foreach (AnswerRR answerRR in this.Answers) + var list = new List(); + foreach (var rr in Answers) { - RecordSoa record = answerRR.Record as RecordSoa; - if (record != null) + if (rr.Record is RecordSoa record) { list.Add(record); } @@ -294,11 +272,10 @@ public List RecordCERT { get { - List list = new List(); - foreach (AnswerRR answerRR in this.Answers) + var list = new List(); + foreach (var rr in Answers) { - RecordCert record = answerRR.Record as RecordCert; - if (record != null) + if (rr.Record is RecordCert record) { list.Add(record); } @@ -315,11 +292,10 @@ public List RecordSRV { get { - List list = new List(); - foreach (AnswerRR answerRR in this.Answers) + var list = new List(); + foreach (var rr in Answers) { - RecordSrv record = answerRR.Record as RecordSrv; - if (record != null) + if (rr.Record is RecordSrv record) { list.Add(record); } @@ -332,27 +308,27 @@ public List RecordSRV /// /// Gets a list of resource records in the answers /// - public List ResourceRecords + public IEnumerable ResourceRecords { get { - List list = new List(); - foreach (ResourceRecord rr in this.Answers) + var list = new List(); + foreach (var rr in Answers) { list.Add(rr); } - foreach (ResourceRecord rr in this.Answers) + foreach (var rr in Answers) { list.Add(rr); } - foreach (ResourceRecord rr in this.Authorities) + foreach (var rr in Authorities) { list.Add(rr); } - foreach (ResourceRecord rr in this.Additionals) + foreach (var rr in Additionals) { list.Add(rr); } @@ -361,4 +337,4 @@ public List ResourceRecords } } } -} +} \ No newline at end of file diff --git a/src/Ubiety.Dns.Core/stylecop.json b/src/Ubiety.Dns.Core/stylecop.json index b8c5f54..f2114ea 100644 --- a/src/Ubiety.Dns.Core/stylecop.json +++ b/src/Ubiety.Dns.Core/stylecop.json @@ -7,6 +7,9 @@ "indentationSize": 4, "tabSize": 4 }, + "readabilityRules": { + "allowBuiltInTypeAliases": true + }, "orderingRules": { "usingDirectivesPlacement": "outsideNamespace" } diff --git a/test/Ubiety.Dns.Test/Records/NotUsed/RecordA6Tests.cs b/test/Ubiety.Dns.Test/Records/NotUsed/RecordA6Tests.cs index b08e416..538d921 100644 --- a/test/Ubiety.Dns.Test/Records/NotUsed/RecordA6Tests.cs +++ b/test/Ubiety.Dns.Test/Records/NotUsed/RecordA6Tests.cs @@ -1,4 +1,3 @@ -using System; using Shouldly; using Ubiety.Dns.Core; using Ubiety.Dns.Core.Records.NotUsed; @@ -8,12 +7,9 @@ namespace Ubiety.Dns.Test.Records.NotUsed { public class RecordA6Tests { - private readonly Byte[] data; - private readonly RecordReader reader; - public RecordA6Tests() { - data = new Byte[4]; + data = new byte[4]; data[0] = 0; data[1] = 2; data[2] = 4; @@ -22,6 +18,9 @@ public RecordA6Tests() reader = new RecordReader(data, 2); } + private readonly byte[] data; + private readonly RecordReader reader; + [Fact] public void TestRecordData() { diff --git a/test/Ubiety.Dns.Test/Records/NotUsed/RecordAplTests.cs b/test/Ubiety.Dns.Test/Records/NotUsed/RecordAplTests.cs index 5bf3e8f..6a8d02b 100644 --- a/test/Ubiety.Dns.Test/Records/NotUsed/RecordAplTests.cs +++ b/test/Ubiety.Dns.Test/Records/NotUsed/RecordAplTests.cs @@ -1,4 +1,3 @@ -using System; using Shouldly; using Ubiety.Dns.Core; using Ubiety.Dns.Core.Records.NotUsed; @@ -8,12 +7,9 @@ namespace Ubiety.Dns.Test.Records.NotUsed { public class RecordAplTests { - private readonly Byte[] data; - private readonly RecordReader reader; - public RecordAplTests() { - data = new Byte[4]; + data = new byte[4]; data[0] = 0; data[1] = 2; data[2] = 4; @@ -22,6 +18,9 @@ public RecordAplTests() reader = new RecordReader(data, 2); } + private readonly byte[] data; + private readonly RecordReader reader; + [Fact] public void TestRecordData() { diff --git a/test/Ubiety.Dns.Test/Records/RecordATests.cs b/test/Ubiety.Dns.Test/Records/RecordATests.cs index ab8b7fe..60d0d9a 100644 --- a/test/Ubiety.Dns.Test/Records/RecordATests.cs +++ b/test/Ubiety.Dns.Test/Records/RecordATests.cs @@ -1,4 +1,3 @@ -using System; using System.Net; using Shouldly; using Ubiety.Dns.Core; @@ -9,9 +8,6 @@ namespace Ubiety.Dns.Test.Records { public class RecordATests { - private readonly Byte[] data = new Byte[4]; - private readonly RecordReader reader; - public RecordATests() { data[0] = 192; @@ -22,6 +18,9 @@ public RecordATests() reader = new RecordReader(data); } + private readonly byte[] data = new byte[4]; + private readonly RecordReader reader; + [Fact] public void TestRecordAddress() { diff --git a/test/Ubiety.Dns.Test/Records/RecordAaaaTests.cs b/test/Ubiety.Dns.Test/Records/RecordAaaaTests.cs index ed3f4ee..493b342 100644 --- a/test/Ubiety.Dns.Test/Records/RecordAaaaTests.cs +++ b/test/Ubiety.Dns.Test/Records/RecordAaaaTests.cs @@ -1,4 +1,3 @@ -using System; using System.Net; using Shouldly; using Ubiety.Dns.Core; @@ -9,9 +8,6 @@ namespace Ubiety.Dns.Test.Records { public class RecordAaaaTests { - private readonly Byte[] data = new Byte[16]; - private readonly RecordReader reader; - public RecordAaaaTests() { data[0] = 0x20; @@ -34,6 +30,9 @@ public RecordAaaaTests() reader = new RecordReader(data); } + private readonly byte[] data = new byte[16]; + private readonly RecordReader reader; + [Fact] public void TestRecordAddress() { diff --git a/test/Ubiety.Dns.Test/Ubiety.Dns.Test.csproj b/test/Ubiety.Dns.Test/Ubiety.Dns.Test.csproj index 56336bb..e877f01 100644 --- a/test/Ubiety.Dns.Test/Ubiety.Dns.Test.csproj +++ b/test/Ubiety.Dns.Test/Ubiety.Dns.Test.csproj @@ -1,21 +1,17 @@ - - + netcoreapp2.0 - false - - + - - + \ No newline at end of file From b95edd5b77a0b59c7f9a33fda67bb89342bc48bc Mon Sep 17 00:00:00 2001 From: Dieter Lunn Date: Wed, 20 Jun 2018 23:48:28 -0500 Subject: [PATCH 11/15] Refactor with stylecop --- src/ProjectLevel.ruleset | 3 +- src/Ubiety.Dns.Core/Question.cs | 7 +- src/Ubiety.Dns.Core/RecordReader.cs | 10 ++- src/Ubiety.Dns.Core/Records/Mail/RecordMB.cs | 2 - src/Ubiety.Dns.Core/Records/Mail/RecordMG.cs | 2 - src/Ubiety.Dns.Core/Records/Mail/RecordMX.cs | 88 +++++++++---------- .../Records/Obsolete/RecordGPOS.cs | 2 - .../Records/Obsolete/RecordMD.cs | 2 - .../Records/Obsolete/RecordMF.cs | 2 - .../Records/Obsolete/RecordNSAPPTR.cs | 4 +- .../Records/Obsolete/RecordNXT.cs | 35 ++++---- src/Ubiety.Dns.Core/Records/RecordDNAME.cs | 2 - src/Ubiety.Dns.Core/Records/RecordHINFO.cs | 2 - src/Ubiety.Dns.Core/Records/RecordISDN.cs | 2 - src/Ubiety.Dns.Core/Records/RecordKEY.cs | 2 - src/Ubiety.Dns.Core/Records/RecordLOC.cs | 13 +-- src/Ubiety.Dns.Core/Records/RecordNAPTR.cs | 2 - src/Ubiety.Dns.Core/Records/RecordNS.cs | 2 - src/Ubiety.Dns.Core/Records/RecordNSAP.cs | 30 ++++--- src/Ubiety.Dns.Core/Records/RecordPTR.cs | 2 - src/Ubiety.Dns.Core/Records/RecordPX.cs | 2 - src/Ubiety.Dns.Core/Records/RecordRP.cs | 2 - src/Ubiety.Dns.Core/Records/RecordRT.cs | 2 - src/Ubiety.Dns.Core/Records/RecordSOA.cs | 2 - src/Ubiety.Dns.Core/Records/RecordSRV.cs | 2 - src/Ubiety.Dns.Core/Records/RecordTKEY.cs | 12 +-- src/Ubiety.Dns.Core/Records/RecordTSIG.cs | 12 +-- src/Ubiety.Dns.Core/Records/RecordTXT.cs | 2 - src/Ubiety.Dns.Core/Records/RecordWKS.cs | 8 +- src/Ubiety.Dns.Core/Records/RecordX25.cs | 2 - src/Ubiety.Dns.Core/Resolver.cs | 79 ++++++++++------- src/Ubiety.Dns.Core/ResourceRecord.cs | 2 +- src/Ubiety.Dns.Core/Response.cs | 32 ++++--- 33 files changed, 187 insertions(+), 186 deletions(-) diff --git a/src/ProjectLevel.ruleset b/src/ProjectLevel.ruleset index 08e7823..00a4eaf 100644 --- a/src/ProjectLevel.ruleset +++ b/src/ProjectLevel.ruleset @@ -5,7 +5,8 @@ + - + diff --git a/src/Ubiety.Dns.Core/Question.cs b/src/Ubiety.Dns.Core/Question.cs index 92896d2..e933742 100644 --- a/src/Ubiety.Dns.Core/Question.cs +++ b/src/Ubiety.Dns.Core/Question.cs @@ -47,7 +47,10 @@ public String QuestionName private set { _questionName = value; - if (!_questionName.EndsWith(".", StringComparison.InvariantCulture)) _questionName += "."; + if (!_questionName.EndsWith(".", StringComparison.InvariantCulture)) + { + _questionName += "."; + } } } @@ -67,7 +70,7 @@ private set /// String of the question public override String ToString() { - return $"{QuestionName,-32}\t{QuestionClass}\t{QuestionType}"; + return $"{QuestionName, -32}\t{QuestionClass}\t{QuestionType}"; } /// diff --git a/src/Ubiety.Dns.Core/RecordReader.cs b/src/Ubiety.Dns.Core/RecordReader.cs index bf17fda..a153b8e 100644 --- a/src/Ubiety.Dns.Core/RecordReader.cs +++ b/src/Ubiety.Dns.Core/RecordReader.cs @@ -134,7 +134,10 @@ public String ReadString() Int16 length = ReadByte(); var name = new StringBuilder(); - for (var i = 0; i < length; i++) name.Append(ReadChar()); + for (var i = 0; i < length; i++) + { + name.Append(ReadChar()); + } return name.ToString(); } @@ -147,7 +150,10 @@ public String ReadString() public Byte[] ReadBytes(Int32 length) { var list = new List(); - for (var i = 0; i < length; i++) list.Add(ReadByte()); + for (var i = 0; i < length; i++) + { + list.Add(ReadByte()); + } return list.ToArray(); } diff --git a/src/Ubiety.Dns.Core/Records/Mail/RecordMB.cs b/src/Ubiety.Dns.Core/Records/Mail/RecordMB.cs index 64106c4..97e0045 100644 --- a/src/Ubiety.Dns.Core/Records/Mail/RecordMB.cs +++ b/src/Ubiety.Dns.Core/Records/Mail/RecordMB.cs @@ -1,5 +1,3 @@ - - /* 3.3.3. MB RDATA format (EXPERIMENTAL) diff --git a/src/Ubiety.Dns.Core/Records/Mail/RecordMG.cs b/src/Ubiety.Dns.Core/Records/Mail/RecordMG.cs index 33805ee..77c0c65 100644 --- a/src/Ubiety.Dns.Core/Records/Mail/RecordMG.cs +++ b/src/Ubiety.Dns.Core/Records/Mail/RecordMG.cs @@ -1,5 +1,3 @@ - - /* 3.3.6. MG RDATA format (EXPERIMENTAL) diff --git a/src/Ubiety.Dns.Core/Records/Mail/RecordMX.cs b/src/Ubiety.Dns.Core/Records/Mail/RecordMX.cs index c1fa00c..b59fbc8 100644 --- a/src/Ubiety.Dns.Core/Records/Mail/RecordMX.cs +++ b/src/Ubiety.Dns.Core/Records/Mail/RecordMX.cs @@ -50,6 +50,50 @@ public RecordMx(RecordReader rr) /// public String Exchange { get; } + /// + /// + /// + /// + public static Boolean operator <(RecordMx x, RecordMx y) + { + return CompareTo(x, y) < 0; + } + + /// + /// + public static Boolean operator >(RecordMx x, RecordMx y) + { + return CompareTo(x, y) > 0; + } + + /// + /// + public static Boolean operator <=(RecordMx x, RecordMx y) + { + return CompareTo(x, y) <= 0; + } + + /// + /// + public static Boolean operator >=(RecordMx x, RecordMx y) + { + return CompareTo(x, y) >= 0; + } + + /// + /// + public static Boolean operator ==(RecordMx x, RecordMx y) + { + return CompareTo(x, y) == 0; + } + + /// + /// + public static Boolean operator !=(RecordMx x, RecordMx y) + { + return CompareTo(x, y) != 0; + } + /// /// Compares record to an object /// @@ -113,50 +157,6 @@ public override Int32 GetHashCode() return Exchange.GetHashCode(); } - /// - /// - /// - /// - public static Boolean operator <(RecordMx x, RecordMx y) - { - return CompareTo(x, y) < 0; - } - - /// - /// - public static Boolean operator >(RecordMx x, RecordMx y) - { - return CompareTo(x, y) > 0; - } - - /// - /// - public static Boolean operator <=(RecordMx x, RecordMx y) - { - return CompareTo(x, y) <= 0; - } - - /// - /// - public static Boolean operator >=(RecordMx x, RecordMx y) - { - return CompareTo(x, y) >= 0; - } - - /// - /// - public static Boolean operator ==(RecordMx x, RecordMx y) - { - return CompareTo(x, y) == 0; - } - - /// - /// - public static Boolean operator !=(RecordMx x, RecordMx y) - { - return CompareTo(x, y) != 0; - } - private static Int32 CompareTo(RecordMx x, RecordMx y) { if (y == null) diff --git a/src/Ubiety.Dns.Core/Records/Obsolete/RecordGPOS.cs b/src/Ubiety.Dns.Core/Records/Obsolete/RecordGPOS.cs index 23404c9..189499f 100644 --- a/src/Ubiety.Dns.Core/Records/Obsolete/RecordGPOS.cs +++ b/src/Ubiety.Dns.Core/Records/Obsolete/RecordGPOS.cs @@ -1,5 +1,3 @@ - - /* * http://tools.ietf.org/rfc/rfc1712.txt * diff --git a/src/Ubiety.Dns.Core/Records/Obsolete/RecordMD.cs b/src/Ubiety.Dns.Core/Records/Obsolete/RecordMD.cs index e5db735..459e6dd 100644 --- a/src/Ubiety.Dns.Core/Records/Obsolete/RecordMD.cs +++ b/src/Ubiety.Dns.Core/Records/Obsolete/RecordMD.cs @@ -1,5 +1,3 @@ - - /* 3.3.4. MD RDATA format (Obsolete) diff --git a/src/Ubiety.Dns.Core/Records/Obsolete/RecordMF.cs b/src/Ubiety.Dns.Core/Records/Obsolete/RecordMF.cs index fa518a8..66660ca 100644 --- a/src/Ubiety.Dns.Core/Records/Obsolete/RecordMF.cs +++ b/src/Ubiety.Dns.Core/Records/Obsolete/RecordMF.cs @@ -1,5 +1,3 @@ - - /* * 3.3.5. MF RDATA format (Obsolete) diff --git a/src/Ubiety.Dns.Core/Records/Obsolete/RecordNSAPPTR.cs b/src/Ubiety.Dns.Core/Records/Obsolete/RecordNSAPPTR.cs index fc8c003..9d0101c 100644 --- a/src/Ubiety.Dns.Core/Records/Obsolete/RecordNSAPPTR.cs +++ b/src/Ubiety.Dns.Core/Records/Obsolete/RecordNSAPPTR.cs @@ -1,5 +1,3 @@ - - /* * http://tools.ietf.org/rfc/rfc1348.txt @@ -58,7 +56,7 @@ public RecordNsapPtr(RecordReader rr) } /// - /// Gets or sets the owner + /// Gets the owner /// public String Owner { get; } diff --git a/src/Ubiety.Dns.Core/Records/Obsolete/RecordNXT.cs b/src/Ubiety.Dns.Core/Records/Obsolete/RecordNXT.cs index 714392e..b070f78 100644 --- a/src/Ubiety.Dns.Core/Records/Obsolete/RecordNXT.cs +++ b/src/Ubiety.Dns.Core/Records/Obsolete/RecordNXT.cs @@ -1,4 +1,5 @@ -using System.Collections.ObjectModel; +using System; +using System.Collections.Generic; using System.Text; using Ubiety.Dns.Core.Common; @@ -45,7 +46,7 @@ namespace Ubiety.Dns.Core.Records.Obsolete /// public class RecordNxt : Record { - private readonly byte[] bitmap; + private readonly Byte[] _bitmap; /// /// Initializes a new instance of the class @@ -55,44 +56,46 @@ public RecordNxt(RecordReader rr) { var length = rr.ReadUInt16(-2); NextDomainName = rr.ReadDomainName(); - length -= (ushort) rr.Position; - bitmap = new byte[length]; - bitmap = rr.ReadBytes(length); + length -= (UInt16)rr.Position; + _bitmap = new Byte[length]; + _bitmap = rr.ReadBytes(length); } /// - /// Gets or sets the next domain name + /// Gets the next domain name /// - public string NextDomainName { get; set; } + public String NextDomainName { get; } /// /// Gets the record bitmap /// - public Collection Bitmap => new Collection(bitmap); + public List Bitmap => new List(_bitmap); /// /// String representation of the record /// /// String version of the data - public override string ToString() + public override String ToString() { var sb = new StringBuilder(); - for (var bitNr = 1; bitNr < bitmap.Length * 8; bitNr++) + for (var bitNr = 1; bitNr < _bitmap.Length * 8; bitNr++) + { if (IsSet(bitNr)) - sb.Append(" " + (RecordType) bitNr); + { + sb.Append(" " + (RecordType)bitNr); + } + } return $"{NextDomainName}{sb}"; } - private bool IsSet(int bitNr) + private bool IsSet(Int32 bitNr) { var intByte = bitNr / 8; var intOffset = bitNr % 8; - var b = bitmap[intByte]; + var b = _bitmap[intByte]; var intTest = 1 << intOffset; - if ((b & intTest) == 0) - return false; - return true; + return (b & intTest) != 0; } } } \ No newline at end of file diff --git a/src/Ubiety.Dns.Core/Records/RecordDNAME.cs b/src/Ubiety.Dns.Core/Records/RecordDNAME.cs index 181eb23..dea7bef 100644 --- a/src/Ubiety.Dns.Core/Records/RecordDNAME.cs +++ b/src/Ubiety.Dns.Core/Records/RecordDNAME.cs @@ -1,5 +1,3 @@ - - /* * http://tools.ietf.org/rfc/rfc2672.txt * diff --git a/src/Ubiety.Dns.Core/Records/RecordHINFO.cs b/src/Ubiety.Dns.Core/Records/RecordHINFO.cs index cb939e5..8f8414f 100644 --- a/src/Ubiety.Dns.Core/Records/RecordHINFO.cs +++ b/src/Ubiety.Dns.Core/Records/RecordHINFO.cs @@ -1,5 +1,3 @@ - - /* 3.3.2. HINFO RDATA format diff --git a/src/Ubiety.Dns.Core/Records/RecordISDN.cs b/src/Ubiety.Dns.Core/Records/RecordISDN.cs index cee3111..ef63f09 100644 --- a/src/Ubiety.Dns.Core/Records/RecordISDN.cs +++ b/src/Ubiety.Dns.Core/Records/RecordISDN.cs @@ -1,5 +1,3 @@ - - /* http://tools.ietf.org/rfc/rfc1183.txt 3.2. The ISDN RR diff --git a/src/Ubiety.Dns.Core/Records/RecordKEY.cs b/src/Ubiety.Dns.Core/Records/RecordKEY.cs index c46115e..b066403 100644 --- a/src/Ubiety.Dns.Core/Records/RecordKEY.cs +++ b/src/Ubiety.Dns.Core/Records/RecordKEY.cs @@ -1,5 +1,3 @@ - - /* http://www.ietf.org/rfc/rfc2535.txt * 3.1 KEY RDATA format diff --git a/src/Ubiety.Dns.Core/Records/RecordLOC.cs b/src/Ubiety.Dns.Core/Records/RecordLOC.cs index 7bdf503..813e7d4 100644 --- a/src/Ubiety.Dns.Core/Records/RecordLOC.cs +++ b/src/Ubiety.Dns.Core/Records/RecordLOC.cs @@ -172,7 +172,7 @@ public override string ToString() private static string ToAlt(uint a) { - var alt = a / 100.0 - 100000.00; + var alt = (a / 100.0) - 100000.00; return string.Format(CultureInfo.InvariantCulture, "{0:0.00}m", alt); } @@ -189,7 +189,10 @@ private static string SizeToString(byte size) var sb = new StringBuilder(); sb.AppendFormat(CultureInfo.InvariantCulture, "{0}", prime); - for (; power > 0; power--) sb.Append('0'); + for (; power > 0; power--) + { + sb.Append('0'); + } sb.Append(unit); return sb.ToString(); @@ -211,9 +214,9 @@ private static string ToTime(uint r, char below, char above) } var h = r / (360000.0 * 10.0); - var m = 60.0 * (h - (int) h); - var s = 60.0 * (m - (int) m); - return string.Format(CultureInfo.InvariantCulture, "{0} {1} {2:0.000} {3}", (int) h, (int) m, s, dir); + var m = 60.0 * (h - (int)h); + var s = 60.0 * (m - (int)m); + return string.Format(CultureInfo.InvariantCulture, "{0} {1} {2:0.000} {3}", (int)h, (int)m, s, dir); } } } \ No newline at end of file diff --git a/src/Ubiety.Dns.Core/Records/RecordNAPTR.cs b/src/Ubiety.Dns.Core/Records/RecordNAPTR.cs index 12785a8..605fd92 100644 --- a/src/Ubiety.Dns.Core/Records/RecordNAPTR.cs +++ b/src/Ubiety.Dns.Core/Records/RecordNAPTR.cs @@ -1,5 +1,3 @@ - - /* * http://www.faqs.org/rfcs/rfc2915.html * diff --git a/src/Ubiety.Dns.Core/Records/RecordNS.cs b/src/Ubiety.Dns.Core/Records/RecordNS.cs index 8af1d33..d2269dd 100644 --- a/src/Ubiety.Dns.Core/Records/RecordNS.cs +++ b/src/Ubiety.Dns.Core/Records/RecordNS.cs @@ -1,5 +1,3 @@ - - /* 3.3.11. NS RDATA format diff --git a/src/Ubiety.Dns.Core/Records/RecordNSAP.cs b/src/Ubiety.Dns.Core/Records/RecordNSAP.cs index 43ba5c8..0bb0a6d 100644 --- a/src/Ubiety.Dns.Core/Records/RecordNSAP.cs +++ b/src/Ubiety.Dns.Core/Records/RecordNSAP.cs @@ -39,7 +39,7 @@ namespace Ubiety.Dns.Core.Records /// public class RecordNsap : Record { - private readonly byte[] address; + private readonly byte[] _address; /// /// Initializes a new instance of the class @@ -48,7 +48,7 @@ public class RecordNsap : Record public RecordNsap(RecordReader rr) { Length = rr.ReadUInt16(); - address = rr.ReadBytes(Length); + _address = rr.ReadBytes(Length); } /// @@ -59,7 +59,7 @@ public RecordNsap(RecordReader rr) /// /// Gets the address as a byte collection /// - public Collection NsapAddress => new Collection(address); + public Collection NsapAddress => new Collection(_address); /// /// String representation of the record data @@ -69,8 +69,10 @@ public override string ToString() { var sb = new StringBuilder(); sb.AppendFormat(CultureInfo.InvariantCulture, "{0} ", Length); - for (var i = 0; i < address.Length; i++) - sb.AppendFormat(CultureInfo.InvariantCulture, "{0:X00}", address[i]); + foreach (var t in _address) + { + sb.AppendFormat(CultureInfo.InvariantCulture, "{0:X00}", t); + } return sb.ToString(); } @@ -84,15 +86,15 @@ public string ToGOSIPV2() return string.Format( CultureInfo.InvariantCulture, "{0:X}.{1:X}.{2:X}.{3:X}.{4:X}.{5:X}.{6:X}{7:X}.{8:X}", - address[0], - (address[1] << 8) | address[2], - address[3], - (address[4] << 16) | (address[5] << 8) | address[6], - (address[7] << 8) | address[8], - (address[9] << 8) | address[10], - (address[11] << 8) | address[12], - (address[13] << 16) | (address[14] << 8) | address[15], - (address[16] << 16) | (address[17] << 8) | address[18]); + _address[0], + (_address[1] << 8) | _address[2], + _address[3], + (_address[4] << 16) | (_address[5] << 8) | _address[6], + (_address[7] << 8) | _address[8], + (_address[9] << 8) | _address[10], + (_address[11] << 8) | _address[12], + (_address[13] << 16) | (_address[14] << 8) | _address[15], + (_address[16] << 16) | (_address[17] << 8) | _address[18]); } } } \ No newline at end of file diff --git a/src/Ubiety.Dns.Core/Records/RecordPTR.cs b/src/Ubiety.Dns.Core/Records/RecordPTR.cs index d441915..7943102 100644 --- a/src/Ubiety.Dns.Core/Records/RecordPTR.cs +++ b/src/Ubiety.Dns.Core/Records/RecordPTR.cs @@ -1,5 +1,3 @@ - - /* 3.3.12. PTR RDATA format diff --git a/src/Ubiety.Dns.Core/Records/RecordPX.cs b/src/Ubiety.Dns.Core/Records/RecordPX.cs index 1e8de1b..5b307aa 100644 --- a/src/Ubiety.Dns.Core/Records/RecordPX.cs +++ b/src/Ubiety.Dns.Core/Records/RecordPX.cs @@ -1,5 +1,3 @@ - - /* * http://tools.ietf.org/rfc/rfc2163.txt * diff --git a/src/Ubiety.Dns.Core/Records/RecordRP.cs b/src/Ubiety.Dns.Core/Records/RecordRP.cs index 8844a9e..1cb6f8d 100644 --- a/src/Ubiety.Dns.Core/Records/RecordRP.cs +++ b/src/Ubiety.Dns.Core/Records/RecordRP.cs @@ -1,5 +1,3 @@ - - /* http://tools.ietf.org/rfc/rfc1183.txt 2.2. The Responsible Person RR diff --git a/src/Ubiety.Dns.Core/Records/RecordRT.cs b/src/Ubiety.Dns.Core/Records/RecordRT.cs index f4559c4..32110ef 100644 --- a/src/Ubiety.Dns.Core/Records/RecordRT.cs +++ b/src/Ubiety.Dns.Core/Records/RecordRT.cs @@ -1,5 +1,3 @@ - - /* http://tools.ietf.org/rfc/rfc1183.txt 3.3. The Route Through RR diff --git a/src/Ubiety.Dns.Core/Records/RecordSOA.cs b/src/Ubiety.Dns.Core/Records/RecordSOA.cs index 80e8fce..c6ce3e4 100644 --- a/src/Ubiety.Dns.Core/Records/RecordSOA.cs +++ b/src/Ubiety.Dns.Core/Records/RecordSOA.cs @@ -1,5 +1,3 @@ - - /* 3.3.13. SOA RDATA format diff --git a/src/Ubiety.Dns.Core/Records/RecordSRV.cs b/src/Ubiety.Dns.Core/Records/RecordSRV.cs index 2082eb7..dda0f2d 100644 --- a/src/Ubiety.Dns.Core/Records/RecordSRV.cs +++ b/src/Ubiety.Dns.Core/Records/RecordSRV.cs @@ -1,5 +1,3 @@ - - /* * http://www.ietf.org/rfc/rfc2782.txt * diff --git a/src/Ubiety.Dns.Core/Records/RecordTKEY.cs b/src/Ubiety.Dns.Core/Records/RecordTKEY.cs index 1042331..fb63c3c 100644 --- a/src/Ubiety.Dns.Core/Records/RecordTKEY.cs +++ b/src/Ubiety.Dns.Core/Records/RecordTKEY.cs @@ -30,8 +30,8 @@ namespace Ubiety.Dns.Core.Records /// public class RecordTkey : Record { - private readonly byte[] keyData; - private readonly byte[] otherData; + private readonly byte[] _keyData; + private readonly byte[] _otherData; /// /// Initializes a new instance of the class @@ -45,9 +45,9 @@ public RecordTkey(RecordReader rr) Mode = rr.ReadUInt16(); Error = rr.ReadUInt16(); KeySize = rr.ReadUInt16(); - keyData = rr.ReadBytes(KeySize); + _keyData = rr.ReadBytes(KeySize); OtherSize = rr.ReadUInt16(); - otherData = rr.ReadBytes(OtherSize); + _otherData = rr.ReadBytes(OtherSize); } /// @@ -83,7 +83,7 @@ public RecordTkey(RecordReader rr) /// /// Gets the key data /// - public List KeyData => new List(keyData); + public List KeyData => new List(_keyData); /// /// Gets the other size from the record (Future use) @@ -93,7 +93,7 @@ public RecordTkey(RecordReader rr) /// /// Gets the other data from the record (Future use) /// - public List OtherData => new List(otherData); + public List OtherData => new List(_otherData); /// /// String representation of the record data diff --git a/src/Ubiety.Dns.Core/Records/RecordTSIG.cs b/src/Ubiety.Dns.Core/Records/RecordTSIG.cs index bf7f886..b2f9011 100644 --- a/src/Ubiety.Dns.Core/Records/RecordTSIG.cs +++ b/src/Ubiety.Dns.Core/Records/RecordTSIG.cs @@ -30,8 +30,8 @@ namespace Ubiety.Dns.Core.Records /// public class RecordTsig : Record { - private readonly byte[] mac; - private readonly byte[] otherData; + private readonly byte[] _mac; + private readonly byte[] _otherData; /// /// Initializes a new instance of the class @@ -43,11 +43,11 @@ public RecordTsig(RecordReader rr) TimeSigned = (rr.ReadUInt32() << 32) | rr.ReadUInt32(); Fudge = rr.ReadUInt16(); MacSize = rr.ReadUInt16(); - mac = rr.ReadBytes(MacSize); + _mac = rr.ReadBytes(MacSize); OriginalId = rr.ReadUInt16(); Error = rr.ReadUInt16(); OtherLength = rr.ReadUInt16(); - otherData = rr.ReadBytes(OtherLength); + _otherData = rr.ReadBytes(OtherLength); } /// @@ -73,7 +73,7 @@ public RecordTsig(RecordReader rr) /// /// Gets the MAC /// - public List Mac => new List(mac); + public List Mac => new List(_mac); /// /// Gets or sets the original id @@ -93,7 +93,7 @@ public RecordTsig(RecordReader rr) /// /// Gets the other record data /// - public List OtherData => new List(otherData); + public List OtherData => new List(_otherData); /// /// String representation of the record data diff --git a/src/Ubiety.Dns.Core/Records/RecordTXT.cs b/src/Ubiety.Dns.Core/Records/RecordTXT.cs index 4bef39b..03be78d 100644 --- a/src/Ubiety.Dns.Core/Records/RecordTXT.cs +++ b/src/Ubiety.Dns.Core/Records/RecordTXT.cs @@ -1,5 +1,3 @@ - - /* 3.3.14. TXT RDATA format diff --git a/src/Ubiety.Dns.Core/Records/RecordWKS.cs b/src/Ubiety.Dns.Core/Records/RecordWKS.cs index 3f0a55b..fd393b9 100644 --- a/src/Ubiety.Dns.Core/Records/RecordWKS.cs +++ b/src/Ubiety.Dns.Core/Records/RecordWKS.cs @@ -53,7 +53,7 @@ namespace Ubiety.Dns.Core.Records /// public class RecordWks : Record { - private readonly byte[] bitmap; + private readonly byte[] _bitmap; /// /// Initializes a new instance of the class @@ -71,8 +71,8 @@ public RecordWks(RecordReader rr) rr.ReadByte()); Protocol = rr.ReadByte(); length -= 5; - bitmap = new byte[length]; - bitmap = rr.ReadBytes(length); + _bitmap = new byte[length]; + _bitmap = rr.ReadBytes(length); } /// @@ -88,7 +88,7 @@ public RecordWks(RecordReader rr) /// /// Gets the service bitmap /// - public Collection Bitmap => new Collection(bitmap); + public Collection Bitmap => new Collection(_bitmap); /// /// Return a string of the well known service record diff --git a/src/Ubiety.Dns.Core/Records/RecordX25.cs b/src/Ubiety.Dns.Core/Records/RecordX25.cs index 7e8f45e..4a3d195 100644 --- a/src/Ubiety.Dns.Core/Records/RecordX25.cs +++ b/src/Ubiety.Dns.Core/Records/RecordX25.cs @@ -1,5 +1,3 @@ - - /* http://tools.ietf.org/rfc/rfc1183.txt 3.1. The X25 RR diff --git a/src/Ubiety.Dns.Core/Resolver.cs b/src/Ubiety.Dns.Core/Resolver.cs index c53ea8e..8c016a6 100644 --- a/src/Ubiety.Dns.Core/Resolver.cs +++ b/src/Ubiety.Dns.Core/Resolver.cs @@ -55,7 +55,7 @@ public Resolver(IEnumerable dnsServers) /// /// DNS server to use public Resolver(IPEndPoint dnsServer) - : this(new[] {dnsServer}) + : this(new[] { dnsServer }) { } @@ -92,7 +92,7 @@ public Resolver(string serverIpAddress) /// Initializes a new instance of the class /// public Resolver() - : this(GetDnsServers()) + : this(GetSystemDnsServers()) { } @@ -116,7 +116,7 @@ public Resolver() /// /// Gets the default OpenDNS servers /// - public IPEndPoint[] DefaultDnsServers { get; } = + public static List DefaultDnsServers => new List { new IPEndPoint(IPAddress.Parse("208.67.222.222"), DefaultPort), new IPEndPoint(IPAddress.Parse("208.67.220.220"), DefaultPort) @@ -141,7 +141,10 @@ public int Retries set { - if (value >= 1) _retries = value; + if (value >= 1) + { + _retries = value; + } } } @@ -158,9 +161,9 @@ public int Retries /// /// Gets or sets list of DNS servers to use /// - public IPEndPoint[] DnsServers + public List DnsServers { - get => _dnsServers.ToArray(); + get => _dnsServers; set { @@ -218,7 +221,7 @@ public bool UseCache /// Gets a list of default DNS servers used on the Windows machine. /// /// Array of DNS servers - public static IEnumerable GetDnsServers() + public static IEnumerable GetSystemDnsServers() { var list = new List(); @@ -266,6 +269,7 @@ public static string GetArpaFromIp(IPAddress ip) return sb.ToString(); } + case AddressFamily.InterNetworkV6: { var sb = new StringBuilder(); @@ -372,7 +376,7 @@ private Response GetResponse(Request request) return TcpRequest(request).Result; } - var response = new Response {Error = "Unknown TransportType"}; + var response = new Response { Error = "Unknown TransportType" }; return response; } @@ -442,7 +446,10 @@ private void AddToCache(Response response) lock (_responseCache) { - if (_responseCache.ContainsKey(strKey)) _responseCache.Remove(strKey); + if (_responseCache.ContainsKey(strKey)) + { + _responseCache.Remove(strKey); + } _responseCache.Add(strKey, response); } @@ -454,44 +461,47 @@ private Response UdpRequest(Request request) var responseMessage = new byte[512]; for (var intAttempts = 0; intAttempts < _retries; intAttempts++) - for (var intDnsServer = 0; intDnsServer < _dnsServers.Count; intDnsServer++) { - var socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); - socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveTimeout, Timeout); - - try + for (var intDnsServer = 0; intDnsServer < _dnsServers.Count; intDnsServer++) { - socket.SendTo(request.GetData(), _dnsServers[intDnsServer]); - var intReceived = socket.Receive(responseMessage); - var data = new byte[intReceived]; - Array.Copy(responseMessage, data, intReceived); - var response = new Response(_dnsServers[intDnsServer], data); - AddToCache(response); - return response; - } - catch (SocketException) - { - Verbose($";; Connection to nameserver {intDnsServer + 1} failed"); - } - finally - { - _unique++; + var socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); + socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveTimeout, Timeout); - // close the socket - socket.Close(); + try + { + socket.SendTo(request.GetData(), _dnsServers[intDnsServer]); + var intReceived = socket.Receive(responseMessage); + var data = new byte[intReceived]; + Array.Copy(responseMessage, data, intReceived); + var response = new Response(_dnsServers[intDnsServer], data); + AddToCache(response); + return response; + } + catch (SocketException) + { + Verbose($";; Connection to nameserver {intDnsServer + 1} failed"); + } + finally + { + _unique++; + + // close the socket + socket.Close(); + } } } - var responseTimeout = new Response {Error = "Timeout Error"}; + var responseTimeout = new Response { Error = "Timeout Error" }; return responseTimeout; } private async Task TcpRequest(Request request) { for (var intAttempts = 0; intAttempts < _retries; intAttempts++) + { foreach (var server in _dnsServers) { - var client = new TcpClient {ReceiveTimeout = _timeout}; + var client = new TcpClient { ReceiveTimeout = _timeout }; try { @@ -519,8 +529,9 @@ private async Task TcpRequest(Request request) client.Close(); } } + } - var responseTimeout = new Response {Error = "Timeout Error"}; + var responseTimeout = new Response { Error = "Timeout Error" }; return responseTimeout; } diff --git a/src/Ubiety.Dns.Core/ResourceRecord.cs b/src/Ubiety.Dns.Core/ResourceRecord.cs index 5411a3c..10eb21e 100644 --- a/src/Ubiety.Dns.Core/ResourceRecord.cs +++ b/src/Ubiety.Dns.Core/ResourceRecord.cs @@ -128,7 +128,7 @@ public UInt32 Ttl /// String of the resource public override String ToString() { - return $"{Name,-32} {Ttl}\t{Class}\t{Type}\t{Record}"; + return $"{Name, -32} {Ttl}\t{Class}\t{Type}\t{Record}"; } } } \ No newline at end of file diff --git a/src/Ubiety.Dns.Core/Response.cs b/src/Ubiety.Dns.Core/Response.cs index 6f49b8c..15ca2f9 100644 --- a/src/Ubiety.Dns.Core/Response.cs +++ b/src/Ubiety.Dns.Core/Response.cs @@ -49,13 +49,25 @@ public Response(IPEndPoint iPEndPoint, byte[] data) Header = new Header(rr); - for (var i = 0; i < Header.QuestionCount; i++) Questions.Add(new Question(rr)); + for (var i = 0; i < Header.QuestionCount; i++) + { + Questions.Add(new Question(rr)); + } - for (var i = 0; i < Header.AnswerCount; i++) Answers.Add(new AnswerRR(rr)); + for (var i = 0; i < Header.AnswerCount; i++) + { + Answers.Add(new AnswerRR(rr)); + } - for (var i = 0; i < Header.NameserverCount; i++) Authorities.Add(new AuthorityRR(rr)); + for (var i = 0; i < Header.NameserverCount; i++) + { + Authorities.Add(new AuthorityRR(rr)); + } - for (var i = 0; i < Header.AdditionalRecordsCount; i++) Additionals.Add(new AdditionalRR(rr)); + for (var i = 0; i < Header.AdditionalRecordsCount; i++) + { + Additionals.Add(new AdditionalRR(rr)); + } } /// @@ -94,7 +106,7 @@ public Response(IPEndPoint iPEndPoint, byte[] data) public int MessageSize { get; set; } /// - /// Gets or sets the timestamp when cached + /// Gets the timestamp when cached /// public DateTime TimeStamp { get; } @@ -208,7 +220,7 @@ public List RecordCname /// /// Gets a list of AAAA records in the answers /// - public List RecordAAAA + public List RecordAaaa { get { @@ -228,7 +240,7 @@ public List RecordAAAA /// /// Gets a list of NS records in the answers /// - public List RecordNS + public List RecordNs { get { @@ -248,7 +260,7 @@ public List RecordNS /// /// Gets a list of SOA records in the answers /// - public List RecordSOA + public List RecordSoa { get { @@ -268,7 +280,7 @@ public List RecordSOA /// /// Gets a list of CERT records in the answers /// - public List RecordCERT + public List RecordCert { get { @@ -288,7 +300,7 @@ public List RecordCERT /// /// Gets a list of SRV records in the answers /// - public List RecordSRV + public List RecordSrv { get { From bad01fa08feb26f8df48faf59d12373049d231cb Mon Sep 17 00:00:00 2001 From: Dieter Lunn Date: Thu, 21 Jun 2018 19:05:50 -0500 Subject: [PATCH 12/15] Added operator documentation --- src/Ubiety.Dns.Core/Records/Mail/RecordMX.cs | 20 ++++++++- src/Ubiety.Dns.Core/Records/RecordKX.cs | 46 +++++++++++--------- 2 files changed, 44 insertions(+), 22 deletions(-) diff --git a/src/Ubiety.Dns.Core/Records/Mail/RecordMX.cs b/src/Ubiety.Dns.Core/Records/Mail/RecordMX.cs index b59fbc8..5e84dc6 100644 --- a/src/Ubiety.Dns.Core/Records/Mail/RecordMX.cs +++ b/src/Ubiety.Dns.Core/Records/Mail/RecordMX.cs @@ -51,44 +51,60 @@ public RecordMx(RecordReader rr) public String Exchange { get; } /// + /// Is the left less than the right /// - /// - /// + /// Left comparison object + /// Right comparison object public static Boolean operator <(RecordMx x, RecordMx y) { return CompareTo(x, y) < 0; } /// + /// Is the left greater than the right /// + /// Left comparison object + /// Right comparison object public static Boolean operator >(RecordMx x, RecordMx y) { return CompareTo(x, y) > 0; } /// + /// Is the left less than or equal to the right /// + /// Lefyt comparison object + /// Right comparison object public static Boolean operator <=(RecordMx x, RecordMx y) { return CompareTo(x, y) <= 0; } /// + /// Is the left greater than or equal to the right /// + /// Left comparison object + /// Right comparison object public static Boolean operator >=(RecordMx x, RecordMx y) { return CompareTo(x, y) >= 0; } /// + /// Are the left and right objects equal /// + /// Left comparison object + /// Right comparison object public static Boolean operator ==(RecordMx x, RecordMx y) { return CompareTo(x, y) == 0; } /// + /// Are the left and right objects not equal /// + /// Left comparison object + /// Right comparison object public static Boolean operator !=(RecordMx x, RecordMx y) { return CompareTo(x, y) != 0; diff --git a/src/Ubiety.Dns.Core/Records/RecordKX.cs b/src/Ubiety.Dns.Core/Records/RecordKX.cs index 7d8a7ce..8047b60 100644 --- a/src/Ubiety.Dns.Core/Records/RecordKX.cs +++ b/src/Ubiety.Dns.Core/Records/RecordKX.cs @@ -61,55 +61,61 @@ public RecordKx(RecordReader rr) public String Exchanger { get; } /// + /// Is the left less than the right /// - /// - /// - public static bool operator <(RecordKx x, RecordKx y) + /// Left comparison object + /// Right comparison object + public static Boolean operator <(RecordKx x, RecordKx y) { return CompareTo(x, y) < 0; } /// + /// Is the left greater than the right /// - /// - /// - public static bool operator >(RecordKx x, RecordKx y) + /// Left comparison object + /// Right comparison object + public static Boolean operator >(RecordKx x, RecordKx y) { return CompareTo(x, y) > 0; } /// + /// Is the left less than or equal to the right /// - /// - /// - public static bool operator <=(RecordKx x, RecordKx y) + /// Left comparison object + /// Right comparison object + public static Boolean operator <=(RecordKx x, RecordKx y) { return CompareTo(x, y) <= 0; } /// + /// Is the left greater than or equal to the right /// - /// - /// - public static bool operator >=(RecordKx x, RecordKx y) + /// Left comparison object + /// Right comparison object + public static Boolean operator >=(RecordKx x, RecordKx y) { return CompareTo(x, y) >= 0; } /// + /// Do the objects equal each other /// - /// - /// - public static bool operator ==(RecordKx x, RecordKx y) + /// Left comparison object + /// Right comparison object + public static Boolean operator ==(RecordKx x, RecordKx y) { return CompareTo(x, y) == 0; } /// + /// Do the objects not equal each other /// - /// - /// - public static bool operator !=(RecordKx x, RecordKx y) + /// Left comparison object + /// Right comparison object + public static Boolean operator !=(RecordKx x, RecordKx y) { return CompareTo(x, y) != 0; } @@ -184,7 +190,7 @@ public override Int32 GetHashCode() } } - private static int CompareTo(RecordKx x, RecordKx y) + private static Int32 CompareTo(RecordKx x, RecordKx y) { if (y == null) { @@ -201,7 +207,7 @@ private static int CompareTo(RecordKx x, RecordKx y) return -1; } - return string.Compare(x.Exchanger, y.Exchanger, true, CultureInfo.InvariantCulture); + return String.Compare(x.Exchanger, y.Exchanger, true, CultureInfo.InvariantCulture); } } } \ No newline at end of file From 248d352eda6f3db728cb0428f1ef519f4d5067e2 Mon Sep 17 00:00:00 2001 From: Dieter Lunn Date: Thu, 21 Jun 2018 19:25:19 -0500 Subject: [PATCH 13/15] Add sample console project --- Ubiety.Dns.Core.sln | 17 ++++++++++++- src/Dns.Sample/Dns.Sample.csproj | 9 +++++++ src/Dns.Sample/DnsTest.cs | 42 ++++++++++++++++++++++++++++++++ src/Dns.Sample/Program.cs | 18 ++++++++++++++ 4 files changed, 85 insertions(+), 1 deletion(-) create mode 100644 src/Dns.Sample/Dns.Sample.csproj create mode 100644 src/Dns.Sample/DnsTest.cs create mode 100644 src/Dns.Sample/Program.cs diff --git a/Ubiety.Dns.Core.sln b/Ubiety.Dns.Core.sln index 6ee8ec5..5ececf2 100644 --- a/Ubiety.Dns.Core.sln +++ b/Ubiety.Dns.Core.sln @@ -1,4 +1,4 @@ - + Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 VisualStudioVersion = 15.0.26124.0 @@ -11,6 +11,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{B521661C-0 EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ubiety.Dns.Test", "test\Ubiety.Dns.Test\Ubiety.Dns.Test.csproj", "{9655F729-1254-4EC0-8676-0392E9C61DDF}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dns.Sample", "src\Dns.Sample\Dns.Sample.csproj", "{9FA05314-88A6-440F-92BA-EAD97FFD9A5D}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -48,9 +50,22 @@ Global {9655F729-1254-4EC0-8676-0392E9C61DDF}.Release|x64.Build.0 = Release|x64 {9655F729-1254-4EC0-8676-0392E9C61DDF}.Release|x86.ActiveCfg = Release|x86 {9655F729-1254-4EC0-8676-0392E9C61DDF}.Release|x86.Build.0 = Release|x86 + {9FA05314-88A6-440F-92BA-EAD97FFD9A5D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9FA05314-88A6-440F-92BA-EAD97FFD9A5D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9FA05314-88A6-440F-92BA-EAD97FFD9A5D}.Debug|x64.ActiveCfg = Debug|Any CPU + {9FA05314-88A6-440F-92BA-EAD97FFD9A5D}.Debug|x64.Build.0 = Debug|Any CPU + {9FA05314-88A6-440F-92BA-EAD97FFD9A5D}.Debug|x86.ActiveCfg = Debug|Any CPU + {9FA05314-88A6-440F-92BA-EAD97FFD9A5D}.Debug|x86.Build.0 = Debug|Any CPU + {9FA05314-88A6-440F-92BA-EAD97FFD9A5D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9FA05314-88A6-440F-92BA-EAD97FFD9A5D}.Release|Any CPU.Build.0 = Release|Any CPU + {9FA05314-88A6-440F-92BA-EAD97FFD9A5D}.Release|x64.ActiveCfg = Release|Any CPU + {9FA05314-88A6-440F-92BA-EAD97FFD9A5D}.Release|x64.Build.0 = Release|Any CPU + {9FA05314-88A6-440F-92BA-EAD97FFD9A5D}.Release|x86.ActiveCfg = Release|Any CPU + {9FA05314-88A6-440F-92BA-EAD97FFD9A5D}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(NestedProjects) = preSolution {6ED5CB16-4917-4E99-9AA1-1349C51D15A6} = {3D43F0BD-7EE6-4713-8814-F5B295DE197A} {9655F729-1254-4EC0-8676-0392E9C61DDF} = {B521661C-0E81-4B32-9010-9408F5142A09} + {9FA05314-88A6-440F-92BA-EAD97FFD9A5D} = {3D43F0BD-7EE6-4713-8814-F5B295DE197A} EndGlobalSection EndGlobal diff --git a/src/Dns.Sample/Dns.Sample.csproj b/src/Dns.Sample/Dns.Sample.csproj new file mode 100644 index 0000000..5ccc21b --- /dev/null +++ b/src/Dns.Sample/Dns.Sample.csproj @@ -0,0 +1,9 @@ + + + Exe + netcoreapp2.1 + + + + + \ No newline at end of file diff --git a/src/Dns.Sample/DnsTest.cs b/src/Dns.Sample/DnsTest.cs new file mode 100644 index 0000000..659f889 --- /dev/null +++ b/src/Dns.Sample/DnsTest.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using Ubiety.Dns.Core; +using Ubiety.Dns.Core.Common; + +namespace Dns.Sample +{ + public class DnsTest + { + private readonly Resolver _resolver; + + public DnsTest() + { + _resolver = new Resolver() + { + Recursion = true, + UseCache = true, + Timeout = 1000, + Retries = 3, + TransportType = TransportType.Tcp, + DnsServer = "8.8.8.8" + }; + } + + public IList CertRecords(string name) + { + IList records = new List(); + + const QuestionType questionType = QuestionType.CERT; + const QuestionClass questionClass = QuestionClass.IN; + + var response = _resolver.Query(name, questionType, questionClass); + + foreach (var record in response.RecordCert) + { + records.Add(record.ToString()); + } + + return records; + } + } +} \ No newline at end of file diff --git a/src/Dns.Sample/Program.cs b/src/Dns.Sample/Program.cs new file mode 100644 index 0000000..e4d87ca --- /dev/null +++ b/src/Dns.Sample/Program.cs @@ -0,0 +1,18 @@ +using System; + +namespace Dns.Sample +{ + internal static class Program + { + private static void Main(string[] args) + { + var test = new DnsTest(); + + Console.WriteLine("CERT records for: direct.sitenv.org"); + foreach (var record in test.CertRecords("direct.sitenv.org")) + { + Console.WriteLine(record); + } + } + } +} \ No newline at end of file From 73ce25f93204ee908f7fc097fbfd0fa446141a34 Mon Sep 17 00:00:00 2001 From: Dieter Lunn Date: Thu, 21 Jun 2018 19:36:12 -0500 Subject: [PATCH 14/15] Set sample project as not packable --- src/Dns.Sample/Dns.Sample.csproj | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Dns.Sample/Dns.Sample.csproj b/src/Dns.Sample/Dns.Sample.csproj index 5ccc21b..880401f 100644 --- a/src/Dns.Sample/Dns.Sample.csproj +++ b/src/Dns.Sample/Dns.Sample.csproj @@ -2,6 +2,7 @@ Exe netcoreapp2.1 + False From 8d369317adfc822ebfbfcf26b45a12846b77dcc8 Mon Sep 17 00:00:00 2001 From: Dieter Lunn Date: Thu, 21 Jun 2018 23:41:21 -0500 Subject: [PATCH 15/15] Remove unneeded file --- src/Ubiety.Dns.Core/Records/totla.txt | 21 --------------------- src/Ubiety.Dns.Core/Ubiety.Dns.Core.csproj | 13 +++++-------- test/Ubiety.Dns.Test/Ubiety.Dns.Test.csproj | 2 ++ 3 files changed, 7 insertions(+), 29 deletions(-) delete mode 100644 src/Ubiety.Dns.Core/Records/totla.txt diff --git a/src/Ubiety.Dns.Core/Records/totla.txt b/src/Ubiety.Dns.Core/Records/totla.txt deleted file mode 100644 index bc195f3..0000000 --- a/src/Ubiety.Dns.Core/Records/totla.txt +++ /dev/null @@ -1,21 +0,0 @@ -Record.cs -RecordA.cs -RecordAAAA.cs -RecordCNAME.cs -RecordHINFO.cs -RecordMB.cs -RecordMD.cs -RecordMF.cs -RecordMG.cs -RecordMINFO.cs -RecordMR.cs -RecordMX.cs -RecordNS.cs -RecordNULL.cs -RecordPTR.cs -RecordReader.cs -RecordSOA.cs -RecordTXT.cs -RecordUnknown.cs -RecordWKS.cs -totla.txt diff --git a/src/Ubiety.Dns.Core/Ubiety.Dns.Core.csproj b/src/Ubiety.Dns.Core/Ubiety.Dns.Core.csproj index 7caff68..5267e39 100644 --- a/src/Ubiety.Dns.Core/Ubiety.Dns.Core.csproj +++ b/src/Ubiety.Dns.Core/Ubiety.Dns.Core.csproj @@ -1,5 +1,4 @@ - - + netstandard2.0 ../ProjectLevel.ruleset @@ -7,15 +6,13 @@ 2.0.0 479864c2-f29b-40e4-987b-577d189c3d08 - - - + + + - - - + \ No newline at end of file diff --git a/test/Ubiety.Dns.Test/Ubiety.Dns.Test.csproj b/test/Ubiety.Dns.Test/Ubiety.Dns.Test.csproj index e877f01..e345e71 100644 --- a/test/Ubiety.Dns.Test/Ubiety.Dns.Test.csproj +++ b/test/Ubiety.Dns.Test/Ubiety.Dns.Test.csproj @@ -7,8 +7,10 @@ + +