From bf3ec0ec26960c558bb624950b8229e9c798add4 Mon Sep 17 00:00:00 2001 From: 20kdc Date: Tue, 21 Mar 2017 12:50:23 +0000 Subject: [PATCH] Those changes lost in the midst of testing. --- oc/hierarchi.lua | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/oc/hierarchi.lua b/oc/hierarchi.lua index fc3d645..feba0d4 100644 --- a/oc/hierarchi.lua +++ b/oc/hierarchi.lua @@ -57,10 +57,10 @@ if outbound then return "<" .. from end processTo = function (nto) - if from:sub(1, netname:len()) ~= netname then + if nto:sub(1, netname:len()) ~= netname then return end - return from:sub(netname:len() + 1) + return nto:sub(netname:len() + 1) end else processFrom = function (from) @@ -70,14 +70,15 @@ else return netname .. from end processTo = function (nto) - if from:sub(1, 1) ~= "<" then + if nto:sub(1, 1) ~= "<" then return end - return from:sub(2) + return nto:sub(2) end end local function checkLen(s) + if not s then return end if s:len() == 0 then return end if s:len() > 256 then return end return s @@ -98,9 +99,10 @@ while true do elseif e[2] == modem.address then -- Process it, then give to tunnel if hops ~= 255 then - local tfrom, tto = checkLen(processFrom(nfrom)), checkLen(processTo(nto)) - if tfrom and tto then - tunnel.send("copper", cdlib.encode(hops + 1, tfrom, tto, data)) + local tfrom, tto = checkLen(processFrom(nfrom)), checkLen(processTo(nto)) + if tfrom and tto then + tunnel.send("copper", cdlib.encode(hops + 1, tfrom, tto, data)) + end end end end