1
0
mirror of https://github.com/XeonSquared/OC-Copper.git synced 2024-11-23 09:58:06 +11:00

Fix the hierarchial gateway and make the OC/CU/RE driver more resilient

This commit is contained in:
20kdc 2017-03-20 22:58:05 +00:00
parent 9df9823a4f
commit eeb01821c3
2 changed files with 18 additions and 13 deletions

View File

@ -86,19 +86,22 @@ end
while true do while true do
local e = {event.pull("modem_message")} local e = {event.pull("modem_message")}
if e[1] == "modem_message" then 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 if ((e[2] == tunnel.address) or (e[4] == 4957)) then
local hops, nfrom, nto, data = cdlib.decode(e[6]) if e[6] == "copper" then
if data then if type(e[7]) == "string" then
if e[2] == tunnel.address then local hops, nfrom, nto, data = cdlib.decode(e[7])
-- Pass it on as given. if data then
modem.broadcast(4957, e[6]) if e[2] == tunnel.address then
elseif e[2] == modem.address then -- Pass it on as given.
-- Process it, then give to tunnel modem.broadcast(4957, "copper", e[7])
if hops ~= 255 then elseif e[2] == modem.address then
local tfrom, tto = checkLen(processFrom(nfrom)), checkLen(processTo(nto)) -- Process it, then give to tunnel
if tfrom and tto then if hops ~= 255 then
tunnel.send(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 end
end end

View File

@ -44,7 +44,9 @@ event.listen("modem_message", function (et, adto, adfrom, port, dist, magic, dat
if et ~= "modem_message" then return end if et ~= "modem_message" then return end
if port == 4957 then if port == 4957 then
if magic == "copper" then if magic == "copper" then
node.input(adfrom, data) if type(data) == "string" then
node.input(adfrom, data)
end
end end
end end
end) end)