Skip to content

Commit 2195a0e

Browse files
Merge branch 'develop-2.0.0' into vetting-test-develop-2.0.0
2 parents 305235b + aea4421 commit 2195a0e

File tree

6 files changed

+758
-299
lines changed

6 files changed

+758
-299
lines changed

com.unity.netcode.gameobjects/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Additional documentation and release notes are available at [Multiplayer Documen
1717

1818
### Fixed
1919

20+
- Fixed issue where NetworkConfig.ConnectionData could cause the ConnectionRequestMessage to exceed the transport's MTU size and would result in a buffer overflow error. (#3564)
2021
- Fixed regression issue in v2.x where `NetworkObject.GetNetworkBehaviourAtOrderIndex` was converted from public to internal. (#3541)
2122
- Fixed ensuring OnValueChanged callback is still triggered on the authority when a collection changes and then reverts to the previous value in the same frame. (#3539)
2223
- Fixed synchronizing the destroyGameObject parameter to clients for InScenePlaced network objects. (#3514)

com.unity.netcode.gameobjects/Runtime/Connection/NetworkConnectionManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,7 @@ private void SendConnectionRequest()
635635
}
636636
}
637637

638-
SendMessage(ref message, NetworkDelivery.ReliableSequenced, NetworkManager.ServerClientId);
638+
SendMessage(ref message, NetworkDelivery.ReliableFragmentedSequenced, NetworkManager.ServerClientId);
639639
message.MessageVersions.Dispose();
640640
}
641641

com.unity.netcode.gameobjects/Tests/Editor/Messaging/MessageCorruptionTests.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,13 @@ public unsafe void Send(ulong clientId, NetworkDelivery delivery, FastBufferWrit
9090
break;
9191
}
9292
case TypeOfCorruption.CorruptBytes:
93-
batchData.Seek(batchData.Length - 2);
94-
var currentByte = batchData.GetUnsafePtr()[0];
95-
batchData.WriteByteSafe((byte)(currentByte == 0 ? 1 : 0));
96-
MessageQueue.Add(batchData.ToArray());
93+
for (int i = 0; i < 4; i++)
94+
{
95+
var currentByte = batchData.GetUnsafePtr()[i];
96+
currentByte = (byte)((currentByte + 1) % 255);
97+
batchData.WriteByteSafe(currentByte);
98+
MessageQueue.Add(batchData.ToArray());
99+
}
97100
break;
98101
case TypeOfCorruption.Truncated:
99102
batchData.Truncate(batchData.Length - 1);

com.unity.netcode.gameobjects/Tests/Runtime/ConnectionApproval.cs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public enum PlayerCreation
2222
Prefab,
2323
PrefabHash,
2424
NoPlayer,
25-
FailValidation
25+
FailValidation,
2626
}
2727
private PlayerCreation m_PlayerCreation;
2828
private bool m_ClientDisconnectReasonValidated;
@@ -38,7 +38,7 @@ public ConnectionApprovalTests(PlayerCreation playerCreation)
3838

3939
protected override int NumberOfClients => 1;
4040

41-
private Guid m_ValidationToken;
41+
private string m_ValidationToken;
4242

4343
protected override bool ShouldCheckForSpawnedPlayers()
4444
{
@@ -56,8 +56,13 @@ protected override void OnServerAndClientsCreated()
5656
m_ClientDisconnectReasonValidated = false;
5757
m_BypassConnectionTimeout = m_PlayerCreation == PlayerCreation.FailValidation;
5858
m_Validated.Clear();
59-
m_ValidationToken = Guid.NewGuid();
60-
var validationToken = Encoding.UTF8.GetBytes(m_ValidationToken.ToString());
59+
m_ValidationToken = string.Empty;
60+
// Exceed the expected MTU size
61+
while (m_ValidationToken.Length < 2000)
62+
{
63+
m_ValidationToken += Guid.NewGuid().ToString();
64+
}
65+
var validationToken = Encoding.UTF8.GetBytes(m_ValidationToken);
6166
m_ServerNetworkManager.ConnectionApprovalCallback = NetworkManagerObject_ConnectionApprovalCallback;
6267
m_ServerNetworkManager.NetworkConfig.PlayerPrefab = m_PlayerCreation == PlayerCreation.Prefab ? m_PlayerPrefab : null;
6368
if (m_PlayerCreation == PlayerCreation.PrefabHash)
@@ -66,7 +71,6 @@ protected override void OnServerAndClientsCreated()
6671
}
6772
m_ServerNetworkManager.NetworkConfig.ConnectionApproval = true;
6873
m_ServerNetworkManager.NetworkConfig.ConnectionData = validationToken;
69-
7074
foreach (var client in m_ClientNetworkManagers)
7175
{
7276
client.NetworkConfig.PlayerPrefab = m_PlayerCreation == PlayerCreation.Prefab ? m_PlayerPrefab : null;

com.unity.netcode.gameobjects/Tests/Runtime/Transports/UnityTransportTests.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ public IEnumerator Cleanup()
5151

5252
// Need to destroy the GameObject (all assigned components will get destroyed too)
5353
UnityEngine.Object.DestroyImmediate(m_Server.gameObject);
54+
m_Server = null;
5455
}
5556

5657
if (m_Client1)
@@ -59,6 +60,7 @@ public IEnumerator Cleanup()
5960

6061
// Need to destroy the GameObject (all assigned components will get destroyed too)
6162
UnityEngine.Object.DestroyImmediate(m_Client1.gameObject);
63+
m_Client1 = null;
6264
}
6365

6466
if (m_Client2)
@@ -67,6 +69,7 @@ public IEnumerator Cleanup()
6769

6870
// Need to destroy the GameObject (all assigned components will get destroyed too)
6971
UnityEngine.Object.DestroyImmediate(m_Client2.gameObject);
72+
m_Client2 = null;
7073
}
7174
m_ServerEvents?.Clear();
7275
m_Client1Events?.Clear();
@@ -317,7 +320,7 @@ public IEnumerator DisconnectOnReliableSendQueueOverflow()
317320
m_Server.StartServer();
318321
m_Client1.StartClient();
319322

320-
yield return WaitForNetworkEvent(NetworkEvent.Connect, m_Client1Events);
323+
yield return WaitForNetworkEvent(NetworkEvent.Connect, m_Client1Events, 5.0f);
321324

322325
var serverClientId = m_Client1.ServerClientId;
323326

0 commit comments

Comments
 (0)