*/
struct classifier_config* find_classifier_conf (struct config_file *cfg, const gchar *name);
+/*
+ * Parse input `ip_list` to radix tree `tree`. Now supports only IPv4 addresses.
+ */
+gboolean rspamd_parse_ip_list (const gchar *ip_list, radix_tree_t **tree);
+
#endif /* ifdef CFG_FILE_H */
/*
* vi:ts=4
}
}
+gboolean
+rspamd_parse_ip_list (const gchar *ip_list, radix_tree_t **tree)
+{
+ gchar **strvec, **cur;
+ struct in_addr ina;
+ guint32 mask;
+
+ strvec = g_strsplit_set (ip_list, ",", 0);
+ cur = strvec;
+
+ while (*cur != NULL) {
+ /* XXX: handle only ipv4 addresses */
+ if (parse_ipmask_v4 (*cur, &ina, &mask)) {
+ if (*tree == NULL) {
+ *tree = radix_tree_create ();
+ }
+ radix32tree_add (*tree, htonl (ina.s_addr), mask, 1);
+ }
+ cur ++;
+ }
+
+ return (*tree != NULL);
+}
+
/*
* vi:ts=4
*/
ctx->start_time = time (NULL);
ctx->worker = worker;
+ ctx->cfg = worker->srv->cfg;
+ ctx->srv = worker->srv;
+
/* Accept event */
ctx->http = evhttp_new (ctx->ev_base);