return ls;
}
+gsize
+rspamd_upstreams_count (struct upstream_list *ups)
+{
+ return ups->ups->len;
+}
+
static void
rspamd_upstream_dtor (struct upstream *up)
{
return ret;
}
+gboolean
+rspamd_upstreams_from_ucl (struct upstream_list *ups,
+ const ucl_object_t *in, guint16 def_port, void *data)
+{
+ gboolean ret = FALSE;
+ const ucl_object_t *cur;
+ ucl_object_iter_t it = NULL;
+
+ if (ucl_object_type (in) == UCL_ARRAY) {
+ while ((cur = ucl_iterate_object (in, &it, true)) != NULL) {
+ if (rspamd_upstreams_from_ucl (ups, cur, def_port, data)) {
+ ret = TRUE;
+ }
+ }
+ }
+ else if (ucl_object_type (in) == UCL_STRING) {
+ ret = rspamd_upstreams_parse_line (ups, ucl_object_tostring (in),
+ def_port, data);
+ }
+
+ return ret;
+}
+
void
rspamd_upstreams_destroy (struct upstream_list *ups)
{
#include "config.h"
#include "util.h"
#include "rdns.h"
+#include "ucl.h"
enum rspamd_upstream_rotation {
RSPAMD_UPSTREAM_RANDOM,
*/
void rspamd_upstreams_destroy (struct upstream_list *ups);
+/**
+ * Returns count of upstreams in a list
+ * @param ups
+ * @return
+ */
+gsize rspamd_upstreams_count (struct upstream_list *ups);
+
/**
* Add upstream from the string
* @param ups upstream list
gboolean rspamd_upstreams_parse_line (struct upstream_list *ups,
const gchar *str, guint16 def_port, void *data);
+
+/**
+ * Parse upstreams list from the UCL object
+ * @param ups
+ * @param in
+ * @param def_port
+ * @param data
+ * @return
+ */
+gboolean rspamd_upstreams_from_ucl (struct upstream_list *ups,
+ const ucl_object_t *in, guint16 def_port, void *data);
+
/**
* Returns the current IP address of the upstream
* @param up