X-Git-Url: https://git.exim.org/users/heiko/exim.git/blobdiff_plain/589b317958399c195bd143ecf408afb8dc91bb3b..a818f67959c0f6dd23ca37280d5c4f9b9ee07125:/test/src/fakens.c diff --git a/test/src/fakens.c b/test/src/fakens.c index be3a148b8..aff5f40f6 100644 --- a/test/src/fakens.c +++ b/test/src/fakens.c @@ -51,14 +51,14 @@ and the domain is not found. It converts the the result to PASS_ON instead of HOST_NOT_FOUND. Any DNS record line in a zone file can be prefixed with "DELAY=" and -a number of milliseconds (followed by whitespace). +a number of milliseconds (followed by one space). -Any DNS record line in a zone file can be prefixed with "DNSSEC" and -at least one space; if all the records found by a lookup are marked +Any DNS record line in a zone file can be prefixed with "DNSSEC "; +if all the records found by a lookup are marked as such then the response will have the "AD" bit set. -Any DNS record line in a zone file can be prefixed with "AA" and -at least one space; if all the records found by a lookup are marked +Any DNS record line in a zone file can be prefixed with "AA " +if all the records found by a lookup are marked as such then the response will have the "AA" bit set. */ @@ -378,13 +378,13 @@ while (fgets(CS buffer, sizeof(buffer), f) != NULL) else if (Ustrncmp(p, US"DELAY=", 6) == 0) /* delay before response */ { for (p += 6; *p >= '0' && *p <= '9'; p++) delay = delay*10 + *p - '0'; - while (isspace(*p)) p++; + if (isspace(*p)) p++; } else break; } - if (!isspace(*p)) + if (!isspace(*p)) /* new domain name */ { uschar *pp = rrdomain; uschar *PP = RRdomain; @@ -403,7 +403,7 @@ while (fgets(CS buffer, sizeof(buffer), f) != NULL) pp[-1] = 0; PP[-1] = 0; } - } + } /* else use previous line's domain name */ /* Compare domain names; first check for a wildcard */ @@ -583,6 +583,55 @@ alarmfn(int sig) { } + +/************************************************* +* Special-purpose domains * +*************************************************/ + +static int +special_manyhome(uschar * packet, uschar * domain) +{ +uschar *pk = packet + 12; +uschar *rdlptr; +int i, j; + +memset(packet, 0, 12); + +for (i = 104; i <= 111; i++) for (j = 0; j <= 255; j++) + { + pk = packname(domain, pk); + *pk++ = (ns_t_a >> 8) & 255; + *pk++ = (ns_t_a) & 255; + *pk++ = 0; + *pk++ = 1; /* class = IN */ + pk += 4; /* TTL field; don't care */ + rdlptr = pk; /* remember rdlength field */ + pk += 2; + + *pk++ = 10; *pk++ = 250; *pk++ = i; *pk++ = j; + + rdlptr[0] = ((pk - rdlptr - 2) >> 8) & 255; + rdlptr[1] = (pk - rdlptr - 2) & 255; + } + +packet[6] = (2048 >> 8) & 255; +packet[7] = 2048 & 255; +packet[10] = 0; +packet[11] = 0; + +(void)fwrite(packet, 1, pk - packet, stdout); +return 0; +} + +static int +special_again(uschar * packet, uschar * domain) +{ +int delay = atoi(CCS domain); /* digits at the start of the name */ +if (delay > 0) sleep(delay); +return TRY_AGAIN; +} + + /************************************************* * Entry point and main program * *************************************************/ @@ -666,38 +715,11 @@ domain[domlen] = 0; for (i = 0; i < domlen; i++) domain[i] = tolower(domain[i]); if (Ustrcmp(domain, "manyhome.test.ex") == 0 && Ustrcmp(qtype, "A") == 0) - { - uschar *pk = packet + 12; - uschar *rdlptr; - int i, j; - - memset(packet, 0, 12); - - for (i = 104; i <= 111; i++) for (j = 0; j <= 255; j++) - { - pk = packname(domain, pk); - *pk++ = (ns_t_a >> 8) & 255; - *pk++ = (ns_t_a) & 255; - *pk++ = 0; - *pk++ = 1; /* class = IN */ - pk += 4; /* TTL field; don't care */ - rdlptr = pk; /* remember rdlength field */ - pk += 2; - - *pk++ = 10; *pk++ = 250; *pk++ = i; *pk++ = j; - - rdlptr[0] = ((pk - rdlptr - 2) >> 8) & 255; - rdlptr[1] = (pk - rdlptr - 2) & 255; - } - - packet[6] = (2048 >> 8) & 255; - packet[7] = 2048 & 255; - packet[10] = 0; - packet[11] = 0; - - (void)fwrite(packet, 1, pk - packet, stdout); - return 0; - } + return special_manyhome(packet, domain); +else if (domlen >= 14 && Ustrcmp(domain + domlen - 14, "test.again.dns") == 0) + return special_again(packet, domain); +else if (domlen >= 13 && Ustrcmp(domain + domlen - 13, "test.fail.dns") == 0) + return NO_RECOVERY; if (Ustrchr(domain, '.') == NULL && qualify != NULL &&