apps/app_verify.c
static int reload_verify(int reload)
{
	const char *tempstr;
	char *cat = NULL;
	struct call_verify *v;
	struct ast_variable *var;
	struct ast_config *cfg;
	struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 };

	if (!(cfg = ast_config_load("verify.conf", config_flags))) {
		ast_debug(1, "No verify config file (verify.conf), so no verification profiles loaded\n");
		return 0;
	} else if (cfg == CONFIG_STATUS_FILEUNCHANGED) {
		return 0;
	} else if (cfg == CONFIG_STATUS_FILEINVALID) {
		ast_log(LOG_ERROR, "Config file verify.conf is in an invalid format. Aborting.\n");
		return 0;
	}

	AST_RWLIST_WRLOCK(&verifys);

	/* Reset Global Var Values */
	curltimeout = DEFAULT_CURL_TIMEOUT;

	/* General section */
	if (!ast_strlen_zero(tempstr = ast_variable_retrieve(cfg, "general", "curltimeout"))) {
		if (ast_str_to_int(tempstr, &curltimeout)) {
			ast_log(LOG_WARNING, "Invalid curl timeout: %s\n", tempstr);
			curltimeout = DEFAULT_CURL_TIMEOUT;
		}
	}

	/* Remaining sections */
	while ((cat = ast_category_browse(cfg, cat))) {
		int new = 0;

		if (!strcasecmp(cat, "general")) {
			continue;
		}

		/* Look for an existing one */
		AST_LIST_TRAVERSE(&verifys, v, entry) {
			if (!strcasecmp(v->name, cat)) {
				break;
			}
		}

		ast_debug(1, "New profile: '%s'\n", cat);

		if (!v) {
			/* Make one then */
			v = alloc_profile(cat);
			new = 1;
		}

		/* Totally fail if we fail to find/create an entry */
		if (!v) {
			ast_log(LOG_WARNING, "Failed to create verify profile for '%s'\n", cat);
			continue;
		}

		if (!new) {
			ast_mutex_lock(&v->lock);
		}
		/* Re-initialize the defaults */
		v->extendtrust = 1;
		v->allowdisathru = 1;
		v->allowpstnthru = 1;
		v->allowtoken = 0;
		v->threshold = 0;
		v->sanitychecks = 0;
		v->flagprivateip = 1;
		v->blacklist_threshold = 1;
		v->blacklist_failopen = 0;
		ast_copy_string(v->verifymethod, "reverse", sizeof(v->verifymethod));
		ast_copy_string(v->requestmethod, "curl", sizeof(v->requestmethod));
		/* Search Config */
		var = ast_variable_browse(cfg, cat);
		while (var) {
			ast_debug(2, "Logging parameter %s with value %s from lineno %d\n", var->name, var->value, var->lineno);
			profile_set_param(v, var->name, var->value, var->lineno, 1);
			var = var->next;
		} /* End while(var) loop */

		if (!new) {
			ast_mutex_unlock(&v->lock);
		} else {
			AST_RWLIST_INSERT_HEAD(&verifys, v, entry);
		}
	}

	ast_config_destroy(cfg);

	AST_RWLIST_UNLOCK(&verifys);

	return 0;
}
/*! \brief Reload verify application module */
\brief Reload verify application module
\ brief Reload verify application module
static int reload_verify(int reload)
{
	const char *tempstr;
	char *cat = NULL;
	struct call_verify *v;
	struct ast_variable *var;
	struct ast_config *cfg;
	struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 };
	if (!(cfg = ast_config_load("verify.conf", config_flags))) {
		ast_debug(1, "No verify config file (verify.conf), so no verification profiles loaded\n");
		return 0;
	} else if (cfg == CONFIG_STATUS_FILEUNCHANGED) {
		return 0;
	} else if (cfg == CONFIG_STATUS_FILEINVALID) {
		ast_log(LOG_ERROR, "Config file verify.conf is in an invalid format. Aborting.\n");
		return 0;
	}
	AST_RWLIST_WRLOCK(&verifys);
	curltimeout = DEFAULT_CURL_TIMEOUT;
	if (!ast_strlen_zero(tempstr = ast_variable_retrieve(cfg, "general", "curltimeout"))) {
		if (ast_str_to_int(tempstr, &curltimeout)) {
			ast_log(LOG_WARNING, "Invalid curl timeout: %s\n", tempstr);
			curltimeout = DEFAULT_CURL_TIMEOUT;
		}
	}
	while ((cat = ast_category_browse(cfg, cat))) {
		int new = 0;
		if (!strcasecmp(cat, "general")) {
			continue;
		}
		AST_LIST_TRAVERSE(&verifys, v, entry) {
			if (!strcasecmp(v->name, cat)) {
				break;
			}
		}
		ast_debug(1, "New profile: '%s'\n", cat);
		if (!v) {
			v = alloc_profile(cat);
			new = 1;
		}
		if (!v) {
			ast_log(LOG_WARNING, "Failed to create verify profile for '%s'\n", cat);
			continue;
		}
		if (!new) {
			ast_mutex_lock(&v->lock);
		}
		v->extendtrust = 1;
		v->allowdisathru = 1;
		v->allowpstnthru = 1;
		v->allowtoken = 0;
		v->threshold = 0;
		v->sanitychecks = 0;
		v->flagprivateip = 1;
		v->blacklist_threshold = 1;
		v->blacklist_failopen = 0;
		ast_copy_string(v->verifymethod, "reverse", sizeof(v->verifymethod));
		ast_copy_string(v->requestmethod, "curl", sizeof(v->requestmethod));
		var = ast_variable_browse(cfg, cat);
		while (var) {
			ast_debug(2, "Logging parameter %s with value %s from lineno %d\n", var->name, var->value, var->lineno);
			profile_set_param(v, var->name, var->value, var->lineno, 1);
			var = var->next;
		} 
		if (!new) {
			ast_mutex_unlock(&v->lock);
		} else {
			AST_RWLIST_INSERT_HEAD(&verifys, v, entry);
		}
	}
	ast_config_destroy(cfg);
	AST_RWLIST_UNLOCK(&verifys);
	return 0;
}
static int reload_verify ( int reload ) { const char * tempstr ; char * cat = NULL ; struct call_verify * v ; struct ast_variable * var ; struct ast_config * cfg ; struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 } ; if ( ! ( cfg = ast_config_load ( " " , config_flags ) ) ) { ast_debug ( 1 , " \n " ) ; return 0 ; } else if ( cfg == CONFIG_STATUS_FILEUNCHANGED ) { return 0 ; } else if ( cfg == CONFIG_STATUS_FILEINVALID ) { ast_log ( LOG_ERROR , " \n " ) ; return 0 ; } AST_RWLIST_WRLOCK ( & verifys ) ; curltimeout = DEFAULT_CURL_TIMEOUT ; if ( ! ast_strlen_zero ( tempstr = ast_variable_retrieve ( cfg , " " , " " ) ) ) { if ( ast_str_to_int ( tempstr , & curltimeout ) ) { ast_log ( LOG_WARNING , " \n " , tempstr ) ; curltimeout = DEFAULT_CURL_TIMEOUT ; } } while ( ( cat = ast_category_browse ( cfg , cat ) ) ) { int new = 0 ; if ( ! strcasecmp ( cat , " " ) ) { continue ; } AST_LIST_TRAVERSE ( & verifys , v , entry ) { if ( ! strcasecmp ( v -> name , cat ) ) { break ; } } ast_debug ( 1 , " \n " , cat ) ; if ( ! v ) { v = alloc_profile ( cat ) ; new = 1 ; } if ( ! v ) { ast_log ( LOG_WARNING , " \n " , cat ) ; continue ; } if ( ! new ) { ast_mutex_lock ( & v -> lock ) ; } v -> extendtrust = 1 ; v -> allowdisathru = 1 ; v -> allowpstnthru = 1 ; v -> allowtoken = 0 ; v -> threshold = 0 ; v -> sanitychecks = 0 ; v -> flagprivateip = 1 ; v -> blacklist_threshold = 1 ; v -> blacklist_failopen = 0 ; ast_copy_string ( v -> verifymethod , " " , sizeof ( v -> verifymethod ) ) ; ast_copy_string ( v -> requestmethod , " " , sizeof ( v -> requestmethod ) ) ; var = ast_variable_browse ( cfg , cat ) ; while ( var ) { ast_debug ( 2 , " \n " , var -> name , var -> value , var -> lineno ) ; profile_set_param ( v , var -> name , var -> value , var -> lineno , 1 ) ; var = var -> next ; } if ( ! new ) { ast_mutex_unlock ( & v -> lock ) ; } else { AST_RWLIST_INSERT_HEAD ( & verifys , v , entry ) ; } } ast_config_destroy ( cfg ) ; AST_RWLIST_UNLOCK ( & verifys ) ; return 0 ; }
\brief Reload verify application module
\ brief Reload verify application module
/* Reset Global Var Values */ /* General section */ /* Remaining sections */ /* Look for an existing one */ /* Make one then */ /* Totally fail if we fail to find/create an entry */ /* Re-initialize the defaults */ /* Search Config */ /* End while(var) loop */