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

Joel Grunbaum
2020-10-21 d3f3ee16d8adaef681afed67f236e3bb14e7cdc0
change artifact name and added penalty for failed connections
4 files modified
26 ■■■■■ changed files
.gitignore 1 ●●●● patch | view | raw | blame | history
Makefile 4 ●●●● patch | view | raw | blame | history
main.c 20 ●●●● patch | view | raw | blame | history
slist.c 1 ●●●● patch | view | raw | blame | history
.gitignore
@@ -1,3 +1,4 @@
*.o
*.out
*~
dnscomp
Makefile
@@ -9,12 +9,12 @@
DEPS = $(patsubst %,$(IDIR)/%,$(_DEPS))
OBJ = $(patsubst %,$(ODIR)/%,$(_OBJ))
default: a.out
default: dnscomp
%.o: %c $(DEPS)
    $(CC) $(CFLAGS) -c -o $@ $<
a.out: $(_OBJ)
dnscomp: $(_OBJ)
    $(CC) $(CFLAGS) -o $@ $^
.PHONY: clean
main.c
@@ -16,19 +16,6 @@
#define NUM_TESTS 10
/* struct test_server_input { */
/*  int dns; */
/*  //struct hosts_list *hosts; */
/*  int num_hosts; */
/*  int num_tests; */
/* }; */
/* struct progress_input { */
/*  int num_hosts; */
/*  int num_tests; */
/*  int num_servers; */
/* }; */
int test_dns(void);
void *test_server(void *in);
void *print_progress(void *in);
@@ -117,10 +104,13 @@
        struct hosts_list *curr = hosts;
        while (curr) {
            struct timespec run;
            run.tv_sec = -1; run.tv_nsec = 0;
            unsigned char buf[65536];
            for (int i = 0; i < 3 && run.tv_sec == -1; i++) {
            run = resolve(buf, curr->server, dns->server, T_A);
            if (run.tv_sec == -1) //currently ignore failed tests, need to figure out what to do with them
                continue;
            }
            if (run.tv_sec == -1) //if test has failed 3 times, set time taken to 3s as penalty
                run.tv_sec = 3;
            dns->time.tv_sec += run.tv_sec;
            dns->time.tv_nsec += run.tv_nsec;
            if (dns->time.tv_nsec >= 1000000000) { //nanoseconds have overflowed into seconds
slist.c
@@ -99,7 +99,6 @@
struct dns_list *merge(struct dns_list *a, struct dns_list *b)
{
    struct dns_list *out = NULL;
    int comp;
    if (!a)
        return b;
    if (!b)