Last active
December 28, 2015 16:48
-
-
Save vstakhov/7531010 to your computer and use it in GitHub Desktop.
An example of how to use rspamd_lua_ip module
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| local print_octets = function(ip) | |
| print('Normal order octets:') | |
| for _,o in ipairs(ip:str_octets()) do | |
| print(o) | |
| end | |
| print('Reversed order octets:') | |
| for _,o in ipairs(ip:inversed_str_octets()) do | |
| print(o) | |
| end | |
| print('Numeric octets:') | |
| for _,o in ipairs(ip:to_table()) do | |
| print(o) | |
| end | |
| end | |
| local ip4 = rspamd_ip.from_string('127.0.0.1') | |
| print(ip4) | |
| print_octets(ip4) | |
| local ip6 = rspamd_ip.from_string('2001:41d0:8:dd9a::100') | |
| print(ip6) | |
| print_octets(ip6) | |
| -- Output: | |
| -- 127.0.0.1 | |
| -- Normal order octets: | |
| -- 127 | |
| -- 0 | |
| -- 0 | |
| -- 1 | |
| -- Reversed order octets: | |
| -- 1 | |
| -- 0 | |
| -- 0 | |
| -- 127 | |
| -- Numeric octets: | |
| -- 127 | |
| -- 0 | |
| -- 0 | |
| -- 1 | |
| -- 2001:41d0:8:dd9a::100 | |
| -- Normal order octets: | |
| -- 2 | |
| -- 0 | |
| -- 0 | |
| -- 1 | |
| -- 4 | |
| -- 1 | |
| -- d | |
| -- 0 | |
| -- 0 | |
| -- 0 | |
| -- 0 | |
| -- 8 | |
| -- d | |
| -- d | |
| -- 9 | |
| -- a | |
| -- 0 | |
| -- 0 | |
| -- 0 | |
| -- 0 | |
| -- 0 | |
| -- 0 | |
| -- 0 | |
| -- 0 | |
| -- 0 | |
| -- 0 | |
| -- 0 | |
| -- 0 | |
| -- 0 | |
| -- 1 | |
| -- 0 | |
| -- 0 | |
| -- Reversed order octets: | |
| -- 0 | |
| -- 0 | |
| -- 1 | |
| -- 0 | |
| -- 0 | |
| -- 0 | |
| -- 0 | |
| -- 0 | |
| -- 0 | |
| -- 0 | |
| -- 0 | |
| -- 0 | |
| -- 0 | |
| -- 0 | |
| -- 0 | |
| -- 0 | |
| -- a | |
| -- 9 | |
| -- d | |
| -- d | |
| -- 8 | |
| -- 0 | |
| -- 0 | |
| -- 0 | |
| -- 0 | |
| -- d | |
| -- 1 | |
| -- 4 | |
| -- 1 | |
| -- 0 | |
| -- 0 | |
| -- 2 | |
| -- Numeric octets: | |
| -- 32 | |
| -- 1 | |
| -- 65 | |
| -- 208 | |
| -- 0 | |
| -- 8 | |
| -- 221 | |
| -- 154 | |
| -- 0 | |
| -- 0 | |
| -- 0 | |
| -- 0 | |
| -- 0 | |
| -- 0 | |
| -- 1 | |
| -- 0 | |
| -- |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment