mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
Merged in paulpach/hlapi-community-edition/norandombytes (pull request #38)
Don't allow end user to send random bytes
This commit is contained in:
commit
c5263ed7ac
@ -283,7 +283,9 @@ static bool SendToObservers(GameObject contextObj, short msgType, MessageBase ms
|
||||
return false;
|
||||
}
|
||||
|
||||
static public void SendWriterToReady(GameObject contextObj, NetworkWriter writer, int channelId)
|
||||
// End users should not send random bytes
|
||||
// because the other side might interpret them as messages
|
||||
static internal void SendWriterToReady(GameObject contextObj, NetworkWriter writer, int channelId)
|
||||
{
|
||||
if (writer.Position > UInt16.MaxValue)
|
||||
{
|
||||
@ -293,7 +295,9 @@ static public void SendWriterToReady(GameObject contextObj, NetworkWriter writer
|
||||
SendBytesToReady(contextObj, writer.ToArray(), writer.Position, channelId);
|
||||
}
|
||||
|
||||
static public void SendBytesToReady(GameObject contextObj, byte[] buffer, int numBytes, int channelId)
|
||||
// End users should not send random bytes
|
||||
// because the other side might interpret them as messages
|
||||
static internal void SendBytesToReady(GameObject contextObj, byte[] buffer, int numBytes, int channelId)
|
||||
{
|
||||
if (contextObj == null)
|
||||
{
|
||||
@ -344,25 +348,6 @@ static public void SendBytesToReady(GameObject contextObj, byte[] buffer, int nu
|
||||
}
|
||||
}
|
||||
|
||||
public static void SendBytesToPlayer(GameObject player, byte[] buffer, int numBytes, int channelId)
|
||||
{
|
||||
for (int i = 0; i < connections.Count; i++)
|
||||
{
|
||||
var conn = connections[i];
|
||||
if (conn != null)
|
||||
{
|
||||
for (int j = 0; j < conn.playerControllers.Count; j++)
|
||||
{
|
||||
if (conn.playerControllers[j].IsValid && conn.playerControllers[j].gameObject == player)
|
||||
{
|
||||
conn.SendBytes(buffer, numBytes, channelId);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static public bool SendByChannelToAll(short msgType, MessageBase msg, int channelId)
|
||||
{
|
||||
if (LogFilter.logDev) { Debug.Log("Server.SendByChannelToAll id:" + msgType); }
|
||||
|
Loading…
Reference in New Issue
Block a user