added some better copper configuration stuff.
This commit is contained in:
parent
74c9030668
commit
a7be3ada0d
@ -1,9 +1,12 @@
|
|||||||
net = {}
|
net = {}
|
||||||
net.id = computer.address():sub(1,8)
|
net.id = computer.address():sub(1,8)
|
||||||
net.np = 4957
|
net.np = 4957
|
||||||
|
net.cache = true
|
||||||
|
net.cache_time = 16
|
||||||
|
net.log = false
|
||||||
net.tm = {}
|
net.tm = {}
|
||||||
if not component.list("ocemu")() then
|
if not component.list("ocemu")() then
|
||||||
_G.LKR_CACHE = true
|
net.cache = true
|
||||||
end
|
end
|
||||||
function net.send(id,po,msg) -- id, port, message
|
function net.send(id,po,msg) -- id, port, message
|
||||||
if id and po and msg then
|
if id and po and msg then
|
||||||
@ -18,7 +21,7 @@ spawn("copperd",function() print(xpcall(function ()
|
|||||||
local fcache = {}
|
local fcache = {}
|
||||||
local olog = log
|
local olog = log
|
||||||
local function log(...)
|
local function log(...)
|
||||||
if COPPER_LOG then
|
if net.log then
|
||||||
olog(...)
|
olog(...)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -73,7 +76,7 @@ spawn("copperd",function() print(xpcall(function ()
|
|||||||
end
|
end
|
||||||
else
|
else
|
||||||
if hops < 255 then
|
if hops < 255 then
|
||||||
if fcache[dst] and _G.LKR_CACHE then
|
if fcache[dst] and net.cache then
|
||||||
component.invoke(fcache[dst][1],"send",fcache[dst][2],net.np,"copper",cdlib.encode(hops+1,src,dst,data))
|
component.invoke(fcache[dst][1],"send",fcache[dst][2],net.np,"copper",cdlib.encode(hops+1,src,dst,data))
|
||||||
else
|
else
|
||||||
for k,v in ipairs(net.tm) do
|
for k,v in ipairs(net.tm) do
|
||||||
@ -87,7 +90,7 @@ spawn("copperd",function() print(xpcall(function ()
|
|||||||
end
|
end
|
||||||
for k,v in pairs(ps) do
|
for k,v in pairs(ps) do
|
||||||
if v.lt < os.time()-1 then
|
if v.lt < os.time()-1 then
|
||||||
if fcache[v.nid] and _G.LKR_CACHE then
|
if fcache[v.nid] and net.cache then
|
||||||
local lma = fcache[v.nid][1]
|
local lma = fcache[v.nid][1]
|
||||||
local rma = fcache[v.nid][2]
|
local rma = fcache[v.nid][2]
|
||||||
component.invoke(lma,"send",rma,net.np,"copper",cdlib.encode(0,net.id,v.nid,relib.encode(v)))
|
component.invoke(lma,"send",rma,net.np,"copper",cdlib.encode(0,net.id,v.nid,relib.encode(v)))
|
||||||
@ -111,7 +114,8 @@ spawn("copperd",function() print(xpcall(function ()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
for k,v in pairs(fcache) do
|
for k,v in pairs(fcache) do
|
||||||
if v[3] < cot - 60 then
|
if v[3] < cot - net.cache_time then
|
||||||
|
log(k.." derezzed")
|
||||||
fcache[k] = nil
|
fcache[k] = nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user