完善解码保护,联网收到非法消息不会爆炸了
This commit is contained in:
@@ -212,8 +212,15 @@ local function loadGameEnv(P)--Load gameEnv
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
local function loadRemoteEnv(P,conf)--Load gameEnv
|
local function loadRemoteEnv(P,confStr)--Load gameEnv
|
||||||
conf=conf and json.decode(love.data.decode("string","base64",conf))or{}
|
local _,conf=pcall(love.data.decode,"string","base64",confStr)
|
||||||
|
if _ then
|
||||||
|
conf=json.decode(conf)
|
||||||
|
else
|
||||||
|
conf={}
|
||||||
|
LOG.print("Bad conf from "..P.userName.."#"..P.userID)
|
||||||
|
end
|
||||||
|
|
||||||
P.gameEnv={}--Current game setting environment
|
P.gameEnv={}--Current game setting environment
|
||||||
local ENV=P.gameEnv
|
local ENV=P.gameEnv
|
||||||
local GAME,SETTING=GAME,SETTING
|
local GAME,SETTING=GAME,SETTING
|
||||||
|
|||||||
@@ -215,12 +215,16 @@ function Player.setRS(P,RSname)
|
|||||||
P.RS=kickList[RSname]
|
P.RS=kickList[RSname]
|
||||||
end
|
end
|
||||||
|
|
||||||
function Player.setConf(P,conf)
|
function Player.setConf(P,confStr)
|
||||||
conf=json.decode(love.data.decode("string","base64",conf))
|
local _,conf=pcall(love.data.decode,"string","base64",confStr)
|
||||||
for k,v in next,conf do
|
if _ then
|
||||||
if not GAME.modeEnv[k]then
|
for k,v in next,conf do
|
||||||
P.gameEnv[k]=v
|
if not GAME.modeEnv[k]then
|
||||||
|
P.gameEnv[k]=v
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
LOG.print("Bad conf from "..P.userName.."#"..P.userID)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -73,10 +73,12 @@ function scene.socketRead(mes)
|
|||||||
}
|
}
|
||||||
remain=tonumber(args[3])
|
remain=tonumber(args[3])
|
||||||
elseif cmd=="T"then
|
elseif cmd=="T"then
|
||||||
|
local _,text=pcall(data.decode,"string","base64",args[3])
|
||||||
|
if not _ then text=args[3]end
|
||||||
textBox:push{
|
textBox:push{
|
||||||
COLOR.W,args[1],
|
COLOR.W,args[1],
|
||||||
COLOR.dY,"#"..args[2].." ",
|
COLOR.dY,"#"..args[2].." ",
|
||||||
COLOR.sky,data.decode("string","base64",args[3])
|
COLOR.sky,text
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
LOG.print("Illegal message: "..mes,30,COLOR.green)
|
LOG.print("Illegal message: "..mes,30,COLOR.green)
|
||||||
|
|||||||
@@ -198,10 +198,12 @@ function scene.socketRead(mes)
|
|||||||
end
|
end
|
||||||
initPlayerPosition(true)
|
initPlayerPosition(true)
|
||||||
elseif cmd=="T"then
|
elseif cmd=="T"then
|
||||||
|
local _,text=pcall(data.decode,"string","base64",args[3])
|
||||||
|
if not _ then text=args[3]end
|
||||||
textBox:push{
|
textBox:push{
|
||||||
COLOR.W,args[1],
|
COLOR.W,args[1],
|
||||||
COLOR.dY,"#"..args[2].." ",
|
COLOR.dY,"#"..args[2].." ",
|
||||||
COLOR.sky,data.decode("string","base64",args[3])
|
COLOR.sky,text
|
||||||
}
|
}
|
||||||
elseif cmd=="C"then
|
elseif cmd=="C"then
|
||||||
if tostring(USER.id)~=args[2]then
|
if tostring(USER.id)~=args[2]then
|
||||||
@@ -218,7 +220,12 @@ function scene.socketRead(mes)
|
|||||||
if playing and args[1]~=PLAYERS[1].subID then
|
if playing and args[1]~=PLAYERS[1].subID then
|
||||||
for _,P in next,PLAYERS do
|
for _,P in next,PLAYERS do
|
||||||
if P.subID==args[1]then
|
if P.subID==args[1]then
|
||||||
pumpRecording(data.decode("string","base64",args[2]),P.stream)
|
local _,stream=pcall(data.decode,"string","base64",args[2])
|
||||||
|
if _ then
|
||||||
|
pumpRecording(stream,P.stream)
|
||||||
|
else
|
||||||
|
LOG.print("Bad stream from "..P.userName.."#"..P.userID)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user