diff --git a/oc/hierarchi.lua b/oc/hierarchi.lua index 7ae9d9a..fc3d645 100644 --- a/oc/hierarchi.lua +++ b/oc/hierarchi.lua @@ -86,19 +86,22 @@ end while true do local e = {event.pull("modem_message")} if e[1] == "modem_message" then - -- type, to, from, port, dist, data + -- type, to, from, port, dist, magic[6], data[7] if ((e[2] == tunnel.address) or (e[4] == 4957)) then - local hops, nfrom, nto, data = cdlib.decode(e[6]) - if data then - if e[2] == tunnel.address then - -- Pass it on as given. - modem.broadcast(4957, e[6]) - 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(cdlib.encode(hops + 1, tfrom, tto, data)) + if e[6] == "copper" then + if type(e[7]) == "string" then + local hops, nfrom, nto, data = cdlib.decode(e[7]) + if data then + if e[2] == tunnel.address then + -- Pass it on as given. + modem.broadcast(4957, "copper", e[7]) + 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)) + end end end end diff --git a/oc/occure.lua b/oc/occure.lua index c382d59..b5e654f 100644 --- a/oc/occure.lua +++ b/oc/occure.lua @@ -44,7 +44,9 @@ event.listen("modem_message", function (et, adto, adfrom, port, dist, magic, dat if et ~= "modem_message" then return end if port == 4957 then if magic == "copper" then - node.input(adfrom, data) + if type(data) == "string" then + node.input(adfrom, data) + end end end end)