struct upstream_inet_addr_entry *new_addrs;
rspamd_mutex_t *lock;
-
+ gpointer data;
ref_entry_t ref;
};
rspamd_mutex_t *lock;
guint64 hash_seed;
guint cur_elt;
+ enum rspamd_upstream_flag flags;
enum rspamd_upstream_rotation rot_alg;
};
g_ptr_array_remove_index (ls->alive, up->active_idx);
up->active_idx = -1;
- if (up->ctx->res != NULL && up->ctx->configured) {
+ if (up->ctx->res != NULL && up->ctx->configured &&
+ !(ls->flags & RSPAMD_UPSTREAM_FLAG_NORESOLVE)) {
/* Resolve name of the upstream one more time */
if (up->name[0] != '/') {
{
struct upstream_list *ls;
- ls = g_slice_alloc (sizeof (*ls));
+ ls = g_slice_alloc0 (sizeof (*ls));
ls->hash_seed = SEED_CONSTANT;
ls->ups = g_ptr_array_new ();
ls->alive = g_ptr_array_new ();
return TRUE;
}
+void
+rspamd_upstreams_set_flags (struct upstream_list *ups,
+ enum rspamd_upstream_flag flags)
+{
+ ups->flags = flags;
+}
+
gboolean
rspamd_upstream_add_addr (struct upstream *up, rspamd_inet_addr_t *addr)
{
up = cur->data;
REF_RETAIN (up);
- if (up->name[0] != '/' && ctx->res != NULL) {
+ if (up->name[0] != '/' && ctx->res != NULL &&
+ !(up->ls->flags & RSPAMD_UPSTREAM_FLAG_NORESOLVE)) {
if (rdns_make_request_full (ctx->res,
rspamd_upstream_dns_cb,
up,
cur = g_list_next (cur);
}
}
+
+gpointer
+rspamd_upstream_set_data (struct upstream *up, gpointer data)
+{
+ gpointer prev_data = up->data;
+ up->data = data;
+
+ return prev_data;
+}
+
+gpointer
+rspamd_upstream_get_data (struct upstream *up)
+{
+ return up->data;
+}
RSPAMD_UPSTREAM_UNDEF
};
+enum rspamd_upstream_flag {
+ RSPAMD_UPSTREAM_FLAG_NORESOLVE = (1 << 0),
+};
struct rspamd_config;
/* Opaque upstream structures */
* @return
*/
struct upstream_list* rspamd_upstreams_create (struct upstream_ctx *ctx);
+
+/**
+ * Sets specific flag to the upstream list
+ * @param ups
+ * @param flags
+ */
+void rspamd_upstreams_set_flags (struct upstream_list *ups,
+ enum rspamd_upstream_flag flags);
+
/**
* Destroy list of upstreams
* @param ups
*/
const gchar* rspamd_upstream_name (struct upstream *up);
+/**
+ * Sets opaque user data associated with this upstream
+ * @param up
+ * @param data
+ * @return old data
+ */
+gpointer rspamd_upstream_set_data (struct upstream *up, gpointer data);
+
+/**
+ * Gets opaque user data associated with this upstream
+ * @param up
+ * @return
+ */
+gpointer rspamd_upstream_get_data (struct upstream *up);
+
/**
* Get new upstream from the list
* @param ups upstream list