Skip to content

Sample: TxtRecord #76

Closed
Closed

Description

@glararan

I wonder how to read key/value from TxtRecord.

I have following code

IDnsQueryResponse response = await dnsClient.QueryAsync(domainInfo.Hostname, QueryType.TXT);

IEnumerable<DnsClient.Protocol.TxtRecord> records = response.Answers.TxtRecords();

However TxtRecord has only available properties: Text which is ICollection<string>. I suppose its value field splitted by ; or whitespace?

How I am suppose to retreive key?
e.g.:
image
Key: google.com
Value: docusign=05958488-4752-4ef2-95eb-aa7ba8a3bd0e

Thanks

Activity

  1. MichaConrad commented on Jun 14, 2020

    @MichaConrad
    Collaborator

    There is a collection of strings because a TXT resource record can be used to store multiple values.
    If quotes are used, the whole value within the quotes is treated as one value (and will produce only one element in the collection); e.g. "some text with spaces".
    The same value without quotes would be 4 different values and would create a list of 4 strings.

    In your example, all values are in quotes so the full text will be in the first element of the collection I guess.

    Different systems then use different mechanisms to separate key/values. You'll have to parse the string yourself if you want to analyse any of the data.

  2. locked and limited conversation to collaborators on Jun 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions