4 ms·
I'll dig up my old comment about how easy DNS is to work with using DNS4J: Message query = new Message(data); Header header = query.getHeader(); Record q
by bullen 3y ago
I'll dig up my old comment about how easy DNS is to work with using DNS4J:
Message query = new Message(data);
Header header = query.getHeader();
Record question = query.getQuestion();
Message response = new Message(query.getHeader().getID());
response.getHeader().setFlag(Flags.QR);
response.addRecord(question, Section.QUESTION);
Name name = question.getName();
int type = question.getType();
int dclass = question.getDClass();
String host = name.toString(true).toLowerCase();
...
response.addRecord(new ARecord(name, dclass, 300, "someIP"), Section.ANSWER);
...
response.getHeader().setFlag(Flags.AA);
return response.toWire(512);
- arjvik 3y agoCan't tell if this is sarcasm or not :) On one hand, like all Java code, this is really really verbose. But on the other, it's not that complicated—every line seems like it corresponds to some part of the DNS spec.
- vineyardmike 3y agoIt’s verbose but not complicated. Verboseness doesn’t make something uneasy, it means you tell your IDE to autocomplete.
- deathanatos 3y agoYeah, I'll take a verbose but uncomplicated API any day of the week. Straight-forwardly named classes/functions, no surprising behavior, one concept == one name, and a good reference … that's how stuff gets done. … always better than something that tries to hide things from you and does the wrong thing sometimes.