mirror of
https://github.com/ShadowKatStudios/OC-Minitel.git
synced 2024-11-25 19:38:07 +11:00
Compare commits
3 Commits
5c2e4e6137
...
1b8929b129
Author | SHA1 | Date | |
---|---|---|---|
|
1b8929b129 | ||
071a692f11 | |||
|
8c1c25f79e |
@ -74,6 +74,17 @@ function computer.pullSignal(t)
|
|||||||
else
|
else
|
||||||
packetQueue[eventTab[11]] = nil
|
packetQueue[eventTab[11]] = nil
|
||||||
end
|
end
|
||||||
|
elseif eventTab[8]:sub(1,1) == "~" then
|
||||||
|
if eventTab[8] == "~" then
|
||||||
|
computer.pushSignal("net_broadcast", eventTab[9], eventTab[10], eventTab[11])
|
||||||
|
else
|
||||||
|
for d in eventTab[8]:gmatch("~([^~]+)") do
|
||||||
|
if d == net.hostname then
|
||||||
|
computer.pushSignal("net_msg",eventTab[9],eventTab[10],eventTab[11])
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
elseif net.route and checkCache(eventTab[6]) then
|
elseif net.route and checkCache(eventTab[6]) then
|
||||||
rawSendPacket(eventTab[6],eventTab[7],eventTab[8],eventTab[9],eventTab[10],eventTab[11])
|
rawSendPacket(eventTab[6],eventTab[7],eventTab[8],eventTab[9],eventTab[10],eventTab[11])
|
||||||
end
|
end
|
||||||
|
@ -1,12 +1,18 @@
|
|||||||
local computer = require "computer"
|
local computer = require "computer"
|
||||||
local event = require "event"
|
local event = require "event"
|
||||||
local net = {}
|
local net = {}
|
||||||
net.mtu = 4096
|
net.mtu = 8192
|
||||||
net.streamdelay = 30
|
net.streamdelay = 30
|
||||||
net.minport = 32768
|
net.minport = 32768
|
||||||
net.maxport = 65535
|
net.maxport = 65535
|
||||||
net.openports = {}
|
net.openports = {}
|
||||||
|
|
||||||
|
for k,v in pairs(computer.getDeviceInfo()) do
|
||||||
|
if v.class == "network" then
|
||||||
|
net.mtu = math.min(net.mtu, tonumber(v.capacity))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function net.genPacketID()
|
function net.genPacketID()
|
||||||
local npID = ""
|
local npID = ""
|
||||||
for i = 1, 16 do
|
for i = 1, 16 do
|
||||||
@ -31,17 +37,13 @@ function net.rsend(to,port,data,block)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- ordered packet delivery, layer 4?
|
-- ordered packet delivery, layer 4?
|
||||||
|
|
||||||
function net.send(to,port,ldata)
|
function net.send(to,port,ldata)
|
||||||
local tdata = {}
|
local tdata, hsize = {}, 44 + #(os.getenv("HOSTNAME") or computer.address():sub(1,8)) + #to
|
||||||
if ldata:len() > net.mtu then
|
while hsize+#ldata > net.mtu do
|
||||||
for i = 1, ldata:len(), net.mtu do
|
tdata[#tdata+1] = ldata:sub(1, net.mtu - hsize)
|
||||||
tdata[#tdata+1] = ldata:sub(1,net.mtu)
|
ldata = ldata:sub(#tdata[#tdata]+1)
|
||||||
ldata = ldata:sub(net.mtu+1)
|
|
||||||
end
|
|
||||||
else
|
|
||||||
tdata = {ldata}
|
|
||||||
end
|
end
|
||||||
|
tdata[#tdata+1] = ldata
|
||||||
for k,v in ipairs(tdata) do
|
for k,v in ipairs(tdata) do
|
||||||
if not net.rsend(to,port,v) then return false end
|
if not net.rsend(to,port,v) then return false end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user