-
-
Notifications
You must be signed in to change notification settings - Fork 132
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expose Value of DnsResourceRecord #36
Comments
Each type has specific properties which are parsed and populated by this library. The |
Hi….I was hoping to provide a tool to my end-users to apply a regex match to the result of a DNS query, and the result of the regex match is used to determine if the Dns is healthy or not. I agree…using “ToString()” should not drive business logic in code, however I need a simple approach from some end-users.
I will probably use a “split” of the ‘\t’ character to get the last part of the “pretty” printed record instead of interpreting all the different derived types, since I would have to modify my code if more types are added.
Thanks.
From: MichaC <notifications@github.com>
Sent: Tuesday, 23 October 2018 9:13 PM
To: MichaCo/DnsClient.NET <DnsClient.NET@noreply.github.com>
Cc: Garry Thomas <gthomas@gemmb.com>; Author <author@noreply.github.com>
Subject: Re: [MichaCo/DnsClient.NET] Expose Value of DnsResourceRecord (#36)
Each type has specific properties which are parsed and populated by this library.
You're supposed to use those instead of parsing a string or binary data yourself.
Depending on the method, yes, you might have to type check the result. There are a couple of helper methods doing that for you though. result.Answers.ARecords() returns all A records from the query result...
The RecordToString is used internally for "pretty" printing the record. There is no point exposing that method.
ToString should also never be used within business logic to determine the value of an object (that's true in general).
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub<#36 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/AkGqar02NFSUubEg0o0IDVEwLGDxOQ49ks5unuvDgaJpZM4X0pk4>.
|
Well, the returned value of That's up to you to decide what to use ofc, just saying ;) |
Would you be open to adding an overload of ToString()? Similar to your current overload which influences the output of ToString(). Something like ToString(bool valueOnly) perhaps?
I hear what you say about using type safe, however, on this occasion I have to “force” everything to go via a string to give a Regex capability. So any code I add on to convert each types “value” to a string is effectively just “undoing” all the good work your code is doing to keep it type safe. I’m not a fan of Regex, but it can be a flexible handover from my code to the administrators of my code.
From: MichaC <notifications@github.com>
Sent: Tuesday, 23 October 2018 11:16 PM
To: MichaCo/DnsClient.NET <DnsClient.NET@noreply.github.com>
Cc: Garry Thomas <gthomas@gemmb.com>; Author <author@noreply.github.com>
Subject: Re: [MichaCo/DnsClient.NET] Expose Value of DnsResourceRecord (#36)
Well, the returned value of ToString might also change in future version. There is no type safe guarantee that the returned value will be the same format or order of values.
That's up to you to decide what to use ofc, just saying ;)
Using type safe properties of the actual records is usually the way to go ;)
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub<#36 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/AkGqaktPQikFcnEuxpTGosSkNmt8Dtheks5unwiEgaJpZM4X0pk4>.
|
I don't really get what you mean with value only. Most resource records have many different fields (not just one value). Others have lists of strings or binary data, enum values etc... |
Well…what I’m attempting to do is provide a facility for the administrators of my software to configure a simple “health check” of the DNS servers they have in their infrastructure. The administrator will decide what type of query is required (like A, AAAA, CNAME etc), and the query itself, like hostname.domain.com. They will then have an option to say the DNS is healthy if:
1. There is any response
2. There is a response with a value that matches a criteria that they set.
The regex fits into option 2. The administrators often use regex in their day-to-day work, so they understand it. I could see that you already saw some benefit in having a “ToString” capability in your code, and all the hard work has been done to get a “string” representation of the DnsResource, so I immediately saw a direct fit for my requirements.
This scenario is my limit for using regex (ie…a match/no match scenario), as I agree anything more than that gets very ugly. If I were to consume the “values” deeper into my code, I would without question use the type safe properties.
From: MichaC <notifications@github.com>
Sent: Wednesday, 24 October 2018 9:07 AM
To: MichaCo/DnsClient.NET <DnsClient.NET@noreply.github.com>
Cc: Garry Thomas <gthomas@gemmb.com>; Author <author@noreply.github.com>
Subject: Re: [MichaCo/DnsClient.NET] Expose Value of DnsResourceRecord (#36)
I don't really get what you mean with value only. Most resource records have many different fields (not just one value). Others have lists of strings or binary data, enum values etc...
I also don't really get what you are doing with regex over dns values to be honest... maybe you can post an example for your use case. But so far, all that sounds pretty horrible to me ;)
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub<#36 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/AkGqavWWaNykvGOQTPQu6dnhLBvh3VoZks5un5LqgaJpZM4X0pk4>.
|
Ok, I kind of get it. I might make that method public/rename it slightly. But that might take a while till it gets published On the other hand, I would write a small switch statement which uses the configured query type and then, with A and AAAA you can cast the answers to |
I’ve taken the “switch” approach in other areas of my code where I access the typed properties, which is really good. I appreciate you reconsidering my request…I didn’t want to “mirror” your internal code to get the string version of the value, and most likely get it wrong ;)
From: MichaC <notifications@github.com>
Sent: Wednesday, 24 October 2018 10:31 PM
To: MichaCo/DnsClient.NET <DnsClient.NET@noreply.github.com>
Cc: Garry Thomas <gthomas@gemmb.com>; Author <author@noreply.github.com>
Subject: Re: [MichaCo/DnsClient.NET] Expose Value of DnsResourceRecord (#36)
Ok, I kind of get it. I might make that method public/rename it slightly. But that might take a while till it gets published
On the other hand, I would write a small switch statement which uses the configured query type and then, with A and AAAA you can cast the answers to AddressRecords and then use the IPAddress property. etc...
That's not really a lot of code and much much safer anyways, too ;)
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub<#36 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/AkGqavHSu9s1Qkmx3vWgxrMPetAAUP-zks5uoE9jgaJpZM4X0pk4>.
|
I can't work out how to get the string "Value" of the DnsResourceRecord without having to either split the output of "ToString()" on the tab characters, or to test the DnsResourceRecords type and access a type specific "value" property.
There is a private protected abstract RecordToString() method that each deriving DnsResourceRecord type implements appropriately, Would it be possible to expose the result of this method as either a property or method?
The text was updated successfully, but these errors were encountered: