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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
#ifndef RSPAMD_SMTP_H
#define RSPAMD_SMTP_H
#include "config.h"
#include "main.h"
#include "upstream.h"
struct smtp_upstream {
struct upstream up;
const char *name;
struct in_addr addr;
uint16_t port;
gboolean is_unix;
};
#define MAX_UPSTREAM 128
struct smtp_worker_ctx {
struct smtp_upstream upstreams[MAX_UPSTREAM];
size_t upstream_num;
memory_pool_t *pool;
char *smtp_banner;
uint32_t smtp_delay;
uint32_t delay_jitter;
struct timeval smtp_timeout;
gboolean use_xclient;
gboolean helo_required;
char *smtp_capabilities;
char *reject_message;
size_t max_size;
char *metric;
};
enum rspamd_smtp_state {
SMTP_STATE_RESOLVE_REVERSE,
SMTP_STATE_RESOLVE_NORMAL,
SMTP_STATE_DELAY,
SMTP_STATE_GREETING,
SMTP_STATE_HELO,
SMTP_STATE_FROM,
SMTP_STATE_RCPT,
SMTP_STATE_BEFORE_DATA,
SMTP_STATE_DATA,
SMTP_STATE_AFTER_DATA,
SMTP_STATE_END,
SMTP_STATE_WAIT_UPSTREAM,
SMTP_STATE_IN_SENDFILE,
SMTP_STATE_ERROR,
SMTP_STATE_CRITICAL_ERROR,
SMTP_STATE_WRITE_ERROR
};
struct smtp_session {
struct smtp_worker_ctx *ctx;
struct config_file *cfg;
memory_pool_t *pool;
enum rspamd_smtp_state state;
enum rspamd_smtp_state upstream_state;
struct rspamd_worker *worker;
struct worker_task *task;
struct in_addr client_addr;
char *hostname;
char *error;
int sock;
int upstream_sock;
int temp_fd;
size_t temp_size;
time_t session_time;
gchar *helo;
GList *from;
GList *rcpt;
GList *cur_rcpt;
struct rspamd_async_session *s;
rspamd_io_dispatcher_t *dispatcher;
rspamd_io_dispatcher_t *upstream_dispatcher;
struct smtp_upstream *upstream;
char data_end[5];
char data_idx;
gboolean resolved;
gboolean esmtp;
};
void start_smtp_worker (struct rspamd_worker *worker);
#endif
|