Beispiel #1
0
        public static void SystemNotifyUserGroupReset(DeltaConnection conn, ObjectId user)
        {
            //Get buffer
            byte[] buffer = _CreateResetGroupsTemplate(FILTERCODE_USER, 12, out int filterOffset);

            //Write filter
            BinaryTool.WriteMongoID(buffer, filterOffset, user);

            //Send
            conn.net.SendRPCCommand(buffer);
        }
Beispiel #2
0
        public static void SendRPCMsgToServer(DeltaConnection conn, RPCOpcode opcode, object payload, ObjectId server_id)
        {
            //Calculate
            string data    = JsonConvert.SerializeObject(payload);
            int    dataLen = Encoding.UTF8.GetByteCount(data);

            //Get buffer
            byte[] buffer = _CreateRPCMessageTemplate(opcode, FILTERCODE_SERVER, 12, (uint)dataLen, out int filterOffset, out int payloadOffset);

            //Write filter
            BinaryTool.WriteMongoID(buffer, filterOffset, server_id);

            //Write payload
            Encoding.UTF8.GetBytes(data, 0, data.Length, buffer, payloadOffset);

            //Send
            conn.net.SendRPCCommand(buffer);
        }
Beispiel #3
0
        public static byte[] _CreatePrivilegedMessageServerTemplate(RPCOpcode op, ObjectId guild, int[] payloadSizes, int[] payloadTribes, out int[] payloadOffsets)
        {
            //1     Byte    Command Opcode
            //1     Byte    Flags
            //4     Int32   RPC Opcode
            //12    MongoID Guild ID
            //4     Int32   Payload Count
            // === ARRAY BEGIN ===
            //4     Int32   Tribe ID
            //4     Int32   Payload Size
            //^     <blob>  Payload data
            // === ARRAY END ===
            payloadOffsets = new int[payloadSizes.Length];

            //Calculate the total size of all payloads, plus their headers
            int totalLength = 0;

            for (int i = 0; i < payloadSizes.Length; i++)
            {
                totalLength += 8 + payloadSizes[i];
            }

            //Generate buffer
            byte[] payload = new byte[22 + totalLength];
            payload[0] = TYPECODE_GROUP_RESET;
            payload[1] = 0x00;
            BitConverter.GetBytes((int)op).CopyTo(payload, 2);
            BinaryTool.WriteMongoID(payload, 6, guild);
            BitConverter.GetBytes((int)payloadSizes.Length).CopyTo(payload, 18);
            int offset = 22;

            for (int i = 0; i < payloadSizes.Length; i++)
            {
                BitConverter.GetBytes(payloadTribes[i]).CopyTo(payload, offset + 0);
                BitConverter.GetBytes(payloadSizes[i]).CopyTo(payload, offset + 4);
                payloadOffsets[i] = offset + 8;
                offset           += 8 + payloadSizes[i];
            }

            return(payload);
        }
 public static bool AuthenticateHashedPassword(string request, byte[] challengeHash, byte[] challengeSalt)
 {
     //Compute
     byte[] hash = ComputeHash(request, challengeSalt);
     return(BinaryTool.CompareBytes(hash, challengeHash));
 }