aboutsummaryrefslogtreecommitdiffstats
path: root/src/ragel
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2016-06-15 08:33:26 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2016-06-15 08:33:26 +0100
commit5a70a9191f3d0901f03372fabec66634618c91a4 (patch)
treee3cbf44fa2733df3a646227126c58ad2a5f8eff4 /src/ragel
parentb4b74e7d0531a414c93d4416fb7e4176c0a8fca7 (diff)
downloadrspamd-5a70a9191f3d0901f03372fabec66634618c91a4.tar.gz
rspamd-5a70a9191f3d0901f03372fabec66634618c91a4.zip
[Feature] Parse received date and ESMTPA proto
Diffstat (limited to 'src/ragel')
-rw-r--r--src/ragel/smtp_received.rl10
-rw-r--r--src/ragel/smtp_received_parser.rl22
2 files changed, 29 insertions, 3 deletions
diff --git a/src/ragel/smtp_received.rl b/src/ragel/smtp_received.rl
index 235c54906..02e850c9b 100644
--- a/src/ragel/smtp_received.rl
+++ b/src/ragel/smtp_received.rl
@@ -11,7 +11,13 @@
Addtl_Link = Atom;
Link = "TCP" | Addtl_Link;
Attdl_Protocol = Atom;
- Protocol = "ESMTP" %ESMTP_proto | "SMTP" %SMTP_proto | "ESMTPS" %ESMTPS_proto | "LMTP" %LMTP_proto | "IMAP" %IMAP_proto | Attdl_Protocol;
+ Protocol = "ESMTP" %ESMTP_proto |
+ "SMTP" %SMTP_proto |
+ "ESMTPS" %ESMTPS_proto |
+ "ESMTPA" %ESMTPA_proto |
+ "LMTP" %LMTP_proto |
+ "IMAP" %IMAP_proto |
+ Attdl_Protocol;
TCP_info = address_literal >Real_IP_Start %Real_IP_End |
( Domain >Real_Domain_Start %Real_Domain_End FWS address_literal >Real_IP_Start %Real_IP_End );
@@ -34,6 +40,6 @@
For = CFWS "FOR"i FWS ( Path | Mailbox ) %For_End;
Additional_Registered_Clauses = CFWS Atom FWS String;
Opt_info = Via? With? ID? For? Additional_Registered_Clauses?;
- Received = From_domain By_domain Opt_info CFWS? ";" FWS date_time;
+ Received = From_domain By_domain Opt_info CFWS? ";" FWS date_time >Date_Start %Date_End;
}%%
diff --git a/src/ragel/smtp_received_parser.rl b/src/ragel/smtp_received_parser.rl
index 5170c2806..7161eab96 100644
--- a/src/ragel/smtp_received_parser.rl
+++ b/src/ragel/smtp_received_parser.rl
@@ -220,6 +220,9 @@
action ESMTPS_proto {
rh->type = RSPAMD_RECEIVED_ESMTPS;
}
+ action ESMTPA_proto {
+ rh->type = RSPAMD_RECEIVED_ESMTPA;
+ }
action ESMTP_proto {
rh->type = RSPAMD_RECEIVED_ESMTP;
}
@@ -230,6 +233,22 @@
rh->type = RSPAMD_RECEIVED_IMAP;
}
+ action Date_Start {
+ date_start = p;
+ }
+ action Date_End {
+ if (date_start && p > date_start) {
+ guint len;
+ char *tdate;
+
+ len = p - date_start;
+ tdate = g_malloc (len + 1);
+ rspamd_strlcpy (tdate, date_start, len + 1);
+ rh->timestamp = g_mime_utils_header_decode_date (tdate, NULL);
+ g_free (tdate);
+ }
+ }
+
include smtp_received "smtp_received.rl";
main := Received;
@@ -248,7 +267,7 @@ rspamd_smtp_recieved_parse (struct rspamd_task *task, const char *data, size_t l
*real_ip_start, *real_ip_end,
*reported_domain_start, *reported_domain_end,
*reported_ip_start, *reported_ip_end,
- *ip_start, *ip_end;
+ *ip_start, *ip_end, *date_start;
const char *p = data, *pe = data + len, *eof;
int cs, in_v6 = 0;
@@ -263,6 +282,7 @@ rspamd_smtp_recieved_parse (struct rspamd_task *task, const char *data, size_t l
reported_ip_end = NULL;
ip_start = NULL;
ip_end = NULL;
+ date_start = NULL;
rh->type = RSPAMD_RECEIVED_UNKNOWN;
memset (&for_addr, 0, sizeof (for_addr));