Skip to content

Commit

Permalink
Merge pull request #51 from EdwinVanVliet/main
Browse files Browse the repository at this point in the history
Fix for reading TXT Records.
  • Loading branch information
coder2000 authored May 18, 2024
2 parents 6c70c2c + 543cee0 commit 9c02d74
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 14 deletions.
8 changes: 1 addition & 7 deletions src/Ubiety.Dns.Core/Common/Extensions/EnumExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,12 @@ public static class EnumExtensions
/// </summary>
/// <param name="type">Type of record to get.</param>
/// <param name="reader">Resource reader to create record with.</param>
/// <param name="length">Length of the record.</param>
/// <returns>A <see cref="Record"/> instance for the given type.</returns>
public static Record GetRecord(this RecordType type, RecordReader reader, int length = 0)
public static Record GetRecord(this RecordType type, RecordReader reader)
{
var fieldInfo = type.GetType().GetField(type.ToString());
var recordAttr = fieldInfo.GetCustomAttribute<RecordAttribute>();

if (type == RecordType.TXT)
{
return (Record)Activator.CreateInstance(recordAttr.RecordType, reader, length);
}

return (Record)Activator.CreateInstance(recordAttr.RecordType, reader);
}
}
Expand Down
11 changes: 4 additions & 7 deletions src/Ubiety.Dns.Core/Records/RecordTxt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,13 @@ public record RecordTxt : Record
/// Initializes a new instance of the <see cref="RecordTxt" /> class.
/// </summary>
/// <param name="reader"><see cref="RecordReader" /> for the record data.</param>
/// <param name="length">Record length.</param>
public RecordTxt(RecordReader reader, int length)
public RecordTxt(RecordReader reader)
: base(reader)
{
var position = Reader.Position;
Text = new List<string>();
while ((Reader.Position - position) < length)
Text = new List<string>
{
Text.Add(Reader.ReadString());
}
Reader.ReadString()
};
}

/// <summary>
Expand Down

0 comments on commit 9c02d74

Please sign in to comment.