aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2015-03-30 15:04:56 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2015-03-30 15:04:56 +0100
commit179af280e97a94471e2946cb275c24994379e471 (patch)
treee9d09880f28e8a2d12809bb6ba3d537009c257e8 /src
parentaaef1f83ddcc631b471f85cac1c7b815990ad8b9 (diff)
downloadrspamd-179af280e97a94471e2946cb275c24994379e471.tar.gz
rspamd-179af280e97a94471e2946cb275c24994379e471.zip
Add function to parse inet address.
Diffstat (limited to 'src')
-rw-r--r--src/libserver/cfg_rcl.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/libserver/cfg_rcl.c b/src/libserver/cfg_rcl.c
index 0fe869a08..66247cf61 100644
--- a/src/libserver/cfg_rcl.c
+++ b/src/libserver/cfg_rcl.c
@@ -1971,6 +1971,41 @@ rspamd_rcl_parse_struct_boolean (rspamd_mempool_t *pool,
return TRUE;
}
+gboolean
+rspamd_rcl_parse_struct_addr (rspamd_mempool_t *pool,
+ const ucl_object_t *obj,
+ gpointer ud,
+ struct rspamd_rcl_section *section,
+ GError **err)
+{
+ struct rspamd_rcl_struct_parser *pd = ud;
+ rspamd_inet_addr_t **target;
+ const gchar *val;
+
+ target = (rspamd_inet_addr_t **)(((gchar *)pd->user_struct) + pd->offset);
+
+ if (obj->type == UCL_STRING) {
+ val = ucl_object_tostring (obj);
+
+ if (!rspamd_parse_inet_address (target, val)) {
+ g_set_error (err,
+ CFG_RCL_ERROR,
+ EINVAL,
+ "cannot parse inet address: %s", val);
+ return FALSE;
+ }
+ }
+ else {
+ g_set_error (err,
+ CFG_RCL_ERROR,
+ EINVAL,
+ "cannot convert an object to inet address");
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
void
rspamd_rcl_register_worker_option (struct rspamd_config *cfg,
gint type,