Commit 2d6df8e6 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Only do the "feature dns" DNS-lookup if/when necessary.

Spotted by:	Willy Tarreau <w@1wt.eu>
parent 5e263a0a
......@@ -82,7 +82,6 @@ extern char *vmod_path;
extern struct vsb *params_vsb;
extern int leave_temp;
extern int vtc_witness;
extern int feature_dns;
extern int ign_unknown_macro;
void init_server(void);
......
......@@ -97,7 +97,6 @@ char *vmod_path = NULL;
struct vsb *params_vsb = NULL;
int leave_temp;
int vtc_witness = 0;
int feature_dns;
/**********************************************************************
* Parse a -D option argument into a name/val pair, and insert
......@@ -430,39 +429,6 @@ i_mode(void)
AZ(putenv(strdup("MALLOC_CONF=abort:true,junk:true")));
}
/**********************************************************************
* Most test-cases use only numeric IP#'s but a few requires non-demented
* DNS services. This is a basic sanity check for those.
*/
static int v_matchproto_(vss_resolved_f)
dns_cb(void *priv, const struct suckaddr *sa)
{
char abuf[VTCP_ADDRBUFSIZE];
char pbuf[VTCP_PORTBUFSIZE];
int *ret = priv;
VTCP_name(sa, abuf, sizeof abuf, pbuf, sizeof pbuf);
if (strcmp(abuf, "192.0.2.255")) {
fprintf(stderr, "DNS-test: Wrong response: %s\n", abuf);
*ret = -1;
} else if (*ret == 0)
*ret = 1;
return (0);
}
static int
dns_works(void)
{
int ret = 0, error;
const char *msg;
error = VSS_resolver("dns-canary.freebsd.dk", NULL, dns_cb, &ret, &msg);
if (error || msg != NULL || ret != 1)
return (0);
return (1);
}
/**********************************************************************
* Figure out what IP related magic
*/
......@@ -682,7 +648,6 @@ main(int argc, char * const *argv)
AZ(VSB_finish(params_vsb));
feature_dns = dns_works();
ip_magic();
if (iflg)
......
......@@ -47,6 +47,8 @@
#include "vnum.h"
#include "vre.h"
#include "vtcp.h"
#include "vss.h"
#include "vtim.h"
/* SECTION: vtest vtest
......@@ -338,6 +340,39 @@ cmd_delay(CMD_ARGS)
VTIM_sleep(f);
}
/**********************************************************************
* Most test-cases use only numeric IP#'s but a few requires non-demented
* DNS services. This is a basic sanity check for those.
*/
static int v_matchproto_(vss_resolved_f)
dns_cb(void *priv, const struct suckaddr *sa)
{
char abuf[VTCP_ADDRBUFSIZE];
char pbuf[VTCP_PORTBUFSIZE];
int *ret = priv;
VTCP_name(sa, abuf, sizeof abuf, pbuf, sizeof pbuf);
if (strcmp(abuf, "192.0.2.255")) {
fprintf(stderr, "DNS-test: Wrong response: %s\n", abuf);
*ret = -1;
} else if (*ret == 0)
*ret = 1;
return (0);
}
static int
dns_works(void)
{
int ret = 0, error;
const char *msg;
error = VSS_resolver("dns-canary.freebsd.dk", NULL, dns_cb, &ret, &msg);
if (error || msg != NULL || ret != 1)
return (0);
return (1);
}
/* SECTION: feature feature
*
* Test that the required feature(s) for a test are available, and skip
......@@ -424,7 +459,7 @@ cmd_feature(CMD_ARGS)
}
FEATURE("pcre_jit", VRE_has_jit);
FEATURE("64bit", sizeof(void*) == 8);
FEATURE("dns", feature_dns);
FEATURE("dns", dns_works());
FEATURE("topbuild", iflg);
FEATURE("root", !geteuid());
FEATURE("user_varnish", getpwnam("varnish") != NULL);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment