regional_destroy(env.scratch);
}
-/** check configuration for errors */
+/** check localzones */
static void
-morechecks(struct config_file* cfg)
+localzonechecks(struct config_file* cfg)
+{
+ struct local_zones* zs;
+ if(!(zs = local_zones_create()))
+ fatal_exit("out of memory");
+ if(!local_zones_apply_cfg(zs, cfg))
+ fatal_exit("failed local-zone, local-data configuration");
+ local_zones_delete(zs);
+}
+
+/** emit warnings for IP in hosts */
+static void
+warn_hosts(const char* typ, struct config_stub* list)
{
- int i;
struct sockaddr_storage a;
socklen_t alen;
- struct config_str2list* acl;
- struct local_zones* zs;
+ struct config_stub* s;
+ struct config_strlist* h;
+ for(s=list; s; s=s->next) {
+ for(h=s->hosts; h; h=h->next) {
+ if(extstrtoaddr(h->str, &a, &alen)) {
+ fprintf(stderr, "unbound-checkconf: warning:"
+ " %s %s: \"%s\" is an IP%s address, "
+ "and when looked up as a host name "
+ "during use may not resolve.\n",
+ s->name, typ, h->str,
+ addr_is_ip6(&a, alen)?"6":"4");
+ }
+ }
+ }
+}
+
+/** check interface strings */
+static void
+interfacechecks(struct config_file* cfg)
+{
+ struct sockaddr_storage a;
+ socklen_t alen;
+ int i, j;
for(i=0; i<cfg->num_ifs; i++) {
if(!ipstrtoaddr(cfg->ifs[i], UNBOUND_DNS_PORT, &a, &alen)) {
fatal_exit("cannot parse interface specified as '%s'",
cfg->ifs[i]);
}
+ for(j=0; j<cfg->num_ifs; j++) {
+ if(i!=j && strcmp(cfg->ifs[i], cfg->ifs[j])==0)
+ fatal_exit("interface: %s present twice, "
+ "cannot bind same ports twice.",
+ cfg->ifs[i]);
+ }
}
for(i=0; i<cfg->num_out_ifs; i++) {
if(!ipstrtoaddr(cfg->out_ifs[i], UNBOUND_DNS_PORT,
fatal_exit("cannot parse outgoing-interface "
"specified as '%s'", cfg->out_ifs[i]);
}
+ for(j=0; j<cfg->num_out_ifs; j++) {
+ if(i!=j && strcmp(cfg->out_ifs[i], cfg->out_ifs[j])==0)
+ fatal_exit("outgoing-interface: %s present "
+ "twice, cannot bind same ports twice.",
+ cfg->out_ifs[i]);
+ }
}
+}
+
+/** check acl ips */
+static void
+aclchecks(struct config_file* cfg)
+{
+ int d;
+ struct sockaddr_storage a;
+ socklen_t alen;
+ struct config_str2list* acl;
for(acl=cfg->acls; acl; acl = acl->next) {
if(!netblockstrtoaddr(acl->str, UNBOUND_DNS_PORT, &a, &alen,
- &i)) {
+ &d)) {
fatal_exit("cannot parse access control address %s %s",
acl->str, acl->str2);
}
}
+}
+
+/** check configuration for errors */
+static void
+morechecks(struct config_file* cfg)
+{
+ warn_hosts("stub-host", cfg->stubs);
+ warn_hosts("forward-host", cfg->forwards);
+ interfacechecks(cfg);
+ aclchecks(cfg);
if(cfg->verbosity < 0)
fatal_exit("verbosity value < 0");
endpwent();
}
- if(!(zs = local_zones_create()))
- fatal_exit("out of memory");
- if(!local_zones_apply_cfg(zs, cfg))
- fatal_exit("failed local-zone, local-data configuration");
- local_zones_print(zs); /* @@@ DEBUG */
- local_zones_delete(zs);
+ localzonechecks(cfg);
}
/** check config file */
if((s=strchr(str, '@'))) {
char buf[MAX_ADDR_STRLEN];
if(s-str >= MAX_ADDR_STRLEN) {
- log_err("address too long: '%s'", str);
return 0;
}
strncpy(buf, str, MAX_ADDR_STRLEN);
buf[s-str] = 0;
port = atoi(s+1);
if(port == 0 && strcmp(s+1,"0")!=0) {
- log_err("bad port spec in address: '%s", str);
return 0;
}
return ipstrtoaddr(buf, port, addr, addrlen);
sa->sin6_family = AF_INET6;
sa->sin6_port = (in_port_t)htons(p);
if(inet_pton((int)sa->sin6_family, ip, &sa->sin6_addr) <= 0) {
- log_err("Bad ip6 address %s", ip);
return 0;
}
} else { /* ip4 */
sa->sin_family = AF_INET;
sa->sin_port = (in_port_t)htons(p);
if(inet_pton((int)sa->sin_family, ip, &sa->sin_addr) <= 0) {
- log_err("Bad ip4 address %s", ip);
return 0;
}
}