mirror of https://github.com/kepler155c/opus
sanitize discovery messages
This commit is contained in:
parent
43163053a5
commit
310879a801
|
@ -121,20 +121,26 @@ print('discovery: listening on port 999')
|
||||||
|
|
||||||
Event.on('modem_message', function(_, _, sport, id, info, distance)
|
Event.on('modem_message', function(_, _, sport, id, info, distance)
|
||||||
if sport == 999 and tonumber(id) and type(info) == 'table' then
|
if sport == 999 and tonumber(id) and type(info) == 'table' then
|
||||||
if not network[id] then
|
if info.label and info.id and
|
||||||
network[id] = { }
|
type(info.label) == 'string' and type(info.id) == 'number' then
|
||||||
end
|
|
||||||
Util.merge(network[id], info)
|
|
||||||
network[id].distance = distance
|
|
||||||
network[id].timestamp = os.clock()
|
|
||||||
|
|
||||||
if not network[id].label then
|
if not network[id] then
|
||||||
network[id].label = 'unknown'
|
network[id] = { }
|
||||||
end
|
end
|
||||||
|
Util.merge(network[id], info)
|
||||||
|
network[id].distance = type(distance) == 'number' and distance
|
||||||
|
network[id].timestamp = os.clock()
|
||||||
|
|
||||||
if not network[id].active then
|
if not network[id].label then
|
||||||
network[id].active = true
|
network[id].label = 'unknown'
|
||||||
os.queueEvent('network_attach', network[id])
|
end
|
||||||
|
|
||||||
|
if not network[id].active then
|
||||||
|
network[id].active = true
|
||||||
|
os.queueEvent('network_attach', network[id])
|
||||||
|
end
|
||||||
|
else
|
||||||
|
print('discovery: Invalid alive message ' .. id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
Loading…
Reference in New Issue