From 9aad3e020ba34916fd680fc157923d5d6906e1a2 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Wed, 15 Jun 2016 09:21:03 +0100 Subject: [PATCH] [Feature] Parse received timestamp --- src/lua/lua_task.c | 5 +++++ src/ragel/smtp_date.rl | 8 ++++---- src/ragel/smtp_received.rl | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/lua/lua_task.c b/src/lua/lua_task.c index bc31640fa..38402039b 100644 --- a/src/lua/lua_task.c +++ b/src/lua/lua_task.c @@ -1478,6 +1478,11 @@ lua_task_get_received_headers (lua_State * L) } lua_pushstring (L, proto); lua_settable (L, -3); + + lua_pushstring (L, "timestamp"); + lua_pushnumber (L, rh->timestamp); + lua_settable (L, -3); + rspamd_lua_table_set (L, "by_hostname", rh->by_hostname); lua_rawseti (L, -2, k ++); } diff --git a/src/ragel/smtp_date.rl b/src/ragel/smtp_date.rl index d2efe61a6..da5872439 100644 --- a/src/ragel/smtp_date.rl +++ b/src/ragel/smtp_date.rl @@ -11,7 +11,7 @@ day_name = "Mon" | "Tue" | "Wed" | "Thu" | "Fri" | "Sat" | "Sun"; day_of_week = FWS? day_name; - day = FWS? digit_2+ FWS; + day = FWS? digit{1,2} FWS; month = "Jan" | "Feb" | "Mar" | "Apr" | "May" | "Jun" | "Jul" | "Aug" | "Sep" | "Oct" | "Nov" | "Dec"; @@ -20,8 +20,8 @@ hour = digit_2; minute = digit_2; second = digit_2; - time_of_day = hour ":" minute ( ":" second ); - zone = (FWS ( "+" |"_" ) digit_4); + time_of_day = hour ":" minute (":" second )?; + zone = FWS ("+" | "-") >Sign_Start %Sign_End digit_4; time = time_of_day zone; - date_time = (day_of_week ",")? date time CFWS?; + date_time = (day_of_week ",")? date time; }%% \ No newline at end of file diff --git a/src/ragel/smtp_received.rl b/src/ragel/smtp_received.rl index 02e850c9b..8e1825855 100644 --- a/src/ragel/smtp_received.rl +++ b/src/ragel/smtp_received.rl @@ -40,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 >Date_Start %Date_End; + Received = From_domain By_domain Opt_info CFWS? ";" FWS date_time >Date_Start %Date_End CFWS?; }%% -- 2.39.5