diff options
Diffstat (limited to 'src/libutil/http_context.c')
-rw-r--r-- | src/libutil/http_context.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/libutil/http_context.c b/src/libutil/http_context.c index d5ab49450..6695e8032 100644 --- a/src/libutil/http_context.c +++ b/src/libutil/http_context.c @@ -207,4 +207,35 @@ rspamd_http_context_default (void) g_assert (default_ctx != NULL); return default_ctx; +} + +gint32 +rspamd_keep_alive_key_hash (struct rspamd_keepalive_hash_key k) +{ + gint32 h; + + h = rspamd_inet_address_port_hash (k.addr); + + if (k.host) { + h = rspamd_cryptobox_fast_hash (k.host, strlen (k.host), h); + } + + return h; +} + +bool +rspamd_keep_alive_key_equal (struct rspamd_keepalive_hash_key k1, + struct rspamd_keepalive_hash_key k2) +{ + if (k1.host && k2.host) { + if (rspamd_inet_address_port_equal (k1.addr, k2.addr)) { + return strcmp (k1.host, k2.host); + } + } + else if (!k1.host && !k2.host) { + return rspamd_inet_address_port_equal (k1.addr, k2.addr); + } + + /* One has host and another has no host */ + return false; }
\ No newline at end of file |