Beispiel #1
0
        public override byte[] Encode(G2Protocol protocol)
        {
            lock (protocol.WriteSection)
            {
                G2Frame ack = protocol.WritePacket(null, NetworkPacket.SearchAck, null);

                Source.WritePacket(protocol, ack, Packet_Source);

                protocol.WritePacket(ack, Packet_SearchID, BitConverter.GetBytes(SearchID));
                protocol.WritePacket(ack, Packet_Service, CompactNum.GetBytes(Service));

                if (Proxied)
                {
                    protocol.WritePacket(ack, Packet_Proxied, null);
                }

                foreach (DhtContact contact in ContactList)
                {
                    contact.WritePacket(protocol, ack, Packet_Contacts);
                }

                foreach (byte[] value in ValueList)
                {
                    protocol.WritePacket(ack, Packet_Values, value);
                }

                InternalData = protocol.WriteFinish();

                return(base.Encode(protocol));
            }
        }
Beispiel #2
0
        public override byte[] Encode(G2Protocol protocol)
        {
            lock (protocol.WriteSection)
            {
                G2Frame root = protocol.WritePacket(null, SharePacket.File, null);

                protocol.WritePacket(root, Packet_Name, UTF8Encoding.UTF8.GetBytes(Name));
                protocol.WritePacket(root, Packet_Hash, Hash);
                protocol.WritePacket(root, Packet_Size, CompactNum.GetBytes(Size));
                protocol.WritePacket(root, Packet_FileKey, FileKey);

                if (SaveLocal)
                {
                    if (SystemPath != null)
                    {
                        protocol.WritePacket(root, Packet_SystemPath, UTF8Encoding.UTF8.GetBytes(SystemPath));
                    }

                    if (Public)
                    {
                        protocol.WritePacket(root, Packet_Public, null);
                    }
                }

                return(protocol.WriteFinish());
            }
        }
Beispiel #3
0
        public override byte[] Encode(G2Protocol protocol)
        {
            lock (protocol.WriteSection)
            {
                G2Frame po = protocol.WritePacket(null, NetworkPacket.Pong, null);

                if (Source != null)
                {
                    Source.WritePacket(protocol, po, Packet_Source);
                }

                if (RemoteIP != null)
                {
                    protocol.WritePacket(po, Packet_RemoteIP, RemoteIP.GetAddressBytes());
                }

                if (Direct)
                {
                    protocol.WritePacket(po, Packet_Direct, null);
                }

                if (Version != 0)
                {
                    protocol.WritePacket(po, Packet_Version, CompactNum.GetBytes(Version));
                }


                // network packet
                InternalData = protocol.WriteFinish();

                return(base.Encode(protocol));
            }
        }
Beispiel #4
0
        public override byte[] Encode(G2Protocol protocol)
        {
            lock (protocol.WriteSection)
            {
                G2Frame ack = protocol.WritePacket(null, TransferPacket.Ack, null);

                protocol.WritePacket(ack, Packet_FileID, BitConverter.GetBytes(FileID));
                protocol.WritePacket(ack, Packet_StartByte, CompactNum.GetBytes(StartByte));

                if (Uninitialized)
                {
                    protocol.WritePacket(ack, Packet_Uninitialized, null);
                }

                if (Error)
                {
                    protocol.WritePacket(ack, Packet_Error, null);
                }

                if (Bitfield != null)
                {
                    protocol.WritePacket(ack, Packet_Bitfield, Bitfield);
                }

                return(protocol.WriteFinish());
            }
        }
Beispiel #5
0
        public override byte[] Encode(G2Protocol protocol)
        {
            lock (protocol.WriteSection)
            {
                G2Frame pong = protocol.WritePacket(null, TransferPacket.Pong, null);

                protocol.WritePacket(pong, Packet_FileID, BitConverter.GetBytes(FileID));
                protocol.WritePacket(pong, Packet_Timeout, CompactNum.GetBytes(Timeout));
                protocol.WritePacket(pong, Packet_Status, CompactNum.GetBytes((int)Status));

                if (Error)
                {
                    protocol.WritePacket(pong, Packet_Error, null);
                }

                if (InternalSize != 0)
                {
                    protocol.WritePacket(pong, Packet_InternalSize, CompactNum.GetBytes(InternalSize));
                    protocol.WritePacket(pong, Packet_ChunkSize, CompactNum.GetBytes(ChunkSize));
                    protocol.WritePacket(pong, Packet_BitCount, CompactNum.GetBytes(BitCount));
                }

                foreach (DhtClient client in Alts.Keys)
                {
                    G2Frame alt = protocol.WritePacket(pong, Packet_AltClient, client.ToBytes());

                    foreach (DhtAddress address in Alts[client])
                    {
                        address.WritePacket(protocol, alt, Packet_AltAddress);
                    }
                }

                return(protocol.WriteFinish());
            }
        }
Beispiel #6
0
        public override byte[] Encode(G2Protocol protocol)
        {
            byte[] details = Details.Encode(protocol); // prevent protocol conflict

            lock (protocol.WriteSection)
            {
                G2Frame ping = protocol.WritePacket(null, TransferPacket.Ping, null);

                protocol.WritePacket(ping, Packet_Target, BitConverter.GetBytes(Target));
                protocol.WritePacket(ping, Packet_Details, details);
                protocol.WritePacket(ping, Packet_Status, BitConverter.GetBytes((int)Status));

                if (MissingDepth >= 0)
                {
                    protocol.WritePacket(ping, Packet_MissingDepth, CompactNum.GetBytes(MissingDepth));
                }

                if (RequestInfo)
                {
                    protocol.WritePacket(ping, Packet_RequestInfo, null);
                }

                if (RequestAlts)
                {
                    protocol.WritePacket(ping, Packet_RequestAlts, null);
                }

                if (BitfieldUpdated)
                {
                    protocol.WritePacket(ping, Packet_BitfieldUpdated, null);
                }

                return(protocol.WriteFinish());
            }
        }
Beispiel #7
0
        public override byte[] Encode(G2Protocol protocol)
        {
            lock (protocol.WriteSection)
            {
                G2Frame packet = protocol.WritePacket(null, VoicePacket.Audio, Audio);

                protocol.WritePacket(packet, Packet_FrameSize, CompactNum.GetBytes(FrameSize));

                return(protocol.WriteFinish());
            }
        }
Beispiel #8
0
        public override byte[] Encode(G2Protocol protocol)
        {
            lock (protocol.WriteSection)
            {
                G2Frame ping = protocol.WritePacket(null, LocationPacket.Ping, null);

                protocol.WritePacket(ping, Packet_RemoteVersion, CompactNum.GetBytes(RemoteVersion));

                return(protocol.WriteFinish());
            }
        }
Beispiel #9
0
        public override byte[] Encode(G2Protocol protocol)
        {
            lock (protocol.WriteSection)
            {
                G2Frame file = protocol.WritePacket(null, BoardPacket.PostFile, null);

                protocol.WritePacket(file, Packet_Name, UTF8Encoding.UTF8.GetBytes(Name));
                protocol.WritePacket(file, Packet_Size, CompactNum.GetBytes(Size));

                return(protocol.WriteFinish());
            }
        }
Beispiel #10
0
        public override byte[] Encode(G2Protocol protocol)
        {
            lock (protocol.WriteSection)
            {
                G2Frame header = protocol.WritePacket(null, ProfilePacket.Attachment, null);

                protocol.WritePacket(header, Packet_Name, UTF8Encoding.UTF8.GetBytes(Name));
                protocol.WritePacket(header, Packet_Size, CompactNum.GetBytes(Size));

                return(protocol.WriteFinish());
            }
        }
Beispiel #11
0
        public override byte[] Encode(G2Protocol protocol)
        {
            lock (protocol.WriteSection)
            {
                G2Frame temp = protocol.WritePacket(null, TempPacket.Data, null);

                protocol.WritePacket(temp, Packet_TTL, CompactNum.GetBytes(TTL));
                protocol.WritePacket(temp, Packet_Data, Data);

                return(protocol.WriteFinish());
            }
        }
Beispiel #12
0
        public override byte[] Encode(G2Protocol protocol)
        {
            lock (protocol.WriteSection)
            {
                G2Frame td = protocol.WritePacket(null, TransferPacket.Data, Block);

                protocol.WritePacket(td, Packet_FileID, BitConverter.GetBytes(FileID));
                protocol.WritePacket(td, Packet_StartByte, CompactNum.GetBytes(StartByte));
                protocol.WritePacket(td, Packet_Index, CompactNum.GetBytes(Index));

                return(protocol.WriteFinish());
            }
        }
Beispiel #13
0
        public override byte[] Encode(G2Protocol protocol)
        {
            lock (protocol.WriteSection)
            {
                G2Frame packet = protocol.WritePacket(null, CommPacket.Data, null);

                protocol.WritePacket(packet, Packet_Service, CompactNum.GetBytes(Service));
                protocol.WritePacket(packet, Packet_DataType, CompactNum.GetBytes(DataType));
                protocol.WritePacket(packet, Packet_Data, Data);

                return(protocol.WriteFinish());
            }
        }
Beispiel #14
0
        public override byte[] Encode(G2Protocol protocol)
        {
            lock (protocol.WriteSection)
            {
                G2Frame root = protocol.WritePacket(null, SharePacket.Collection, null);

                protocol.WritePacket(root, Packet_Hash, Hash);
                protocol.WritePacket(root, Packet_Size, CompactNum.GetBytes(Size));
                protocol.WritePacket(root, Packet_Key, Key);

                return(protocol.WriteFinish());
            }
        }
Beispiel #15
0
        public override byte[] Encode(G2Protocol protocol)
        {
            lock (protocol.WriteSection)
            {
                G2Frame info = protocol.WritePacket(null, BoardPacket.PostInfo, null);

                protocol.WritePacket(info, Packet_Subject, UTF8Encoding.UTF8.GetBytes(Subject));
                protocol.WritePacket(info, Packet_Format, CompactNum.GetBytes((int)Format));
                protocol.WritePacket(info, Packet_Quip, UTF8Encoding.UTF8.GetBytes(Quip));
                protocol.WritePacket(info, Packet_Unique, BitConverter.GetBytes(Unique));

                return(protocol.WriteFinish());
            }
        }
Beispiel #16
0
        public override byte[] Encode(G2Protocol protocol)
        {
            lock (protocol.WriteSection)
            {
                G2Frame packet = protocol.WritePacket(null, TransferPacket.Params, null);

                protocol.WritePacket(packet, Packet_Service, CompactNum.GetBytes(Service));
                protocol.WritePacket(packet, Packet_DataType, CompactNum.GetBytes(DataType));
                protocol.WritePacket(packet, Packet_Hash, Hash);
                protocol.WritePacket(packet, Packet_Size, CompactNum.GetBytes(Size));
                protocol.WritePacket(packet, Packet_Extra, Extra);

                return(protocol.WriteFinish());
            }
        }
Beispiel #17
0
        public override byte[] Encode(G2Protocol protocol)
        {
            lock (protocol.WriteSection)
            {
                G2Frame info = protocol.WritePacket(null, MailPacket.MailInfo, null);

                protocol.WritePacket(info, Packet_Subject, UTF8Encoding.UTF8.GetBytes(Subject));
                protocol.WritePacket(info, Packet_Format, CompactNum.GetBytes((int)Format));
                protocol.WritePacket(info, Packet_Quip, UTF8Encoding.UTF8.GetBytes(Quip));
                protocol.WritePacket(info, Packet_Date, BitConverter.GetBytes(Date.ToBinary()));
                protocol.WritePacket(info, Packet_Attachments, BitConverter.GetBytes(Attachments));
                protocol.WritePacket(info, Packet_Unique, Unique);

                return(protocol.WriteFinish());
            }
        }
Beispiel #18
0
        public override byte[] Encode(G2Protocol protocol)
        {
            lock (protocol.WriteSection)
            {
                G2Frame notify = protocol.WritePacket(null, LocationPacket.Notify, SignedLocation);

                protocol.WritePacket(notify, Packet_Timeout, CompactNum.GetBytes(Timeout));

                if (GoingOffline)
                {
                    protocol.WritePacket(notify, Packet_GoingOffline, null);
                }

                return(protocol.WriteFinish());
            }
        }
Beispiel #19
0
        /*
         #if DEBUG
         * void SignNewUpdate()
         * {
         *  // Network update only uses sequential version
         *  // release betas with higher sequential version
         *  // auto-update requires a signed sequential version, so betas can be safely relesaed
         *
         *  Core.UserMessage("Signing Update");
         *
         *  try
         *  {
         *      UpdateInfo info = new UpdateInfo();
         *
         *      info.Name = "DeOps_13.exe";
         *      //info.DottedVersion = "1.1.3";
         *
         *      // want to prevent infinite update loop, ensure the seq verison in the intaller, and the
         *      // signed seq version in the update are equal
         *      info.SequentialVersion = Core.Context.LocalSeqVersion;
         *
         *      info.Notes = "";
         *      info.Notes += "Fixed stupid bug\r\n";
         *
         *      RijndaelManaged crypt = new RijndaelManaged();
         *      crypt.Key = Utilities.GenerateKey(Core.StrongRndGen, 256);
         *      info.Key = crypt.Key;
         *
         *      string source = "..\\Protected\\DeOps.exe";
         *      string final = Path.Combine(Application.StartupPath, "update.dat");
         *
         *      string tempPath = Core.GetTempPath();
         *      Utilities.EncryptTagFile(source, tempPath, crypt, Core.Network.Protocol, ref info.Hash, ref info.Size);
         *
         *      // function to encrypt given file
         *      using (FileStream stream = File.OpenRead(tempPath))
         *      {
         *          info.Beginning = new byte[64];
         *          stream.Read(info.Beginning, 0, info.Beginning.Length);
         *      }
         *
         *      // test
         *      //Utilities.DecryptTagFile(tempPath, "..\\Protected\\check.exe", crypt.Key, null);
         *
         *      File.Copy(tempPath, final, true);
         *      File.Delete(tempPath);
         *
         *      // sign
         *      info.SignUpdate(Core.Network.Protocol);
         *
         *      // test
         *      byte[] test = info.Encode(Core.Network.Protocol);
         *      Debug.Assert(test.Length < 1024);
         *
         *      G2Header root = new G2Header(test);
         *      Debug.Assert(G2Protocol.ReadPacket(root));
         *      Debug.Assert(UpdateInfo.Decode(root) != null);
         *
         *      // set
         *      Core.Context.SignedUpdate = info;
         *
         *      // write bootstrap
         *      LookupConfig.WriteUpdateInfo(Core);
         *
         *      Core.UserMessage("Sign Update Success");
         *
         *      Process.Start("explorer.exe", Application.StartupPath);
         *      Debug.Assert(false);
         *  }
         *  catch (Exception ex)
         *  {
         *      Core.UserMessage(ex.Message);
         *  }
         *
         *  Application.Exit();
         * }
         #endif*/


        public void NewVersion(uint version, ulong user)
        {
            // if need to get new signed info
            if (Core.Context.SignedUpdate == null || Core.Context.SignedUpdate.SequentialVersion < version)
            {
                byte[] parameters = CompactNum.GetBytes(version);

                Core.Network.Searches.Start(user, "Update Search", ServiceID, 0, parameters, Search_Found);
            }

            // else if just need file
            else if (!Core.Context.SignedUpdate.Loaded)
            {
                StartDownload(user);
            }
        }
Beispiel #20
0
        public override byte[] Encode(G2Protocol protocol)
        {
            lock (protocol.WriteSection)
            {
                G2Frame msg = protocol.WritePacket(null, IMPacket.Message, null);

                protocol.WritePacket(msg, Packet_Text, UTF8Encoding.UTF8.GetBytes(Text));
                protocol.WritePacket(msg, Packet_Format, CompactNum.GetBytes((int)Format));

                if (TargetID != 0)
                {
                    protocol.WritePacket(msg, Packet_TargetID, BitConverter.GetBytes(TargetID));
                }

                return(protocol.WriteFinish());
            }
        }
Beispiel #21
0
        public override byte[] Encode(G2Protocol protocol)
        {
            lock (protocol.WriteSection)
            {
                G2Frame stop = protocol.WritePacket(null, TransferPacket.Stop, null);

                protocol.WritePacket(stop, Packet_FileID, BitConverter.GetBytes(FileID));
                protocol.WritePacket(stop, Packet_StartByte, CompactNum.GetBytes(StartByte));
                protocol.WritePacket(stop, Packet_Index, CompactNum.GetBytes(Index));

                if (Retry)
                {
                    protocol.WritePacket(stop, Packet_Retry, null);
                }

                return(protocol.WriteFinish());
            }
        }
Beispiel #22
0
        public override byte[] Encode(G2Protocol protocol)
        {
            lock (protocol.WriteSection)
            {
                G2Frame tr = protocol.WritePacket(null, TransferPacket.Request, null);

                protocol.WritePacket(tr, Packet_FileID, BitConverter.GetBytes(FileID));
                protocol.WritePacket(tr, Packet_ChunkIndex, CompactNum.GetBytes(ChunkIndex));
                protocol.WritePacket(tr, Packet_StartByte, CompactNum.GetBytes(StartByte));
                protocol.WritePacket(tr, Packet_EndByte, CompactNum.GetBytes(EndByte));

                if (GetBitfield)
                {
                    protocol.WritePacket(tr, Packet_GetBitfield, null);
                }

                return(protocol.WriteFinish());
            }
        }
Beispiel #23
0
        public override byte[] Encode(G2Protocol protocol)
        {
            byte[] details = Details.Encode(protocol); // prevent protocol conflict

            lock (protocol.WriteSection)
            {
                G2Frame partial = protocol.WritePacket(null, TransferPacket.Partial, null);

                protocol.WritePacket(partial, Packet_Created, BitConverter.GetBytes(Created.ToBinary()));
                protocol.WritePacket(partial, Packet_Details, details);
                protocol.WritePacket(partial, Packet_Target, BitConverter.GetBytes(Target));
                protocol.WritePacket(partial, Packet_BitCount, CompactNum.GetBytes(BitCount));
                protocol.WritePacket(partial, Packet_Bitfield, Bitfield.ToBytes());
                protocol.WritePacket(partial, Packet_InternalSize, CompactNum.GetBytes(InternalSize));
                protocol.WritePacket(partial, Packet_ChunkSize, CompactNum.GetBytes(ChunkSize));

                return(protocol.WriteFinish());
            }
        }
Beispiel #24
0
        public override byte[] Encode(G2Protocol protocol)
        {
            lock (protocol.WriteSection)
            {
                G2Frame chat = protocol.WritePacket(null, ChatPacket.Data, null);

                protocol.WritePacket(chat, Packet_ID, BitConverter.GetBytes(ProjectID));
                protocol.WritePacket(chat, Packet_Kind, BitConverter.GetBytes((int)Kind));
                protocol.WritePacket(chat, Packet_RoomID, BitConverter.GetBytes(RoomID));

                if (Text.Length > 0)
                {
                    protocol.WritePacket(chat, Packet_Text, UTF8Encoding.UTF8.GetBytes(Text));
                    protocol.WritePacket(chat, Packet_Format, CompactNum.GetBytes((int)Format));
                }

                return(protocol.WriteFinish());
            }
        }
Beispiel #25
0
        public override byte[] Encode(G2Protocol protocol)
        {
            lock (protocol.WriteSection)
            {
                G2Frame req = protocol.WritePacket(null, NetworkPacket.StoreRequest, null);

                Source.WritePacket(protocol, req, Packet_Source);

                protocol.WritePacket(req, Packet_Key, BitConverter.GetBytes(Key));
                protocol.WritePacket(req, Packet_Service, CompactNum.GetBytes(Service));
                protocol.WritePacket(req, Packet_DataType, CompactNum.GetBytes(DataType));
                protocol.WritePacket(req, Packet_Data, Data);

                protocol.WritePacket(req, Packet_TTL, BitConverter.GetBytes(TTL));

                InternalData = protocol.WriteFinish();

                return(base.Encode(protocol));
            }
        }
Beispiel #26
0
        public byte[] ToBytes()
        {
            byte[] sByte = CompactNum.GetBytes(Service);
            byte[] dByte = CompactNum.GetBytes(DataType);

            byte control = (byte)(sByte.Length << 3);

            control |= (byte)dByte.Length;

            int size = 1 + sByte.Length + dByte.Length + Tag.Length;

            byte[] data = new byte[size];

            data[0] = control;
            sByte.CopyTo(data, 1);
            dByte.CopyTo(data, 1 + sByte.Length);
            Tag.CopyTo(data, 1 + sByte.Length + dByte.Length);

            return(data);
        }
Beispiel #27
0
        public override byte[] Encode(G2Protocol protocol)
        {
            lock (protocol.WriteSection)
            {
                G2Frame header = protocol.WritePacket(null, DataPacket.VersionedFile, null);

                protocol.WritePacket(header, Packet_Key, Key);
                protocol.WritePacket(header, Packet_Version, CompactNum.GetBytes(Version));

                if (FileHash != null)
                {
                    protocol.WritePacket(header, Packet_FileHash, FileHash);
                    protocol.WritePacket(header, Packet_FileSize, CompactNum.GetBytes(FileSize));
                    protocol.WritePacket(header, Packet_FileKey, FileKey);
                }

                protocol.WritePacket(header, Packet_Extra, Extra);

                return(protocol.WriteFinish());
            }
        }
Beispiel #28
0
        public override byte[] Encode(G2Protocol protocol)
        {
            lock (protocol.WriteSection)
            {
                G2Frame loc = protocol.WritePacket(null, LocationPacket.Data, null);

                protocol.WritePacket(loc, Packet_Key, Key);
                Source.WritePacket(protocol, loc, Packet_Source);
                protocol.WritePacket(loc, Packet_IP, IP.GetAddressBytes());
                protocol.WritePacket(loc, Packet_Name, UTF8Encoding.UTF8.GetBytes(Name));
                protocol.WritePacket(loc, Packet_Place, UTF8Encoding.UTF8.GetBytes(Place));
                protocol.WritePacket(loc, Packet_Version, CompactNum.GetBytes(Version));
                protocol.WritePacket(loc, Packet_GMTOffset, BitConverter.GetBytes(GmtOffset));
                protocol.WritePacket(loc, Packet_Away, BitConverter.GetBytes(Away));
                protocol.WritePacket(loc, Packet_AwayMsg, UTF8Encoding.UTF8.GetBytes(AwayMessage));

                foreach (DhtAddress proxy in Proxies)
                {
                    proxy.WritePacket(protocol, loc, Packet_Proxies);
                }

                foreach (PatchTag tag in Tags)
                {
                    protocol.WritePacket(loc, Packet_Tag, tag.ToBytes());
                }

                if (TunnelClient != null)
                {
                    protocol.WritePacket(loc, Packet_TunnelClient, TunnelClient.ToBytes());
                }

                foreach (DhtAddress server in TunnelServers)
                {
                    server.WritePacket(protocol, loc, Packet_TunnelServers);
                }

                return(protocol.WriteFinish());
            }
        }
Beispiel #29
0
        public override byte[] Encode(G2Protocol protocol)
        {
            lock (protocol.WriteSection)
            {
                G2Frame file = protocol.WritePacket(null, StoragePacket.File, null);

                protocol.WritePacket(file, Packet_UID, BitConverter.GetBytes(UID));
                protocol.WritePacket(file, Packet_Name, UTF8Encoding.UTF8.GetBytes(Name));
                protocol.WritePacket(file, Packet_Date, BitConverter.GetBytes(Date.ToBinary()));

                StorageFlags netFlags = Flags & ~(StorageFlags.Unlocked); // allow modified for working
                protocol.WritePacket(file, Packet_Flags, BitConverter.GetBytes((ushort)netFlags));
                protocol.WritePacket(file, Packet_Revs, BitConverter.GetBytes(Revs));
                protocol.WritePacket(file, Packet_Integrated, BitConverter.GetBytes(IntegratedID));

                protocol.WritePacket(file, Packet_Size, CompactNum.GetBytes(Size));
                protocol.WritePacket(file, Packet_Hash, Hash);
                protocol.WritePacket(file, Packet_FileKey, FileKey);
                protocol.WritePacket(file, Packet_InternalSize, CompactNum.GetBytes(InternalSize));
                protocol.WritePacket(file, Packet_InternalHash, InternalHash);

                byte[] scopefield = new byte[10];
                foreach (ulong id in Scope.Keys)
                {
                    BitConverter.GetBytes(id).CopyTo(scopefield, 0);
                    BitConverter.GetBytes(Scope[id]).CopyTo(scopefield, 8);

                    protocol.WritePacket(file, Packet_Scope, scopefield);
                }

                if (Note != null)
                {
                    protocol.WritePacket(file, Packet_Note, UTF8Encoding.UTF8.GetBytes(Note));
                }

                return(protocol.WriteFinish());
            }
        }
Beispiel #30
0
        public override byte[] Encode(G2Protocol protocol)
        {
            lock (protocol.WriteSection)
            {
                G2Frame req = protocol.WritePacket(null, NetworkPacket.SearchRequest, null);

                Source.WritePacket(protocol, req, Packet_Source);
                protocol.WritePacket(req, Packet_Nodes, BitConverter.GetBytes(Nodes));
                protocol.WritePacket(req, Packet_SearchID, BitConverter.GetBytes(SearchID));
                protocol.WritePacket(req, Packet_Target, BitConverter.GetBytes(TargetID));
                protocol.WritePacket(req, Packet_Service, CompactNum.GetBytes(Service));
                protocol.WritePacket(req, Packet_DataType, CompactNum.GetBytes(DataType));
                protocol.WritePacket(req, Packet_Parameters, Parameters);

                if (EndProxySearch)
                {
                    protocol.WritePacket(req, Packet_EndSearch, BitConverter.GetBytes(true));
                }

                InternalData = protocol.WriteFinish();

                return(base.Encode(protocol));
            }
        }