-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
String() wrappers for DNS class and type values #43
Comments
[ Quoting notifications@github.com in "[dns] String() wrappers for DNS cla..." ]
I understand your use case, but how often is this needed? The reason I hesitant to add, just because it's so easy to write yourself, unless grtz Miek |
hi, miek: yes, i know i can do it myself, but i don't want to :) i can say that i write code that converts to and from "presentation format" fairly often and it would be very useful to be able to treat integer RRTypes and strings representing RRTypes without having to worry about whether they are defined or not. having the bare maps feels very "raw". would you be willing to accept a pull request with this functionality (+ full tests, of course)? also, it would probably be nice to have wrappers in the other direction, e.g. convert "aaaa" or "AAAA" or "TYPE28" to uint16(28). i know that RFC 3597 strictly speaking applies only to DNS server software, but i think having this kind of functionality in "the go dns package" would make it more likely that "idiomatic" code gets written that can handle unknown RRTypes correctly, even when written by people who have never heard of RFC 3597 :) |
[ Quoting notifications@github.com in "Re: [dns] String() wrappers for DNS..." ]
Hehe :-) Well I'm sympathetic with your needs, but I always want to keep
Still hesitant. I think (maybe) some new helper function, without a new
Ack, above StringToType you mean?
Note that "www.example.com. IN TYPE1 #4 0a000001", currently is not grtz Miek |
i know about keeping APIs small :) http://rsfcode.isc.org/git/wdns/tree/wdns/wdns.h has served me well for a number of years, but i'm interested in writing more go code. i've only been writing go code for a short while, but i don't think a plain helper function is right. having a type that implements the Stringer interface would be very nice. e.g., i went looking for the go equivalent of inet_ntop() and couldn't find it until i realized that net.IP was a type alias for byte[], so i just had to write:
it would be quite nice to similarly write:
which conceptually seems a bit better than calling a helper function. are you sure switching from bare uint16's to RRType/RRClass type aliases would be that bad? i guess it might be a big diff and probably breaks the API, but i know i have occasionally written buggy code that went undetected (for a very brief while, admittedly) due to CLASS IN / TYPE A having the same uint16 value. wouldn't having dedicated type aliases make it a compile time error to ever use an RRType value where an RRClass value was expected or vice versa? |
[ Quoting notifications@github.com in "Re: [dns] String() wrappers for DNS..." ]
That is indeed a small api ;-)
yes and yes, but you are the first with this specific requirement, hence
breaking the api just for this seems a bit much atm. I agree this is a To turn the thing around: is it an idea to maintain this a go dns++
|
Miek Gieben wrote:
ok, maybe there are people who don't realize they need this, though. if
this works ok and prints "the type is A". but there is a subtle bug,
this will just print out "the type is". so you almost always need to
do you log an error and exit, or what? maybe you get lucky and copy an
yeah, better to queue up all the API breaking changes :)
i guess i might fork miekg/dns and put this on a branch so it can be Robert Edmonds |
[ Quoting notifications@github.com in "Re: [dns] String() wrappers for DNS..." ]
Sorry to quote this from the README:
So "// XXX: what to do here?" should already be answered in the
That is always possible :-) So to be a bit formal, I'm going to NACK this for now. But I can always grtz Miek |
Miek Gieben wrote:
this is a bit silly. the README says "lean and mean" but also "complete
ahem. i guess you should fix the example code then. :)
Robert Edmonds |
oh, that did not format well. note the RRSIG "Type Covered" field is missing from the formatted output.
|
[ Quoting notifications@github.com in "Re: [dns] String() wrappers for DNS..." ]
Ah, yes. Point taken :-) Let me see where fixing this takes me and what convience function should The new types being aliases of uint16 might be handy enough to make the Note, at the time I started ldns a lot of convience functions got
|
[ Quoting notifications@github.com in "Re: [dns] String() wrappers for DNS..." ]
How a little bit of programming can make you see the light :)
|
it would be nice to have wrappers for the TypeToString and ClassToString maps that return the mnemonic if known, or RFC 3597 compliant generic representations otherwise. something like this:
so that one could simply format integer class and type values with e.g.
instead of the ten or so lines it would take otherwise.
The text was updated successfully, but these errors were encountered: