Пример #1
0
        private void testActionToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (sender is ToolStripMenuItem item)
            {
                var actionCode = AllowActionList.
                                 GetYoponAction($"template{item.Text}");
                var chat  = ActiveUser.ChatProxy;
                var proxy = chat?.WebSocketProxy;

                if (proxy?.IsActive == true)
                {
                    var header = new Header();
                    var data   = new ByteArray();
                    data.WriteUTF(actionCode);
                    data.Encrypt(chat.Key);
                    header.CommandId =
                        ChatMethod.ACTION;
                    header.Body = data.Bytes;
                    proxy.Send(header.ToArray());
                }
            }
        }
Пример #2
0
        public override bool ProcessRequestAsync(IRequest request, ICallback callback)
        {
            var url = request.Url;

            Task.Run(() =>
            {
                using (callback)
                {
                    var data = Download(url);

                    if (data.Length > 0)
                    {
                        var module    = new ByteArray(data);
                        int signature = module.ReadByte();

                        if (signature == 101)
                        {
                            var keys = new ByteArray();

                            keys.WriteBytes(keyPrefixHash);
                            keys.WriteBytes(module.ReadBytes(8));

                            var position   = module.Position;
                            var cipherData = module.ReadBytes(module.Length - position);

                            module.Position = position;

                            var decryptor = new D(keys);
                            var index     = 0;

                            while (index + 1024 < cipherData.Length)
                            {
                                decryptor.DecryptBlock(cipherData, index, 32);
                                index = index + 1024;
                            }

                            if (YoponSetting.I.HasDownloadModule)
                            {
                                var dir  = YoponSetting.SwfSaveDir;
                                var f    = new Uri(url).LocalPath;
                                var name = Path.GetFileName(f);
                                Directory.CreateDirectory(dir);
                                File.WriteAllBytes($"{dir}{name}", cipherData);
                            }

                            AllowActionList.LoadSwf(cipherData);

                            var stream = new MemoryStream(data);

                            ResponseLength = stream.Length;
                            StatusCode     = (int)HttpStatusCode.OK;
                            Stream         = stream;

                            callback.Continue();
                        }
                    }
                }
            });

            return(true);
        }