correct issue when unpacking signed commands

This commit is contained in:
Madpeter 2023-12-06 07:43:02 +00:00
parent b64aec531e
commit 86cef289da

View file

@ -441,11 +441,14 @@ namespace SecondBotEvents.Services
{ {
accepted = false; accepted = false;
long dif = SecondbotHelpers.UnixTimeNow() - unixtimeOfCommand; long dif = SecondbotHelpers.UnixTimeNow() - unixtimeOfCommand;
if ((requireTimewindow == true) && ((unixtimeOfCommand == 0) || (dif > windowSize))) // bad time window if(requireTimewindow == true)
{
if ((unixtimeOfCommand == 0) || (dif > windowSize))
{ {
return; return;
} }
if ((signingCode == null)) // no signing code }
if (signingCode == null) // no signing code
{ {
return; return;
} }
@ -484,13 +487,26 @@ namespace SecondBotEvents.Services
{ {
unixtimeOfCommand = Convert.ToInt32(bits[1]); unixtimeOfCommand = Convert.ToInt32(bits[1]);
} }
// command|||args~#~args~#~args#|#reply_target@@@sha1 [inc time if required]
// unixtime of command
bits = bits[0].Split("@@@");
if(bits.Length == 2)
{
signingCode = bits[1];
}
// command|||args~#~args~#~args#|#reply_target
// sha1 [inc time if required]
bits = bits[0].Split("#|#"); bits = bits[0].Split("#|#");
if(bits.Length == 2) if(bits.Length == 2)
{ {
replyTarget = bits[1]; replyTarget = bits[1];
} }
// command|||args~#~args~#~args
// reply_target
bits = bits[0].Split("|||"); bits = bits[0].Split("|||");
command = bits[0]; command = bits[0];
// command
// args~#~args~#~args
args = new string[] { }; args = new string[] { };
if(bits.Length == 2) if(bits.Length == 2)
{ {