[HN Gopher] A DNS resolver in 80 lines of Go ___________________________________________________________________ A DNS resolver in 80 lines of Go Author : 0xedb Score : 47 points Date : 2022-02-01 21:11 UTC (1 hours ago) (HTM) web link (jvns.ca) (TXT) w3m dump (jvns.ca) | NoWayDude1 wrote: | One can do even better. How about a DNS resolver in 1 line of | bash code: | | /lib/systemd/systemd-resolved | | Using miekg/dns to write a DNS resolver in "80 lines" is like | microwaving pizza and then saying "I made a pizza in just 5 | minutes in one easy step". | taeric wrote: | More than a little unfair when the following is in the article: | I'm not going to write this completely from scratch - | I think parsing DNS packets is really interesting, but | it's definitely more than 80 lines of code, and I find | that it kind of distracts from the algorithm. | | Which, seems legit to me. This article was a fun read to | refresh on exactly what goes on in resolving basic records. | dixie_land wrote: | I agree it's a fun article but you can't deny the title is at | the very least clickbait-ish | silisili wrote: | I normally don't like comments like this but I think in this | case your point stands. DNS is not 'easy' in that you have | troves of RFCs and undocumented but expected behaviors to | follow, etc. miekg/dns does all of the heavy lifting here. | | Writing a resolver in it is a fun project, but bragging about | the line count is silly. | chomp wrote: | I smiled at this, though the Sagan quote "If you wish to make | an apple pie from scratch, you must first invent the universe" | springs to mind. At some point to be reasonable you have to cut | off the lower layers of abstraction or else it's madness. | | Unbound leans on libresolv, so I don't think it's cheating to | lean on external libraries - most of the hard part about | resolvers is all the crufty RFCs you have to support anyway, | not the basic nuts and bolts of resolving an A record. ___________________________________________________________________ (page generated 2022-02-01 23:00 UTC)