Software /
code /
prosody
Comparison
util/ip.lua @ 8428:ca44e462322c
util.ip: Reflow metatable
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Fri, 01 Dec 2017 01:55:15 +0100 |
parent | 8382:e5d00bf4a4d5 |
child | 8429:b3562a1b1caa |
comparison
equal
deleted
inserted
replaced
8427:1371518f70ff | 8428:ca44e462322c |
---|---|
4 -- This project is MIT/X11 licensed. Please see the | 4 -- This project is MIT/X11 licensed. Please see the |
5 -- COPYING file in the source package for more information. | 5 -- COPYING file in the source package for more information. |
6 -- | 6 -- |
7 | 7 |
8 local ip_methods = {}; | 8 local ip_methods = {}; |
9 local ip_mt = { __index = function (ip, key) return (ip_methods[key])(ip); end, | 9 |
10 __tostring = function (ip) return ip.addr; end, | 10 local ip_mt = { |
11 __eq = function (ipA, ipB) return ipA.addr == ipB.addr; end}; | 11 __index = function (ip, key) |
12 return ip_methods[key](ip); | |
13 end, | |
14 __tostring = function (ip) return ip.addr; end, | |
15 __eq = function (ipA, ipB) return ipA.addr == ipB.addr; end | |
16 }; | |
17 | |
12 local hex2bits = { | 18 local hex2bits = { |
13 ["0"] = "0000", ["1"] = "0001", ["2"] = "0010", ["3"] = "0011", | 19 ["0"] = "0000", ["1"] = "0001", ["2"] = "0010", ["3"] = "0011", |
14 ["4"] = "0100", ["5"] = "0101", ["6"] = "0110", ["7"] = "0111", | 20 ["4"] = "0100", ["5"] = "0101", ["6"] = "0110", ["7"] = "0111", |
15 ["8"] = "1000", ["9"] = "1001", ["A"] = "1010", ["B"] = "1011", | 21 ["8"] = "1000", ["9"] = "1001", ["A"] = "1010", ["B"] = "1011", |
16 ["C"] = "1100", ["D"] = "1101", ["E"] = "1110", ["F"] = "1111", | 22 ["C"] = "1100", ["D"] = "1101", ["E"] = "1110", ["F"] = "1111", |