#include "dnsrecords.hh"
#include "statbag.hh"
#include <boost/array.hpp>
+#include "ednssubnet.hh"
StatBag S;
int main(int argc, char** argv)
bool tcp=false;
bool showflags=false;
bool hidesoadetails=false;
+ boost::optional<Netmask> ednsnm;
reportAllTypes();
if(argc < 5) {
- cerr<<"Syntax: sdig IP-address port question question-type [dnssec] [recurse] [showflags] [hidesoadetails] [tcp]\n";
+ cerr<<"Syntax: sdig IP-address port question question-type [dnssec] [recurse] [showflags] [hidesoadetails] [tcp] [ednssubnet subnet]\n";
exit(EXIT_FAILURE);
}
showflags=true;
if (strcmp(argv[i], "hidesoadetails") == 0)
hidesoadetails=true;
- if (strcmp(argv[i], "tcp") == 0) {
- tcp=true;
+ if (strcmp(argv[i], "ednssubnet") == 0) {
+ ednsnm=Netmask(argv[++i]);
}
}
}
DNSPacketWriter pw(packet, DNSName(argv[3]), DNSRecordContent::TypeToNumber(argv[4]));
- if(dnssec || getenv("SDIGBUFSIZE"))
+ if(dnssec || ednsnm || getenv("SDIGBUFSIZE"))
{
char *sbuf=getenv("SDIGBUFSIZE");
int bufsize;
bufsize=atoi(sbuf);
else
bufsize=2800;
+ DNSPacketWriter::optvect_t opts;
+ if(ednsnm) {
- pw.addOpt(bufsize, 0, dnssec ? EDNSOpts::DNSSECOK : 0);
+
+ EDNSSubnetOpts eo;
+ eo.source = *ednsnm;
+ opts.push_back(make_pair(8, makeEDNSSubnetOptsString(eo)));
+ }
+
+ pw.addOpt(bufsize, 0, dnssec ? EDNSOpts::DNSSECOK : 0, opts);
pw.commit();
}
{
pw.getHeader()->rd=true;
}
- // pw.setRD(true);
-
- /*
- pw.startRecord("powerdns.com", DNSRecordContent::TypeToNumber("NS"));
- NSRecordContent nrc("ns1.powerdns.com");
- nrc.toPacket(pw);
-
- pw.startRecord("powerdns.com", DNSRecordContent::TypeToNumber("NS"));
- NSRecordContent nrc2("ns2.powerdns.com");
- nrc2.toPacket(pw);
- */
-
-/* DNSPacketWriter::optvect_t opts;
- opts.push_back(make_pair(5, ping));
-
- pw.commit();
-*/
- // pw.addOpt(5200, 0, 0);
- // pw.commit();
-
string reply;
ComboAddress dest(argv[1] + (*argv[1]=='@'), atoi(argv[2]));
}
MOADNSParser mdp(reply);
cout<<"Reply to question for qname='"<<mdp.d_qname.toString()<<"', qtype="<<DNSRecordContent::NumberToType(mdp.d_qtype)<<endl;
- cout<<"Rcode: "<<mdp.d_header.rcode<<", RD: "<<mdp.d_header.rd<<", QR: "<<mdp.d_header.qr;
+ cout<<"Rcode: "<<mdp.d_header.rcode<<" ("<<RCode::to_s(mdp.d_header.rcode)<<"), RD: "<<mdp.d_header.rd<<", QR: "<<mdp.d_header.qr;
cout<<", TC: "<<mdp.d_header.tc<<", AA: "<<mdp.d_header.aa<<", opcode: "<<mdp.d_header.opcode<<endl;
for(MOADNSParser::answers_t::const_iterator i=mdp.d_answers.begin(); i!=mdp.d_answers.end(); ++i) {
//if(iter->second == ping)
// cerr<<"It is correct!"<<endl;
}
+ if(iter->first == 8) {// 'EDNS subnet'
+ EDNSSubnetOpts reso;
+ if(getEDNSSubnetOptsFromString(iter->second, &reso)) {
+ cerr<<"EDNS Subnet response: "<<reso.source.toString()<<", scope: "<<reso.scope.toString()<<", family = "<<reso.scope.getNetwork().sin4.sin_family<<endl;
+ }
+ }
+
else {
cerr<<"Have unknown option "<<(int)iter->first<<endl;
}