mirror of
https://github.com/kepler155c/opus
synced 2024-12-28 01:20:27 +00:00
modem packet validation
This commit is contained in:
parent
68ee419d83
commit
10a0c3a724
@ -128,6 +128,7 @@ function Socket.connect(host, port)
|
|||||||
local e, id, sport, dport, msg = os.pullEvent()
|
local e, id, sport, dport, msg = os.pullEvent()
|
||||||
if e == 'modem_message' and
|
if e == 'modem_message' and
|
||||||
sport == socket.sport and
|
sport == socket.sport and
|
||||||
|
type(msg) == 'table' and
|
||||||
msg.dhost == socket.shost then
|
msg.dhost == socket.shost then
|
||||||
|
|
||||||
os.cancelTimer(timerId)
|
os.cancelTimer(timerId)
|
||||||
@ -183,7 +184,8 @@ function Socket.server(port)
|
|||||||
local _, _, sport, dport, msg = os.pullEvent('modem_message')
|
local _, _, sport, dport, msg = os.pullEvent('modem_message')
|
||||||
|
|
||||||
if sport == port and
|
if sport == port and
|
||||||
msg and type(msg) == 'table' and
|
msg and
|
||||||
|
type(msg) == 'table' and
|
||||||
msg.dhost == os.getComputerID() and
|
msg.dhost == os.getComputerID() and
|
||||||
msg.type == 'OPEN' then
|
msg.type == 'OPEN' then
|
||||||
|
|
||||||
|
@ -83,11 +83,15 @@ Event.on('modem_message', function(_, _, dport, dhost, request)
|
|||||||
if dport == 80 and dhost == computerId and type(request) == 'table' then
|
if dport == 80 and dhost == computerId and type(request) == 'table' then
|
||||||
if request.method == 'GET' then
|
if request.method == 'GET' then
|
||||||
local query
|
local query
|
||||||
|
if not request.path or type(request.path) ~= 'string' then
|
||||||
|
return
|
||||||
|
end
|
||||||
local path = request.path:gsub('%?(.*)', function(v)
|
local path = request.path:gsub('%?(.*)', function(v)
|
||||||
query = parseQuery(v)
|
query = parseQuery(v)
|
||||||
return ''
|
return ''
|
||||||
end)
|
end)
|
||||||
if fs.isDir(path) then
|
if fs.isDir(path) then
|
||||||
|
-- TODO: more validation
|
||||||
modem.transmit(request.replyPort, request.replyAddress, {
|
modem.transmit(request.replyPort, request.replyAddress, {
|
||||||
statusCode = 200,
|
statusCode = 200,
|
||||||
contentType = 'table/directory',
|
contentType = 'table/directory',
|
||||||
|
Loading…
Reference in New Issue
Block a user