diff options
| author | Cy Schubert <cy@FreeBSD.org> | 2019-12-28 05:27:06 +0000 | 
|---|---|---|
| committer | Cy Schubert <cy@FreeBSD.org> | 2019-12-28 05:27:06 +0000 | 
| commit | e2fe726866d062155f6b1aae749375475ef19191 (patch) | |
| tree | fe6b00611d5c987d2c12c32063891ae19295ffeb /util/config_file.c | |
| parent | 366b94c4a9552acfb560d3234aea0955ebc1eb8e (diff) | |
Notes
Diffstat (limited to 'util/config_file.c')
| -rw-r--r-- | util/config_file.c | 60 | 
1 files changed, 56 insertions, 4 deletions
diff --git a/util/config_file.c b/util/config_file.c index 9b60254d7b4e..119b22238443 100644 --- a/util/config_file.c +++ b/util/config_file.c @@ -255,6 +255,9 @@ config_create(void)  	cfg->neg_cache_size = 1 * 1024 * 1024;  	cfg->local_zones = NULL;  	cfg->local_zones_nodefault = NULL; +#ifdef USE_IPSET +	cfg->local_zones_ipset = NULL; +#endif  	cfg->local_zones_disable_default = 0;  	cfg->local_data = NULL;  	cfg->local_zone_overrides = NULL; @@ -327,9 +330,13 @@ config_create(void)  	cfg->cachedb_backend = NULL;  	cfg->cachedb_secret = NULL;  #endif +#ifdef USE_IPSET +	cfg->ipset_name_v4 = NULL; +	cfg->ipset_name_v6 = NULL; +#endif  	return cfg;  error_exit: -	config_delete(cfg);  +	config_delete(cfg);  	return NULL;  } @@ -602,7 +609,7 @@ int config_set_option(struct config_file* cfg, const char* opt,  	else S_STR("control-key-file:", control_key_file)  	else S_STR("control-cert-file:", control_cert_file)  	else S_STR("module-config:", module_conf) -	else S_STR("python-script:", python_script) +	else S_STRLIST("python-script:", python_script)  	else S_YNO("disable-dnssec-lame-check:", disable_dnssec_lame_check)  #ifdef CLIENT_SUBNET  	/* Can't set max subnet prefix here, since that value is used when @@ -1054,7 +1061,7 @@ config_get_option(struct config_file* cfg, const char* opt,  	else O_YNO(opt, "unblock-lan-zones", unblock_lan_zones)  	else O_YNO(opt, "insecure-lan-zones", insecure_lan_zones)  	else O_DEC(opt, "max-udp-size", max_udp_size) -	else O_STR(opt, "python-script", python_script) +	else O_LST(opt, "python-script", python_script)  	else O_YNO(opt, "disable-dnssec-lame-check", disable_dnssec_lame_check)  	else O_DEC(opt, "ip-ratelimit", ip_ratelimit)  	else O_DEC(opt, "ratelimit", ratelimit) @@ -1092,6 +1099,10 @@ config_get_option(struct config_file* cfg, const char* opt,  	else O_STR(opt, "backend", cachedb_backend)  	else O_STR(opt, "secret-seed", cachedb_secret)  #endif +#ifdef USE_IPSET +	else O_STR(opt, "name-v4", ipset_name_v4) +	else O_STR(opt, "name-v6", ipset_name_v6) +#endif  	/* not here:  	 * outgoing-permit, outgoing-avoid - have list of ports  	 * local-zone - zones and nodefault variables @@ -1310,6 +1321,9 @@ config_delview(struct config_view* p)  	free(p->name);  	config_deldblstrlist(p->local_zones);  	config_delstrlist(p->local_zones_nodefault); +#ifdef USE_IPSET +	config_delstrlist(p->local_zones_ipset); +#endif  	config_delstrlist(p->local_data);  	free(p);  } @@ -1384,7 +1398,6 @@ config_delete(struct config_file* cfg)  	free(cfg->version);  	free(cfg->module_conf);  	free(cfg->outgoing_avail_ports); -	free(cfg->python_script);  	config_delstrlist(cfg->caps_whitelist);  	config_delstrlist(cfg->private_address);  	config_delstrlist(cfg->private_domain); @@ -1400,6 +1413,9 @@ config_delete(struct config_file* cfg)  	free(cfg->val_nsec3_key_iterations);  	config_deldblstrlist(cfg->local_zones);  	config_delstrlist(cfg->local_zones_nodefault); +#ifdef USE_IPSET +	config_delstrlist(cfg->local_zones_ipset); +#endif  	config_delstrlist(cfg->local_data);  	config_deltrplstrlist(cfg->local_zone_overrides);  	config_del_strarray(cfg->tagname, cfg->num_tags); @@ -1420,6 +1436,7 @@ config_delete(struct config_file* cfg)  	free(cfg->dnstap_version);  	config_deldblstrlist(cfg->ratelimit_for_domain);  	config_deldblstrlist(cfg->ratelimit_below_domain); +	config_delstrlist(cfg->python_script);  #ifdef USE_IPSECMOD  	free(cfg->ipsecmod_hook);  	config_delstrlist(cfg->ipsecmod_whitelist); @@ -1428,6 +1445,10 @@ config_delete(struct config_file* cfg)  	free(cfg->cachedb_backend);  	free(cfg->cachedb_secret);  #endif +#ifdef USE_IPSET +	free(cfg->ipset_name_v4); +	free(cfg->ipset_name_v6); +#endif  	free(cfg);  } @@ -1630,6 +1651,31 @@ cfg_strlist_insert(struct config_strlist** head, char* item)  	return 1;  } +int +cfg_strlist_append_ex(struct config_strlist** head, char* item) +{ +	struct config_strlist *s; +	if(!item || !head) +		return 0; +	s = (struct config_strlist*)calloc(1, sizeof(struct config_strlist)); +	if(!s) +		return 0; +	s->str = item; +	s->next = NULL; +	 +	if (*head==NULL) { +		*head = s; +	} else { +		struct config_strlist *last = *head; +		while (last->next!=NULL) { +		    last = last->next; +		} +		last->next = s; +	} +	 +	return 1;   +} +  int   cfg_str2list_insert(struct config_str2list** head, char* item, char* i2)  { @@ -2107,6 +2153,11 @@ cfg_parse_local_zone(struct config_file* cfg, const char* val)  	if(strcmp(type, "nodefault")==0) {  		return cfg_strlist_insert(&cfg->local_zones_nodefault,   			strdup(name)); +#ifdef USE_IPSET +	} else if(strcmp(type, "ipset")==0) { +		return cfg_strlist_insert(&cfg->local_zones_ipset,  +			strdup(name)); +#endif  	} else {  		return cfg_str2list_insert(&cfg->local_zones, strdup(buf),  			strdup(type)); @@ -2381,3 +2432,4 @@ int options_remote_is_address(struct config_file* cfg)  	if(cfg->control_ifs.first->str[0] == 0) return 1;  	return (cfg->control_ifs.first->str[0] != '/');  } +  | 
