aboutsummaryrefslogtreecommitdiffstats
path: root/lua
diff options
context:
space:
mode:
authorAsbjørn Sloth Tønnesen <ast@2e8.dk>2019-07-18 18:43:42 +0000
committerAsbjørn Sloth Tønnesen <ast@2e8.dk>2019-07-18 18:43:42 +0000
commite92fb277616ede376d81853c052bc399c198e15d (patch)
tree9e429f4f79f34d87060e4013baa11412d6cf3b9f /lua
parent2149068c6dec19edc33010bf2026a41dd3503c2f (diff)
downloadlua-inet-e92fb277616ede376d81853c052bc399c198e15d.tar.gz
lua-inet-e92fb277616ede376d81853c052bc399c198e15d.tar.xz
lua-inet-e92fb277616ede376d81853c052bc399c198e15d.zip
use and test mixed_networks
Signed-off-by: Asbjørn Sloth Tønnesen <ast@2e8.dk>
Diffstat (limited to 'lua')
-rw-r--r--lua/inet/core.lua8
-rw-r--r--lua/inet/init.lua1
2 files changed, 8 insertions, 1 deletions
diff --git a/lua/inet/core.lua b/lua/inet/core.lua
index f9ff6e1..f3ae228 100644
--- a/lua/inet/core.lua
+++ b/lua/inet/core.lua
@@ -12,6 +12,8 @@ local bxor = bit32.bxor
local get_mt = common.get_mt
+local mixed_networks
+
local mt2fam = {}
local inet = {}
@@ -428,7 +430,7 @@ local function tostr6(self, withmask, embeddedipv4)
local zeros = {}
if embeddedipv4 == nil then
- embeddedipv4 = false -- TODO check if well-known prefix
+ embeddedipv4 = mixed_networks:contains(self)
end
local ipv6pieces = 8
@@ -674,6 +676,10 @@ end
local M = {}
+function M.set_mixed_networks(mixed_set)
+ mixed_networks = mixed_set
+end
+
M.is_inet4 = is_inet4
M.is_inet6 = is_inet6
M.is_inet = is_inet
diff --git a/lua/inet/init.lua b/lua/inet/init.lua
index 2dc7855..a504ddd 100644
--- a/lua/inet/init.lua
+++ b/lua/inet/init.lua
@@ -14,6 +14,7 @@ do
local mixed_networks = set.new()
mixed_networks:add(new_inet('::ffff:0.0.0.0/96'))
M.mixed_networks = mixed_networks
+ core.set_mixed_networks(mixed_networks)
end
M.is4 = core.is_inet4