Commit b9c6acbc authored by Kristian Lyngstøl's avatar Kristian Lyngstøl

DNS Director VCC improvements: Don't assert() as much on syntax errors in

VCL. Also adds a small test for incorrect headers.




git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@5418 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 8e1c8ce4
......@@ -20,6 +20,14 @@ varnish v1 -badvcl {
}
}
varnish v9 -badvcl {
director directorname dns {
.list = {
.host_hdr = "192.168.1.1";
"192.168.1.2";
}
}
}
varnish v1 -badvcl {
director directorname dns {
.list = {
......@@ -45,10 +53,10 @@ varnish v1 -badvcl {
}
}
#varnish v1 -badvcl {
# director directorname dns {
# .list = {
# "192.168.16.255"/24;
# }
# }
#}
varnish v1 -badvcl {
director directorname dns {
.list = {
"192.168.16.255"/24;
}
}
}
......@@ -153,12 +153,14 @@ vcc_dir_dns_makebackend(struct vcc *tl,
ip4 |= a[3] ;
ip4end = ip4 | ~mask;
assert (ip4 == (ip4 & mask));
if (ip4 != (ip4 & mask)) {
vsb_printf(tl->sb, "IP and network mask not compatible: ");
vcc_ErrToken(tl, tl->t);
vsb_printf(tl->sb, " at\n");
vcc_ErrWhere(tl, tl->t);
ERRCHK(tl);
}
/* printf("uip4: \t0x%.8X\na: \t0x", ip4,ip4);
for (int i=0;i<4;i++) printf("%.2X",a[i]);
printf("\nmask:\t0x%.8X\nend:\t0x%.8X\n", mask, ip4end);
*/
while (ip4 <= ip4end) {
uint8_t *b;
b=(uint8_t *)&ip4;
......@@ -256,13 +258,23 @@ vcc_dir_dns_parse_list(struct vcc *tl, int *serial)
int ret;
ERRCHK(tl);
SkipToken(tl, '{');
if (tl->t->tok != CSTR)
if (tl->t->tok != CSTR) {
vcc_dir_dns_parse_backend_options(tl);
ERRCHK(tl);
}
while (tl->t->tok == CSTR) {
mask = 32;
ret = sscanf(tl->t->dec, "%hhu.%hhu.%hhu.%hhu",
&a[0], &a[1], &a[2], &a[3]);
assert(ret == 4);
if (ret != 4) {
vsb_printf(tl->sb, "Incomplete IP supplied: ");
vcc_ErrToken(tl, tl->t);
vsb_printf(tl->sb, " at\n");
vcc_ErrWhere(tl, tl->t);
ERRCHK(tl);
}
vcc_NextToken(tl);
if (tl->t->tok == '/') {
vcc_NextToken(tl);
......
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