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(); } }
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(); } }
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(); } }
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(); } }
public override byte[] Encode(G2Protocol protocol) { lock (protocol.WriteSection) { protocol.WritePacket(null, IMPacket.Alive, null); return protocol.WriteFinish(); } }
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(); } }
public override byte[] Encode(G2Protocol protocol) { lock (protocol.WriteSection) { G2Frame ack = protocol.WritePacket(null, MailPacket.Ack, null); protocol.WritePacket(ack, Packet_MailID, MailID); protocol.WritePacket(ack, Packet_Source, Source); protocol.WritePacket(ack, Packet_Target, Target); protocol.WritePacket(ack, Packet_TargetVersion, BitConverter.GetBytes(TargetVersion)); protocol.WritePacket(ack, Packet_SourceVersion, BitConverter.GetBytes(SourceVersion)); return protocol.WriteFinish(); } }
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(); } }
public override byte[] Encode(G2Protocol protocol) { lock (protocol.WriteSection) { // signals start of encryption if (Start) protocol.WritePacket(null, CommPacket.CryptStart, null); // padding for encrypted block else protocol.WritePacket(null, CommPacket.CryptPadding, Padding); return protocol.WriteFinish(); } }
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(); } }
public override byte[] Encode(G2Protocol protocol) { lock (protocol.WriteSection) { G2Frame request = protocol.WritePacket(null, TrustPacket.UplinkReq, null); protocol.WritePacket(request, Packet_ProjectID, BitConverter.GetBytes(ProjectID)); protocol.WritePacket(request, Packet_LinkVersion, BitConverter.GetBytes(LinkVersion)); protocol.WritePacket(request, Packet_TargetVersion, BitConverter.GetBytes(TargetVersion)); protocol.WritePacket(request, Packet_Key, Key); protocol.WritePacket(request, Packet_Target, Target); return protocol.WriteFinish(); } }
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(); } }
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(); } }
public override byte[] Encode(G2Protocol protocol) { lock (protocol.WriteSection) { G2Frame buddy = protocol.WritePacket(null, BuddyPacket.Buddy, Key); protocol.WritePacket(buddy, Packet_Name, UTF8Encoding.UTF8.GetBytes(Name)); if(Group != null) protocol.WritePacket(buddy, Packet_Group, UTF8Encoding.UTF8.GetBytes(Group)); if(Ignored) protocol.WritePacket(buddy, Packet_Ignored, null); return protocol.WriteFinish(); } }
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(); } }
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(); } }
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(); } }
// cant write local info (read) because post is re-transmitted public override byte[] Encode(G2Protocol protocol) { lock (protocol.WriteSection) { G2Frame header = protocol.WritePacket(null, BoardPacket.PostHeader, null); protocol.WritePacket(header, Packet_Source, Source); protocol.WritePacket(header, Packet_Target, Target); protocol.WritePacket(header, Packet_ProjectID, BitConverter.GetBytes(ProjectID)); protocol.WritePacket(header, Packet_PostID, BitConverter.GetBytes(PostID)); protocol.WritePacket(header, Packet_ParentID, BitConverter.GetBytes(ParentID)); protocol.WritePacket(header, Packet_Time, BitConverter.GetBytes(Time.ToBinary())); protocol.WritePacket(header, Packet_Scope, new byte[] { (byte)Scope }); protocol.WritePacket(header, Packet_Version, BitConverter.GetBytes(Version)); protocol.WritePacket(header, Packet_EditTime, BitConverter.GetBytes(EditTime.ToBinary())); protocol.WritePacket(header, Packet_Archived, BitConverter.GetBytes(Archived)); protocol.WritePacket(header, Packet_FileKey, FileKey); protocol.WritePacket(header, Packet_FileHash, FileHash); protocol.WritePacket(header, Packet_FileSize, BitConverter.GetBytes(FileSize)); protocol.WritePacket(header, Packet_FileStart, BitConverter.GetBytes(FileStart)); return protocol.WriteFinish(); } }
/*#if DEBUG public void SignUpdate(G2Protocol protocol) { // public/private key byte[] safeKey = Convert.FromBase64String("GEFrq6zCbCVN3APcabDmKFUt/VHswKV0RKc4uRgy5XrrdQPgOXNhhJCnO0bVFREeAuURFJKFsLcZbwSXTUL1xKZeukavEdCpGj1IjuUjkixDk/HEeNfwT5nZm8wUB/bWEEUC++W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hG9pq2Q+JjwYUmArHuEBBscXgJsaDmmO+ks="); // password protected GetTextDialog getpass = new GetTextDialog("Sign Update", "Enter private key password", ""); getpass.ResultBox.UseSystemPasswordChar = true; getpass.ShowDialog(); byte[] password = Utilities.GetPasswordKey(getpass.ResultBox.Text, new byte[] { 0x32, 0x12 }); // decrypt - turn into xml safeKey = Utilities.DecryptBytes(safeKey, safeKey.Length, password); RSACryptoServiceProvider JMG_KEY = new RSACryptoServiceProvider() ; JMG_KEY.FromXmlString(UTF8Encoding.UTF8.GetString(safeKey)); lock (protocol.WriteSection) { G2Frame inside = protocol.WritePacket(null, 1, null); protocol.WritePacket(inside, Packet_Name, UTF8Encoding.UTF8.GetBytes(Name)); protocol.WritePacket(inside, Packet_Key, Key); protocol.WritePacket(inside, Packet_Size, CompactNum.GetBytes(Size)); protocol.WritePacket(inside, Packet_Hash, Hash); protocol.WritePacket(inside, Packet_Notes, UTF8Encoding.UTF8.GetBytes(Notes)); protocol.WritePacket(inside, Packet_Beginning, Beginning); protocol.WritePacket(inside, Packet_DottedVersion, UTF8Encoding.UTF8.GetBytes(DottedVersion)); protocol.WritePacket(inside, Packet_SequentialVersion, CompactNum.GetBytes(SequentialVersion)); Embedded = protocol.WriteFinish(); } Signature = JMG_KEY.SignData(Embedded, new SHA1CryptoServiceProvider()); } #endif*/ public override byte[] Encode(G2Protocol protocol) { Debug.Assert(Signature != null); Debug.Assert(Embedded != null); lock (protocol.WriteSection) { G2Frame ouside = protocol.WritePacket(null, IdentityPacket.Update, Embedded); protocol.WritePacket(ouside, Packet_Signature, Signature); return protocol.WriteFinish(); } }
public override byte[] Encode(G2Protocol protocol) { lock (protocol.WriteSection) { G2Frame link = protocol.WritePacket(null, TrustPacket.LinkData, null); protocol.WritePacket(link, Packet_Project, BitConverter.GetBytes(Project)); protocol.WritePacket(link, Packet_Target, Target); protocol.WritePacket(link, Packet_Uplink, BitConverter.GetBytes(Uplink)); if(Title != null) protocol.WritePacket(link, Packet_Title, UTF8Encoding.UTF8.GetBytes(Title)); return protocol.WriteFinish(); } }
public override byte[] Encode(G2Protocol protocol) { lock (protocol.WriteSection) { G2Frame kr = protocol.WritePacket(null, CommPacket.KeyRequest, null); if (Encryption != null) { protocol.WritePacket(kr, Packet_Encryption, UTF8Encoding.UTF8.GetBytes(Encryption)); protocol.WritePacket(kr, Packet_Key, Key); protocol.WritePacket(kr, Packet_IV, IV); } return protocol.WriteFinish(); } }
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(); } }
public override byte[] Encode(G2Protocol protocol) { lock (protocol.WriteSection) { G2Frame update = protocol.WritePacket(null, CommPacket.ProxyUpdate, null); Proxy.WritePacket(protocol, update, Packet_Proxy); return protocol.WriteFinish(); } }
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(); } }
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(); } }
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(); } }
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(); } }
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(); } }
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(); } }
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(); } }