public override byte[] Encode(G2Protocol protocol) { lock (protocol.WriteSection) { G2Frame saved = protocol.WritePacket(null, Name, null); Contact.WritePacket(protocol, saved, Packet_Contact); protocol.WritePacket(saved, Packet_LastSeen, BitConverter.GetBytes(LastSeen.ToBinary())); protocol.WritePacket(saved, Packet_Bootstrap, BitConverter.GetBytes(Bootstrap)); 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 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 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()); } }
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()); } }
public override byte[] Encode(G2Protocol protocol) { lock (protocol.WriteSection) { G2Frame data = protocol.WritePacket(null, SyncPacket.ServiceData, null); protocol.WritePacket(data, Packet_Date, BitConverter.GetBytes(Date.ToBinary())); foreach (PatchTag tag in Tags) { protocol.WritePacket(data, Packet_Tag, tag.ToBytes()); } 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 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 block = protocol.WritePacket(null, PlanPacket.Block, null); protocol.WritePacket(block, Packet_ProjectID, BitConverter.GetBytes(ProjectID)); protocol.WritePacket(block, Packet_Title, UTF8Encoding.UTF8.GetBytes(Title)); protocol.WritePacket(block, Packet_StartTime, BitConverter.GetBytes(StartTime.ToBinary())); protocol.WritePacket(block, Packet_EndTime, BitConverter.GetBytes(EndTime.ToBinary())); protocol.WritePacket(block, Packet_Description, UTF8Encoding.UTF8.GetBytes(Description)); protocol.WritePacket(block, Packet_Scope, BitConverter.GetBytes(Scope)); protocol.WritePacket(block, Packet_Unique, BitConverter.GetBytes(Unique)); return(protocol.WriteFinish()); } }
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()); } }
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 cache = protocol.WritePacket(null, PacketType, null); protocol.WritePacket(cache, Packet_Address, UTF8Encoding.UTF8.GetBytes(Address)); protocol.WritePacket(cache, Packet_AccessKey, AccessKey); if (SaveTimeInfo) { protocol.WritePacket(cache, Packet_LastSeen, BitConverter.GetBytes(LastSeen.ToBinary())); protocol.WritePacket(cache, Packet_LastTried, BitConverter.GetBytes(LastTried.ToBinary())); } return(protocol.WriteFinish()); } }
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()); } }
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()); } }
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()); } }
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()); } }
public override byte[] Encode(G2Protocol protocol) { lock (protocol.WriteSection) { G2Frame status = protocol.WritePacket(null, ChatPacket.Status, null); int offset = 0; byte[] buffer = new byte[ActiveRooms.Count * 8]; foreach (UInt64 id in ActiveRooms) { BitConverter.GetBytes(id).CopyTo(buffer, offset); offset += 8; } protocol.WritePacket(status, Packet_Active, buffer); return(protocol.WriteFinish()); } }
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)); } }
public override byte[] Encode(G2Protocol protocol) { lock (protocol.WriteSection) { G2Frame settings = protocol.WritePacket(null, IdentityPacket.OperationSettings, null); protocol.WritePacket(settings, Packet_Operation, UTF8Encoding.UTF8.GetBytes(Operation)); protocol.WritePacket(settings, Packet_UserName, UTF8Encoding.UTF8.GetBytes(UserName)); protocol.WritePacket(settings, Packet_TcpPort, BitConverter.GetBytes(TcpPort)); protocol.WritePacket(settings, Packet_UdpPort, BitConverter.GetBytes(UdpPort)); protocol.WritePacket(settings, Packet_Location, UTF8Encoding.UTF8.GetBytes(Location)); protocol.WritePacket(settings, Packet_AwayMsg, UTF8Encoding.UTF8.GetBytes(AwayMessage)); protocol.WritePacket(settings, Packet_FileKey, FileKey); protocol.WritePacket(settings, Packet_OpKey, OpKey); protocol.WritePacket(settings, Packet_OpAccess, BitConverter.GetBytes((byte)OpAccess)); protocol.WritePacket(settings, Packet_SecurityLevel, BitConverter.GetBytes((int)Security)); if (GlobalIM) { protocol.WritePacket(settings, Packet_GlobalIM, null); } if (Invisible) { protocol.WritePacket(settings, Packet_Invisible, null); } RSAParameters rsa = KeyPair.ExportParameters(true); G2Frame key = protocol.WritePacket(settings, Packet_KeyPair, null); protocol.WritePacket(key, Key_D, rsa.D); protocol.WritePacket(key, Key_DP, rsa.DP); protocol.WritePacket(key, Key_DQ, rsa.DQ); protocol.WritePacket(key, Key_Exponent, rsa.Exponent); protocol.WritePacket(key, Key_InverseQ, rsa.InverseQ); protocol.WritePacket(key, Key_Modulus, rsa.Modulus); protocol.WritePacket(key, Key_P, rsa.P); protocol.WritePacket(key, Key_Q, rsa.Q); 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 override byte[] Encode(G2Protocol protocol) { lock (protocol.WriteSection) { G2Frame task = protocol.WritePacket(null, PlanPacket.Item, null); protocol.WritePacket(task, Packet_Ident, BitConverter.GetBytes(Ident)); protocol.WritePacket(task, Packet_Project, BitConverter.GetBytes(Project)); protocol.WritePacket(task, Packet_BranchUp, BitConverter.GetBytes(BranchUp)); protocol.WritePacket(task, Packet_Title, UTF8Encoding.UTF8.GetBytes(Title)); protocol.WritePacket(task, Packet_Start, BitConverter.GetBytes(Start.ToBinary())); protocol.WritePacket(task, Packet_End, BitConverter.GetBytes(End.ToBinary())); protocol.WritePacket(task, Packet_Desc, UTF8Encoding.UTF8.GetBytes(Description)); protocol.WritePacket(task, Packet_HoursCompleted, BitConverter.GetBytes(HoursCompleted)); protocol.WritePacket(task, Packet_HoursTotal, BitConverter.GetBytes(HoursTotal)); 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 gn = protocol.WritePacket(null, RootPacket.Network, InternalData); protocol.WritePacket(gn, Packet_SourceID, BitConverter.GetBytes(SourceID)); protocol.WritePacket(gn, Packet_ClientID, BitConverter.GetBytes(ClientID)); if (ToAddress != null) { ToAddress.WritePacket(protocol, gn, Packet_To); } if (FromAddress != null) { FromAddress.WritePacket(protocol, gn, Packet_From); } return(protocol.WriteFinish()); } }
public override byte[] Encode(G2Protocol protocol) { lock (protocol.WriteSection) { G2Frame tunnel = protocol.WritePacket(null, RootPacket.Tunnel, Payload); protocol.WritePacket(tunnel, Packet_Source, Source.ToBytes()); protocol.WritePacket(tunnel, Packet_Target, Target.ToBytes()); if (SourceServer != null) { SourceServer.WritePacket(protocol, tunnel, Packet_SourceServer); } if (TargetServer != null) { TargetServer.WritePacket(protocol, tunnel, Packet_TargetServer); } return(protocol.WriteFinish()); } }
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()); } }
public override byte[] Encode(G2Protocol protocol) { lock (protocol.WriteSection) { G2Frame pr = protocol.WritePacket(null, NetworkPacket.ProxyRequest, null); protocol.WritePacket(pr, Packet_Source, BitConverter.GetBytes(SenderID)); if (Type == ProxyType.ClientBlocked) { protocol.WritePacket(pr, Packet_Blocked, null); } else if (Type == ProxyType.ClientNAT) { protocol.WritePacket(pr, Packet_NAT, null); } // network packet InternalData = protocol.WriteFinish(); return(base.Encode(protocol)); } }
public override byte[] Encode(G2Protocol protocol) { lock (protocol.WriteSection) { // ping packet G2Frame pi = protocol.WritePacket(null, NetworkPacket.Ping, BitConverter.GetBytes(Ident)); if (Source != null) { Source.WritePacket(protocol, pi, Packet_Source); } if (RemoteIP != null) { protocol.WritePacket(pi, Packet_RemoteIP, RemoteIP.GetAddressBytes()); } // network packet InternalData = protocol.WriteFinish(); return(base.Encode(protocol)); } }
public new 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); BitConverter.GetBytes(TcpPort).CopyTo(payload, 12); G2Frame address = protocol.WritePacket(root, name, payload); protocol.WritePacket(address, Packet_IP, IP.GetAddressBytes()); if (TunnelServer != null) { TunnelServer.WritePacket(protocol, address, Packet_Server); } if (TunnelClient != null) { protocol.WritePacket(address, Packet_Client, TunnelClient.ToBytes()); } }
public override byte[] Encode(G2Protocol protocol) { lock (protocol.WriteSection) { G2Frame pa = protocol.WritePacket(null, NetworkPacket.ProxyAck, null); Source.WritePacket(protocol, pa, Packet_Source); if (Accept) { protocol.WritePacket(pa, Packet_Accept, null); } foreach (DhtContact contact in ContactList) { contact.WritePacket(protocol, pa, Packet_Contacts); } // network packet InternalData = protocol.WriteFinish(); return(base.Encode(protocol)); } }