コード例 #1
0
ファイル: PacketsNet.cs プロジェクト: nandub/DeOps
        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));
            }
        }
コード例 #2
0
ファイル: PacketsNet.cs プロジェクト: nandub/DeOps
        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));
            }
        }
コード例 #3
0
ファイル: PacketsNet.cs プロジェクト: nandub/DeOps
        public override byte[] Encode(G2Protocol protocol)
        {
            lock (protocol.WriteSection)
            {
                G2Frame bye = protocol.WritePacket(null, NetworkPacket.Bye, null);

                protocol.WritePacket(bye, Packet_Source, BitConverter.GetBytes(SenderID));

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

                if (Message != null)
                {
                    protocol.WritePacket(bye, Packet_Message, UTF8Encoding.UTF8.GetBytes(Message));
                }

                if (Reconnect)
                {
                    protocol.WritePacket(bye, Packet_Reconnect, null);
                }

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

                return(base.Encode(protocol));
            }
        }
コード例 #4
0
        public byte[] EncodeLight(G2Protocol protocol)
        {
            lock (protocol.WriteSection)
            {
                G2Frame loc = protocol.WritePacket(null, LocationPacket.Data, null);

                Source.WritePacket(protocol, loc, Packet_Source);
                protocol.WritePacket(loc, Packet_IP, IP.GetAddressBytes());

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

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

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

                return(protocol.WriteFinish());
            }
        }
コード例 #5
0
ファイル: StoragePackets.cs プロジェクト: nandub/DeOps
        public override byte[] Encode(G2Protocol protocol)
        {
            lock (protocol.WriteSection)
            {
                G2Frame folder = protocol.WritePacket(null, StoragePacket.Folder, null);

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

                StorageFlags netFlags = Flags & ~(StorageFlags.Modified | StorageFlags.Unlocked);
                protocol.WritePacket(folder, Packet_Flags, BitConverter.GetBytes((ushort)netFlags));

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

                protocol.WritePacket(folder, Packet_Revs, BitConverter.GetBytes(Revs));
                protocol.WritePacket(folder, Packet_Integrated, BitConverter.GetBytes(IntegratedID));

                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(folder, Packet_Scope, scopefield);
                }

                return(protocol.WriteFinish());
            }
        }
コード例 #6
0
ファイル: PacketsNet.cs プロジェクト: nandub/DeOps
        public override byte[] Encode(G2Protocol protocol)
        {
            lock (protocol.WriteSection)
            {
                G2Frame ack = protocol.WritePacket(null, NetworkPacket.CrawlAck, null);

                Source.WritePacket(protocol, ack, Packet_Source);
                protocol.WritePacket(ack, Packet_Version, UTF8Encoding.UTF8.GetBytes(Version));
                protocol.WritePacket(ack, Packet_Uptime, BitConverter.GetBytes(Uptime));

                foreach (DhtContact proxy in ProxyServers)
                {
                    proxy.WritePacket(protocol, ack, Packet_ProxyServers);
                }

                foreach (DhtContact proxy in ProxyClients)
                {
                    proxy.WritePacket(protocol, ack, Packet_ProxyClients);
                }

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

                return(base.Encode(protocol));
            }
        }
コード例 #7
0
ファイル: ChatPackets.cs プロジェクト: nandub/DeOps
        public override byte[] Encode(G2Protocol protocol)
        {
            lock (protocol.WriteSection)
            {
                G2Frame invite = protocol.WritePacket(null, ChatPacket.Invite, null);

                protocol.WritePacket(invite, Packet_RoomID, BitConverter.GetBytes(RoomID));

                if (Host != null)
                {
                    protocol.WritePacket(invite, Packet_Host, Host);
                }

                if (SignedInvite != null)
                {
                    protocol.WritePacket(invite, Packet_SignedInvite, SignedInvite);
                }

                if (Title.Length > 0)
                {
                    protocol.WritePacket(invite, Packet_Title, UTF8Encoding.UTF8.GetBytes(Title));
                }

                return(protocol.WriteFinish());
            }
        }
コード例 #8
0
ファイル: PacketsComm.cs プロジェクト: nandub/DeOps
        public override byte[] Encode(G2Protocol protocol)
        {
            lock (protocol.WriteSection)
            {
                G2Frame bdy = protocol.WritePacket(null, RootPacket.Comm, Payload);

                protocol.WritePacket(bdy, Packet_SenderDht, BitConverter.GetBytes(SenderID));
                protocol.WritePacket(bdy, Packet_SenderClient, BitConverter.GetBytes(SenderClient));
                protocol.WritePacket(bdy, Packet_TargetDht, BitConverter.GetBytes(TargetID));
                protocol.WritePacket(bdy, Packet_TargetClient, BitConverter.GetBytes(TargetClient));
                protocol.WritePacket(bdy, Packet_Type, BitConverter.GetBytes(PacketType));
                protocol.WritePacket(bdy, Packet_ID, BitConverter.GetBytes(PeerID));
                protocol.WritePacket(bdy, Packet_Seq, BitConverter.GetBytes(Sequence));

                if (Ident != 0)
                {
                    protocol.WritePacket(bdy, Packet_Ident, BitConverter.GetBytes(Ident));
                }

                if (ToAddress != null)
                {
                    ToAddress.WritePacket(protocol, bdy, Packet_To);
                }
                if (RemoteProxy != null)
                {
                    RemoteProxy.WritePacket(protocol, bdy, Packet_Proxy);
                }

                return(protocol.WriteFinish());
            }
        }
コード例 #9
0
ファイル: TransferPackets.cs プロジェクト: nandub/DeOps
        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());
            }
        }
コード例 #10
0
ファイル: OpUser.cs プロジェクト: nandub/DeOps
        public override byte[] Encode(G2Protocol protocol)
        {
            lock (protocol.WriteSection)
            {
                G2Frame user = protocol.WritePacket(null, IdentityPacket.UserInfo, Key);

                protocol.WritePacket(user, Packet_Name, UTF8Encoding.UTF8.GetBytes(Name));

                return(protocol.WriteFinish());
            }
        }
コード例 #11
0
ファイル: VoiceService.cs プロジェクト: nandub/DeOps
        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());
            }
        }
コード例 #12
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());
            }
        }
コード例 #13
0
ファイル: StoragePackets.cs プロジェクト: nandub/DeOps
        public override byte[] Encode(G2Protocol protocol)
        {
            lock (protocol.WriteSection)
            {
                G2Frame root = protocol.WritePacket(null, StoragePacket.Root, null);

                protocol.WritePacket(root, Packet_Project, BitConverter.GetBytes(ProjectID));

                return(protocol.WriteFinish());
            }
        }
コード例 #14
0
ファイル: PacketsComm.cs プロジェクト: nandub/DeOps
        public override byte[] Encode(G2Protocol protocol)
        {
            lock (protocol.WriteSection)
            {
                G2Frame sr = protocol.WritePacket(null, CommPacket.SessionRequest, null);

                protocol.WritePacket(sr, Packet_Key, EncryptedKey);

                return(protocol.WriteFinish());
            }
        }
コード例 #15
0
ファイル: PacketsComm.cs プロジェクト: nandub/DeOps
        public override byte[] Encode(G2Protocol protocol)
        {
            lock (protocol.WriteSection)
            {
                G2Frame sa = protocol.WritePacket(null, CommPacket.SessionAck, null);

                protocol.WritePacket(sa, Packet_Name, UTF8Encoding.UTF8.GetBytes(Name));

                return(protocol.WriteFinish());
            }
        }
コード例 #16
0
ファイル: PacketsComm.cs プロジェクト: nandub/DeOps
        public override byte[] Encode(G2Protocol protocol)
        {
            lock (protocol.WriteSection)
            {
                G2Frame ka = protocol.WritePacket(null, CommPacket.KeyAck, null);

                protocol.WritePacket(ka, Packet_Key, PublicKey);

                return(protocol.WriteFinish());
            }
        }
コード例 #17
0
ファイル: PacketsComm.cs プロジェクト: nandub/DeOps
        public override byte[] Encode(G2Protocol protocol)
        {
            lock (protocol.WriteSection)
            {
                G2Frame close = protocol.WritePacket(null, CommPacket.Close, null);

                protocol.WritePacket(close, Packet_Message, UTF8Encoding.UTF8.GetBytes(Reason));

                return(protocol.WriteFinish());
            }
        }
コード例 #18
0
        public override byte[] Encode(G2Protocol protocol)
        {
            lock (protocol.WriteSection)
            {
                G2Frame signed = protocol.WritePacket(null, DataPacket.SignedData, null);

                protocol.WritePacket(signed, Packet_Signature, Signature);
                protocol.WritePacket(signed, Packet_Data, Data);

                return(protocol.WriteFinish());
            }
        }
コード例 #19
0
ファイル: TempCache.cs プロジェクト: nandub/DeOps
        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());
            }
        }
コード例 #20
0
ファイル: BoardPackets.cs プロジェクト: nandub/DeOps
        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());
            }
        }
コード例 #21
0
ファイル: MailPackets.cs プロジェクト: nandub/DeOps
        public override byte[] Encode(G2Protocol protocol)
        {
            lock (protocol.WriteSection)
            {
                G2Frame dest = protocol.WritePacket(null, MailPacket.MailDest, null);

                protocol.WritePacket(dest, Packet_Key, Key);
                protocol.WritePacket(dest, Packet_CC, BitConverter.GetBytes(CC));

                return(protocol.WriteFinish());
            }
        }
コード例 #22
0
        public static byte[] Encode(G2Protocol protocol, RSACryptoServiceProvider key, byte[] data)
        {
            lock (protocol.WriteSection)
            {
                G2Frame signed = protocol.WritePacket(null, DataPacket.SignedData, null);

                protocol.WritePacket(signed, Packet_Signature, key.SignData(data, new SHA1CryptoServiceProvider()));
                protocol.WritePacket(signed, Packet_Data, data);

                return(protocol.WriteFinish());
            }
        }
コード例 #23
0
ファイル: PacketsNet.cs プロジェクト: nandub/DeOps
        public void WritePacket(G2Protocol protocol, G2Frame root, byte name)
        {
            byte[] payload = new byte[PAYLOAD_SIZE];

            BitConverter.GetBytes(UserID).CopyTo(payload, 0);
            BitConverter.GetBytes(ClientID).CopyTo(payload, 8);
            BitConverter.GetBytes(UdpPort).CopyTo(payload, 10);

            G2Frame address = protocol.WritePacket(root, name, payload);

            protocol.WritePacket(address, Packet_IP, IP.GetAddressBytes());
        }
コード例 #24
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());
            }
        }
コード例 #25
0
ファイル: PacketsComm.cs プロジェクト: nandub/DeOps
        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());
            }
        }
コード例 #26
0
        public override byte[] Encode(G2Protocol protocol)
        {
            lock (protocol.WriteSection)
            {
                G2Frame project = protocol.WritePacket(null, TrustPacket.ProjectData, null);

                protocol.WritePacket(project, Packet_ID, BitConverter.GetBytes(ID));
                protocol.WritePacket(project, Packet_Name, UTF8Encoding.UTF8.GetBytes(Name));
                protocol.WritePacket(project, Packet_UserName, UTF8Encoding.UTF8.GetBytes(UserName));

                return(protocol.WriteFinish());
            }
        }
コード例 #27
0
ファイル: TransferPackets.cs プロジェクト: nandub/DeOps
        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());
            }
        }
コード例 #28
0
        // 100 chunks per packet - 10*200 = 2,000kb packets

        public override byte[] Encode(G2Protocol protocol)
        {
            lock (protocol.WriteSection)
            {
                G2Frame subhash = protocol.WritePacket(null, FilePacket.SubHash, null);

                protocol.WritePacket(subhash, Packet_ChunkSize, BitConverter.GetBytes(ChunkSize));
                protocol.WritePacket(subhash, Packet_TotalCount, BitConverter.GetBytes(TotalCount));
                protocol.WritePacket(subhash, Packet_SubHashes, SubHashes);

                return(protocol.WriteFinish());
            }
        }
コード例 #29
0
ファイル: ShareService.cs プロジェクト: nandub/DeOps
        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());
            }
        }
コード例 #30
0
        public override byte[] Encode(G2Protocol protocol)
        {
            lock (protocol.WriteSection)
            {
                G2Frame header = protocol.WritePacket(null, ProfilePacket.Field, null);

                protocol.WritePacket(header, Packet_Type, BitConverter.GetBytes((byte)FieldType));
                protocol.WritePacket(header, Packet_Name, UTF8Encoding.UTF8.GetBytes(Name));
                protocol.WritePacket(header, Packet_Value, Value);

                return(protocol.WriteFinish());
            }
        }
コード例 #31
0
ファイル: SharingService.cs プロジェクト: RoelofSol/DeOps
 internal override byte[] Encode(G2Protocol protocol)
 {
     lock (protocol.WriteSection)
     {
         G2Frame root = protocol.WritePacket(null, SharingPacket.PublicRequest, null);
         return protocol.WriteFinish();
     }
 }
コード例 #32
0
ファイル: SharingService.cs プロジェクト: RoelofSol/DeOps
        internal override byte[] Encode(G2Protocol protocol)
        {
            lock (protocol.WriteSection)
            {
                G2Frame root = protocol.WritePacket(null, SharingPacket.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();
            }
        }
コード例 #33
0
ファイル: SharingService.cs プロジェクト: RoelofSol/DeOps
        internal override byte[] Encode(G2Protocol protocol)
        {
            lock (protocol.WriteSection)
            {
                G2Frame root = protocol.WritePacket(null, SharingPacket.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();
            }
        }