Skip to content

Commit a4c23b5

Browse files
committed
cmd thing
1 parent 4942958 commit a4c23b5

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

Assets/Mirror/Core/NetworkBehaviour.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,13 @@ public bool authority
163163
// hook guard prevents that.
164164
ulong syncVarHookGuard;
165165

166+
// [Command(requiresAuthority=false)] on global objects allow any sender.
167+
// senders can be verified with optional (NetworkConnectionToClient) parameter.
168+
// if a studio forgot to add that parameter, then validating senders would requires a full server + client rebuild.
169+
// sometimes that's not possible in time (i.e. urgent exploits), in that case - this field can be used.
170+
protected NetworkConnectionToClient lastCommandSender = null;
171+
internal void SetLastCommandSender(NetworkConnectionToClient conn) => lastCommandSender = conn;
172+
166173
protected virtual void OnValidate()
167174
{
168175
// Skip if Editor is in Play mode

Assets/Mirror/Core/RemoteCalls.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,9 @@ internal static bool Invoke(ushort functionHash, RemoteCallType remoteCallType,
129129
if (GetInvokerForHash(functionHash, remoteCallType, out Invoker invoker) &&
130130
invoker.componentType.IsInstanceOfType(component))
131131
{
132+
// set sender in case it's needed
133+
component.SetLastCommandSender(senderConnection);
134+
132135
// invoke function on this component
133136
invoker.function(component, reader, senderConnection);
134137
return true;

0 commit comments

Comments
 (0)