A tiny DNS library in C
- C 100%
| examples | ||
| .gitignore | ||
| LICENSE | ||
| README.md | ||
| resolv.c | ||
| resolv.h | ||
tinycdns
A tiny DNS library in C
features
1- can resolve IPV4 domains 2- can resolve TXT records 3- is fully POSIX compliant (Works on MacOS, all the BSD variants, Linux, GNU based systems following the POSIX standard) 4- can bypass OS level DNS restrictions (modifying Hosts file, blocking domains being resolved, etc)
examples
examples can be found in the examples folder
C code example
#include <stdio.h>
#include "resolv.h" // HEADER file of the DNS library
int main(int argc, char *argv[]) {
if (argc < 2) {
printf("Usage: %s <hostname>\n", argv[0]);
return 1;
}
const char *host = argv[1];
char *ip = resolve_ipv4(host);
if (ip) {
printf("IPv4 for %s: %s\n", host, ip);
} else {
printf("Could not resolve IPv4 for %s\n", host);
}
return 0;
}
possible environments to use in
- minimal environments without a traditional DNS resolver
- places where you dont want to use the default operating system's DNS resolver
- to use in IoT projects
where to NOT use (otherwise its a bad idea)
- when you're developing for non-POSIX or Windows based systems.
- when you expect absolute accuracy and many features, since its quite barebones.