:program:`sdig` sends a DNS query to *IP-ADDRESS-OR-DOH-URL* on port *PORT* and displays the answer in a formatted way.
If the address starts with an ``h``, it is assumed to be a DoH endpoint, and *PORT* is ignored.
If qname and qtype are both `-` and tcp is used, multiple lines are read from stdin, where each line contains a qname and a type.
+If the address is ``stdin``, a DNS packet is read from stdin instead of from the network, and *PORT* is ignored.
Options
-------
bool showflags = false;
bool hidesoadetails = false;
bool doh = false;
+ bool stdin = false;
boost::optional<Netmask> ednsnm;
uint16_t xpfcode = 0, xpfversion = 0, xpfproto = 0;
char *xpfsrc = NULL, *xpfdst = NULL;
ComboAddress dest;
if (*argv[1] == 'h') {
doh = true;
+ } else if(strcmp(argv[1], "stdin") == 0) {
+ stdin = true;
} else {
dest = ComboAddress(argv[1] + (*argv[1] == '@'), atoi(argv[2]));
}
#else
throw PDNSException("please link sdig against libcurl for DoH support");
#endif
+ } else if (stdin) {
+ std::istreambuf_iterator<char> begin(std::cin), end;
+ reply = string(begin, end);
+ printReply(reply, showflags, hidesoadetails);
} else if (tcp) {
Socket sock(dest.sin4.sin_family, SOCK_STREAM);
sock.connect(dest);