Skip to content

Commit 6980755

Browse files
committed
Request evidence is more leniant
1 parent 25b7a19 commit 6980755

File tree

5 files changed

+25
-19
lines changed

5 files changed

+25
-19
lines changed

.idea/.idea.Alibi/.idea/contentModel.xml

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/.idea.Alibi/.idea/workspace.xml

Lines changed: 15 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Alibi.Plugins.API/Attributes/RequireStateAttribute.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@ namespace Alibi.Plugins.API.Attributes
66
public class RequireStateAttribute : Attribute
77
{
88
public ClientState State { get; }
9+
public bool Kick { get; }
910

10-
public RequireStateAttribute(ClientState requiredState) => State = requiredState;
11+
public RequireStateAttribute(ClientState requiredState, bool kickIfFalse = true)
12+
{
13+
State = requiredState;
14+
Kick = kickIfFalse;
15+
}
1116
}
1217
}

Alibi/Protocol/MessageHandler.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,13 @@ public static void HandleMessage(IClient client, IAOPacket packet)
2424
var stateAttr = Handlers[packet.Type].Method.GetCustomAttribute<RequireStateAttribute>();
2525

2626
if (stateAttr != null)
27-
if (client.CurrentState != stateAttr.State)
27+
if (client.CurrentState != stateAttr.State && stateAttr.Kick)
2828
{
2929
client.Kick("Protocol violation.");
3030
return;
3131
}
32+
else if(client.CurrentState != stateAttr.State)
33+
return;
3234

3335
Handlers[packet.Type].Method.Invoke(Handlers[packet.Type].Target, new object[] {client, packet});
3436
}

Alibi/Protocol/Messages.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ internal static void RequestCharacters(IClient client, IAOPacket packet)
125125
}
126126

127127
[MessageHandler("RE")]
128-
[RequireState(ClientState.Identified)]
128+
[RequireState(ClientState.InArea, false)]
129129
internal static void RequestEvidence(IClient client, IAOPacket packet)
130130
{
131131
string[] evidenceList = new string[client.Area!.EvidenceList.Count];

0 commit comments

Comments
 (0)