mirror of https://github.com/Chizi123/dnscomp.git

Joel Grunbaum
2020-10-21 602b64263ac7390c6c3eabf008a092cb5ca37983
Added README and help to program
1 files modified
1 files added
45 ■■■■■ changed files
README.org 32 ●●●●● patch | view | raw | blame | history
main.c 13 ●●●● patch | view | raw | blame | history
README.org
New file
@@ -0,0 +1,32 @@
#+TITLE: DNScomp, a basic DNS benchmark tool
* What is this and why did you make it?
This is a basic DNS bench-marking tool, written to be as portable as possible.
As such I have tried to include only POSIX functions.
It runs the tests in parallel to try and save some time, and has a rudimentary progress meter for signs of life.
It is by no means perfect, but it is mostly functional. Nonetheless, feel free to try and improve it.
As to why I made it, I couldn't find a DNS benchmarking tool.
There were some online, which for obvious reasons are useless for local testing, and the others were fairly old and/or platform specific.
Namebench was in the process of a rewrite and also was written in go.
This is written in C to try and make is as approachable as possible.
It was developed mostly on Linux and Mac, although it has been tested to work on Windows as well.
* Usage
There is a preloaded list of 20 DNS servers and 50 hostnames to try out.
By default, all 50 will be tested.
You can add your own DNS servers with the ~-s~ argument and hosts to check with ~-a~.
If you want to test less hostnames, you can do so by specifying the number to test with ~-t~.
The number of times to test each hostname is defaulted to 10, but can be specified with ~-n~.
Added DNS servers and hosts are the first to be used.
While running, a counter will show a completion percentage, although this may undercount due to the parallel nature of the program.
Additionally progress will slow towards the end as the last servers are left to complete.
Once testing has been completed, a list of DNS servers will be printed out from fastest to slowest, with the average response time next to them.
* Things still to do
- Clean up the code and make it more readable and nicer
- Optimise a little
- Add more hostnames and DNS servers
- Allow piping of hosts and/or servers
main.c
@@ -30,13 +30,13 @@
int main(int argc, char** argv)
{
    int option, added_hosts = 0;
    while((option = getopt(argc, argv, "s:h:t:n:")) != -1) {
    while((option = getopt(argc, argv, "s:a:t:n:h")) != -1) {
        switch (option) {
        case 's': //server to use
            add_dns_server(&servers, optarg);
            num_servers++;
            break;
        case 'h': //hostname to search
        case 'a': //hostname to search
            add_hosts_server(&hosts, optarg);
            added_hosts++;
            break;
@@ -47,8 +47,15 @@
            num_tests = atoi(optarg);
            break;
        case '?':
        case 'h':
        default:
            printf("Error: invalid option -%c\n", optopt);
            printf("Usage: %s [options]\n", argv[0]);
            printf("Options:\n");
            printf("\t-s <server>\tadd a DNS server to be tested\n");
            printf("\t-a <hostname>\tadd a hostname to be tested\n");
            printf("\t-t <number>\tspecify the number of hostnames to be tested, capped at 50 + number manually added\n\t\t\tdefaults to test all available\n");
            printf("\t-n <number>\tspecify the number of tests to perform on each hostname\n\t\t\tdefaults to 10\n");
            printf("\t-h\t\tShow this help\n");
            free_dns_list(&servers);
            free_hosts_list(&hosts);
            exit(1);