/*
 * initialize module
 */
static int mod_init(void) {
	bind_sl_t bind_sl;
	strl* ptr;

	DBG("sanity initializing\n");

	/*
	 * We will need sl_send_reply from stateless
	 * module for sending replies
	 */
	bind_sl = (bind_sl_t)find_export("bind_sl", 0, 0);
	if (!bind_sl) {
		ERR("This module requires sl module\n");
		return -1;
	}
	if (bind_sl(&sl) < 0) return -1;

	DBG("parsing proxy requires string:\n");
	ptr = parse_str_list(&pr_str);

	proxyrequire_list = ptr;

	while (ptr != NULL) {
		DBG("string: '%.*s', next: %p\n", ptr->string.len, ptr->string.s, ptr->next);
		ptr = ptr->next;
	}

	return 0;
}
Example #2
0
/*
 * initialize module
 */
static int mod_init(void) {
	strl* ptr;

	LM_DBG("sanity initializing\n");

	ksr_sanity_info_init();

	/* bind the SL API */
	if (sl_load_api(&slb)!=0) {
		LM_ERR("cannot bind to SL API\n");
		return -1;
	}

	LM_DBG("parsing proxy requires string:\n");
	ptr = parse_str_list(&pr_str);

	proxyrequire_list = ptr;

	while (ptr != NULL) {
		LM_DBG("string: '%.*s', next: %p\n", ptr->string.len,
				ptr->string.s, ptr->next);
		ptr = ptr->next;
	}

	return 0;
}
int
dcplugin_init(DCPlugin * const dcplugin, int argc, char *argv[])
{
    Blocking *blocking;
    int       opt_flag;
    int       option_index = 0;

    if ((blocking = calloc((size_t) 1U, sizeof *blocking)) == NULL) {
        return -1;
    }
    dcplugin_set_user_data(dcplugin, blocking);
    if (blocking == NULL) {
        return -1;
    }
    blocking->domains = blocking->ips = NULL;
    optind = 0;
#ifdef _OPTRESET
    optreset = 1;
#endif
    while ((opt_flag = getopt_long(argc, argv,
                                   getopt_options, getopt_long_options,
                                   &option_index)) != -1) {
        switch (opt_flag) {
        case 'd':
            if (parse_str_list(&blocking->domains, optarg) != 0) {
                return -1;
            }
            break;
        case 'i':
            if (parse_str_list(&blocking->ips, optarg) != 0) {
                return -1;
            }
            break;
        default:
            return -1;
        }
    }
    return 0;
}
int
dcplugin_init(DCPlugin * const dcplugin, int argc, char *argv[])
{
    Context  *context;
    GeoIP    *geoip;
    int       opt_flag;
    int       option_index = 0;

    if ((context = calloc((size_t) 1U, sizeof *context)) == NULL) {
        return -1;
    }
    dcplugin_set_user_data(dcplugin, context);
    if (context == NULL) {
        return -1;
    }
    context->blacklist = NULL;
    context->geoip = NULL;
    optind = 0;
#ifdef _OPTRESET
    optreset = 1;
#endif
    while ((opt_flag = getopt_long(argc, argv,
                                   getopt_options, getopt_long_options,
                                   &option_index)) != -1) {
        switch (opt_flag) {
        case 'b':
            if ((context->blacklist = parse_str_list(optarg)) == NULL) {
                return -1;
            }
            break;
        case 'g':
            if ((context->geoip = GeoIP_open(optarg, GEOIP_MEMORY_CACHE)) == NULL) {
                return -1;
            }
            break;
        default:
            return -1;
        }
    }
    if (context->blacklist == NULL || context->geoip == NULL) {
        return -1;
    }
    return 0;
}