aboutsummaryrefslogtreecommitdiffstats
path: root/src/fuzzy_storage.h
blob: 51f6a14f4eb8e551a30b7b8621c5689294cb39d5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#ifndef RSPAMD_FUZZY_STORAGE_H
#define RSPAMD_FUZZY_STORAGE_H

#include "config.h"
#include "rspamd.h"
#include "shingles.h"
#include "cryptobox.h"

#define RSPAMD_FUZZY_VERSION 3

/* Commands for fuzzy storage */
#define FUZZY_CHECK 0
#define FUZZY_WRITE 1
#define FUZZY_DEL 2

RSPAMD_PACKED(rspamd_fuzzy_cmd) {
	guint8 version;
	guint8 cmd;
	guint8 shingles_count;
	guint8 flag;
	gint32 value;
	guint32 tag;
	gchar digest[64];
};

RSPAMD_PACKED(rspamd_fuzzy_shingle_cmd) {
	struct rspamd_fuzzy_cmd basic;
	struct rspamd_shingle sgl;
};

RSPAMD_PACKED(rspamd_fuzzy_reply) {
	gint32 value;
	guint32 flag;
	guint32 tag;
	float prob;
};

RSPAMD_PACKED(rspamd_fuzzy_encrypted_req_hdr) {
	guchar magic[4];
	guchar reserved[8];
	guchar pubkey[rspamd_cryptobox_PKBYTES];
	guchar nonce[rspamd_cryptobox_NONCEBYTES];
	guchar mac[rspamd_cryptobox_MACBYTES];
};

RSPAMD_PACKED(rspamd_fuzzy_encrypted_cmd) {
	struct rspamd_fuzzy_encrypted_req_hdr hdr;
	struct rspamd_fuzzy_cmd cmd;
};

RSPAMD_PACKED(rspamd_fuzzy_encrypted_shingle_cmd) {
	struct rspamd_fuzzy_encrypted_req_hdr hdr;
	struct rspamd_fuzzy_shingle_cmd cmd;
};

RSPAMD_PACKED(rspamd_fuzzy_encrypted_rep_hdr) {
	guchar nonce[rspamd_cryptobox_NONCEBYTES];
	guchar mac[rspamd_cryptobox_MACBYTES];
};

RSPAMD_PACKED(rspamd_fuzzy_encrypted_reply) {
	struct rspamd_fuzzy_encrypted_rep_hdr hdr;
	struct rspamd_fuzzy_reply rep;
};

static const guchar fuzzy_encrypted_magic[4] = {'r', 's', 'f', 'e'};

#endif