diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-04-23 11:33:18 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-04-23 14:45:27 +0100 |
commit | 6832271dbc2771c7e3b2512fef2dcc054ab55c49 (patch) | |
tree | 5e7c944fabf2bcb92f8be6aa5e70d8940ba05167 /src/ragel/smtp_ip.rl | |
parent | d4c86a2cd8a4f326870079d1bcf1cc2b005deec4 (diff) | |
download | rspamd-6832271dbc2771c7e3b2512fef2dcc054ab55c49.tar.gz rspamd-6832271dbc2771c7e3b2512fef2dcc054ab55c49.zip |
[Feature] Add parsers for SMTP address in ragel
Diffstat (limited to 'src/ragel/smtp_ip.rl')
-rw-r--r-- | src/ragel/smtp_ip.rl | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/ragel/smtp_ip.rl b/src/ragel/smtp_ip.rl new file mode 100644 index 000000000..b6b0080f3 --- /dev/null +++ b/src/ragel/smtp_ip.rl @@ -0,0 +1,19 @@ +%%{ + machine smtp_ip; + + # Parses IPv4/IPv6 address + # Source: https://tools.ietf.org/html/rfc5321#section-4.1.3 + + Snum = digit{1,3}; + IPv4_address_literal = Snum ("." Snum){3}; + IPv6_hex = xdigit{1,4}; + IPv6_full = IPv6_hex (":" IPv6_hex){7}; + IPv6_comp = (IPv6_hex (":" IPv6_hex){0,5})? "::" + (IPv6_hex (":" IPv6_hex){0,5})?; + IPv6v4_full = IPv6_hex (":" IPv6_hex){5} ":" IPv4_address_literal; + IPv6v4_comp = (IPv6_hex (":" IPv6_hex){0,3})? "::" + (IPv6_hex (":" IPv6_hex){0,3} ":")? + IPv4_address_literal; + IPv6_addr = IPv6_full | IPv6_comp | IPv6v4_full | IPv6v4_comp; + IPv6_address_literal = "IPv6:" IPv6_addr; +}%%
\ No newline at end of file |