private void ConfirmXferPacketHandler(Packet packet, Simulator simulator) { ConfirmXferPacketPacket confirm = (ConfirmXferPacketPacket)packet; // Building a new UUID every time an ACK is received for an upload is a horrible // thing, but this whole Xfer system is horrible LLUUID transferID = new LLUUID(confirm.XferID.ID); Transfer transfer; AssetUpload upload = null; if (Transfers.TryGetValue(transferID, out transfer)) { upload = (AssetUpload)transfer; //Client.DebugLog(String.Format("ACK for upload {0} of asset type {1} ({2}/{3})", // upload.AssetID.ToString(), upload.Type, upload.Transferred, upload.Size)); if (OnUploadProgress != null) { try { OnUploadProgress(upload); } catch (Exception e) { Client.Log(e.ToString(), Helpers.LogLevel.Error); } } if (upload.Transferred < upload.Size) { SendNextUploadPacket(upload); } } }
private void ConfirmXferPacketHandler(Packet packet, LLAgent agent) { ConfirmXferPacketPacket confirm = (ConfirmXferPacketPacket)packet; XferDownload download; if (currentDownloads.TryGetValue(confirm.XferID.ID, out download)) { // Send the next packet SendXferPacketPacket xfer = new SendXferPacketPacket(); xfer.XferID.ID = confirm.XferID.ID; int bytesRemaining = (int)(download.AssetData.Length - (download.PacketNum * 1000)); if (bytesRemaining > 1000) { xfer.DataPacket.Data = new byte[1000]; Buffer.BlockCopy(download.AssetData, (int)download.PacketNum * 1000, xfer.DataPacket.Data, 0, 1000); xfer.XferID.Packet = download.PacketNum++; } else { // Last packet xfer.DataPacket.Data = new byte[bytesRemaining]; Buffer.BlockCopy(download.AssetData, (int)download.PacketNum * 1000, xfer.DataPacket.Data, 0, bytesRemaining); xfer.XferID.Packet = download.PacketNum | LAST_PACKET_MARKER; lock (currentDownloads) currentDownloads.Remove(confirm.XferID.ID); m_log.Debug("Completing xfer download for: " + download.Filename); } m_udp.SendPacket(agent, xfer, ThrottleCategory.Asset, false); } }
private void SendConfirmXferPacket(ulong xferID, uint packetNum) { ConfirmXferPacketPacket confirm = new ConfirmXferPacketPacket(); confirm.XferID.ID = xferID; confirm.XferID.Packet = packetNum; Client.Network.SendPacket(confirm); }
private void ConfirmXferPacketCallbackHandler(Packet packet, Simulator simulator) { #if DEBUG_PACKETS slClient.DebugLog(packet); #endif ConfirmXferPacketPacket reply = (ConfirmXferPacketPacket)packet; curUploadRequest.ConfirmXferPacket(reply.XferID.ID, reply.XferID.Packet); }
private void ConfirmXferPacketCallbackHandler(Packet packet, Simulator simulator) { #if DEBUG_PACKETS Console.WriteLine(packet); #endif ConfirmXferPacketPacket reply = (ConfirmXferPacketPacket)packet; curUploadRequest.ConfirmXferPacket(reply.XferID.ID, reply.XferID.Packet); }
private void ConfirmXferPacketCallbackHandler(Packet packet, Simulator simulator) { #if DEBUG_PACKETS slClient.Log(packet.ToString(), Helpers.LogLevel.Info); #endif ConfirmXferPacketPacket reply = (ConfirmXferPacketPacket)packet; if (curUploadRequest != null) { curUploadRequest.ConfirmXferPacket(reply.XferID.ID, reply.XferID.Packet); } }
public void HandleXferPacket(SendXferPacketPacket xferPacket) { lock (this.transactions) { foreach (AssetTransaction trans in this.transactions.Values) { if (trans.XferID == xferPacket.XferID.ID) { if (trans.Asset.Data.Length > 1) { byte[] newArray = new byte[trans.Asset.Data.Length + xferPacket.DataPacket.Data.Length]; Array.Copy(trans.Asset.Data, 0, newArray, 0, trans.Asset.Data.Length); Array.Copy(xferPacket.DataPacket.Data, 0, newArray, trans.Asset.Data.Length, xferPacket.DataPacket.Data.Length); trans.Asset.Data = newArray; } else { byte[] newArray = new byte[xferPacket.DataPacket.Data.Length - 4]; Array.Copy(xferPacket.DataPacket.Data, 4, newArray, 0, xferPacket.DataPacket.Data.Length - 4); trans.Asset.Data = newArray; } if ((xferPacket.XferID.Packet & 2147483648) != 0) { //end of transfer trans.UploadComplete = true; AssetUploadCompletePacket response = new AssetUploadCompletePacket(); response.AssetBlock.Type = trans.Asset.Type; response.AssetBlock.Success = true; response.AssetBlock.UUID = trans.TransactionID.Combine(this.ourClient.SecureSessionID); this.ourClient.OutPacket(response); m_assetCache.AddAsset(trans.Asset); //check if we should add it to inventory if (trans.AddToInventory) { // m_assetCache.AddAsset(trans.Asset); m_inventoryCache.AddNewInventoryItem(this.ourClient, trans.InventFolder, trans.Asset); } } break; } } } ConfirmXferPacketPacket confirmXfer = new ConfirmXferPacketPacket(); confirmXfer.XferID.ID = xferPacket.XferID.ID; confirmXfer.XferID.Packet = xferPacket.XferID.Packet; this.ourClient.OutPacket(confirmXfer); }
private void SendXferPacketHandler(Packet packet, LLAgent agent) { SendXferPacketPacket xfer = (SendXferPacketPacket)packet; uint packetID = xfer.XferID.Packet & ~LAST_PACKET_MARKER; bool lastPacket = (xfer.XferID.Packet & LAST_PACKET_MARKER) != 0; Asset asset; if (currentUploads.TryGetValue(xfer.XferID.ID, out asset)) { if (packetID == 0) { uint size = Utils.BytesToUInt(xfer.DataPacket.Data); asset.Data = new byte[size]; Buffer.BlockCopy(xfer.DataPacket.Data, 4, asset.Data, 0, xfer.DataPacket.Data.Length - 4); // Confirm the first upload packet ConfirmXferPacketPacket confirm = new ConfirmXferPacketPacket(); confirm.XferID.ID = xfer.XferID.ID; confirm.XferID.Packet = xfer.XferID.Packet; m_udp.SendPacket(agent, confirm, ThrottleCategory.Asset, false); } else if (asset.Data != null) { AssetType type = (AssetType)LLUtil.ContentTypeToLLAssetType(asset.ContentType); Buffer.BlockCopy(xfer.DataPacket.Data, 0, asset.Data, (int)packetID * 1000, xfer.DataPacket.Data.Length); // Confirm this upload packet ConfirmXferPacketPacket confirm = new ConfirmXferPacketPacket(); confirm.XferID.ID = xfer.XferID.ID; confirm.XferID.Packet = xfer.XferID.Packet; m_udp.SendPacket(agent, confirm, ThrottleCategory.Asset, false); if (lastPacket) { // Asset upload finished lock (currentUploads) currentUploads.Remove(xfer.XferID.ID); if (type != AssetType.LSLBytecode) { // Store the uploaded asset m_log.DebugFormat("Storing uploaded asset {0} ({1})", asset.ID, asset.ContentType); if (!m_assets.StoreAsset(asset)) { m_log.ErrorFormat("Failed to store uploaded asset {0} ({1})", asset.ID, asset.ContentType); } } else { m_log.Debug("Ignoring LSL bytecode upload " + asset.ID); } AssetUploadCompletePacket complete = new AssetUploadCompletePacket(); complete.AssetBlock.Success = true; complete.AssetBlock.Type = (sbyte)type; complete.AssetBlock.UUID = asset.ID; m_udp.SendPacket(agent, complete, ThrottleCategory.Asset, false); } } else { m_log.Error("Received SendXferPacket #" + xfer.XferID.Packet + " when asset.AssetData is still null"); } } else { m_log.Debug("Received a SendXferPacket for an unknown upload"); } }
private void SendXferPacketHandler(Packet packet, LLAgent agent) { SendXferPacketPacket xfer = (SendXferPacketPacket)packet; uint packetID = xfer.XferID.Packet & ~LAST_PACKET_MARKER; bool lastPacket = (xfer.XferID.Packet & LAST_PACKET_MARKER) != 0; Asset asset; if (currentUploads.TryGetValue(xfer.XferID.ID, out asset)) { if (packetID == 0) { uint size = Utils.BytesToUInt(xfer.DataPacket.Data); asset.Data = new byte[size]; Buffer.BlockCopy(xfer.DataPacket.Data, 4, asset.Data, 0, xfer.DataPacket.Data.Length - 4); // Confirm the first upload packet ConfirmXferPacketPacket confirm = new ConfirmXferPacketPacket(); confirm.XferID.ID = xfer.XferID.ID; confirm.XferID.Packet = xfer.XferID.Packet; m_udp.SendPacket(agent, confirm, ThrottleCategory.Asset, false); } else if (asset.Data != null) { AssetType type = (AssetType)LLUtil.ContentTypeToLLAssetType(asset.ContentType); Buffer.BlockCopy(xfer.DataPacket.Data, 0, asset.Data, (int)packetID * 1000, xfer.DataPacket.Data.Length); // Confirm this upload packet ConfirmXferPacketPacket confirm = new ConfirmXferPacketPacket(); confirm.XferID.ID = xfer.XferID.ID; confirm.XferID.Packet = xfer.XferID.Packet; m_udp.SendPacket(agent, confirm, ThrottleCategory.Asset, false); if (lastPacket) { // Asset upload finished lock (currentUploads) currentUploads.Remove(xfer.XferID.ID); if (type != AssetType.LSLBytecode) { // Store the uploaded asset m_log.DebugFormat("Storing uploaded asset {0} ({1})", asset.ID, asset.ContentType); if (!m_assets.StoreAsset(asset)) m_log.ErrorFormat("Failed to store uploaded asset {0} ({1})", asset.ID, asset.ContentType); } else { m_log.Debug("Ignoring LSL bytecode upload " + asset.ID); } AssetUploadCompletePacket complete = new AssetUploadCompletePacket(); complete.AssetBlock.Success = true; complete.AssetBlock.Type = (sbyte)type; complete.AssetBlock.UUID = asset.ID; m_udp.SendPacket(agent, complete, ThrottleCategory.Asset, false); } } else { m_log.Error("Received SendXferPacket #" + xfer.XferID.Packet + " when asset.AssetData is still null"); } } else { m_log.Debug("Received a SendXferPacket for an unknown upload"); } }
/*private bool UploadStart(CapsRequest capReq, CapsStage stage) { Console.WriteLine(capReq.ToString()); Console.WriteLine("drrr"); Console.WriteLine(capReq.Request.ToString()); //RequestXferPacket requestRecived = (RequestXferPacket)Packet.BuildPacket("RequestXfer", (OpenMetaverse.StructuredData.LLSDMap)capReq.Response); return false; }*/ /*private Packet OutDialogFromViewer(Packet packet, IPEndPoint sim) { ScriptDialogReplyPacket DialogFromViewer = (ScriptDialogReplyPacket)packet; if (handeledViewerOutput(Utils.BytesToString(DialogFromViewer.Data.ButtonLabel).Trim().ToLower()) == "die") return null; return packet; } public string handeledViewerOutput(string mssage) { if (mssage.ToLower().Contains(this.brand.ToLower() + "-on")) { Enabled = true; //form.setBox(Enabled); SendUserAlert("AwesomeSauce Enabled"); return "die"; } else if (mssage.ToLower().Contains(this.brand.ToLower() + "-off")) { Enabled = false; SendUserAlert("AwesomeSauce Disabled"); //form.setBox(Enabled); return "die"; } else if (mssage.ToLower().Contains(this.brand.ToLower() + "-help")) { SayToUser("Thanks for using the AwesomeSauce script text remover system :).\n" + "To make it work, just enable it and upload scripts in no mono\n"+ "You have to use DisableCaps.dll to UpdateScriptTask, and UpdateScriptAgent. (put them into the dropped side, and tp or relog)\n"+ "Then, just add \"//(COMPILE_PROTECTED)\"at the top of your script, and the rest is automatic.\n"+ "Your script wil be saved to your hard drive, and the server script will contain the top three lines of it only"+ "(maybe put copywright comments there)"); } else if (mssage.ToLower().Contains(this.brand.ToLower() + "-about")) { SayToUser("This program was made by LordGregGreg for the purpose of allowing\nscripts to be uploaded without their text.\nMight be good for securty if you don't trust sl to keep your perms right"); SayToUser("Special Thanks to \"Philip Linden\" (yeah, thats not his actual sl name)\n" + "and Darling Brody for ideas and motivation\n"+ "and the OpenMetaverse project, and all it's contributors."); } else if (mssage.ToLower().Contains(this.brand.ToLower() + "-")) { SendUserDialog(this.brand + "", "AwesomeSauce", "Messenger", "What do you want me to do?", new string[] { this.brand+"-ON", this.brand+"-OFF", this.brand+"-HELP", this.brand+"-ABOUT" }); return "die"; } return "go"; } private Packet OutChatFromViewerHandler(Packet packet, IPEndPoint sim) { ChatFromViewerPacket ChatFromViewer = (ChatFromViewerPacket)packet; string message = Utils.BytesToString(ChatFromViewer.ChatData.Message); if (handeledViewerOutput(message) == "die") { return null; } return packet; }*/ private Packet ClientSentThisScript(Packet packet, IPEndPoint sim) { if (packet.Header.Resent) return packet; SendXferPacketPacket sxpp = (SendXferPacketPacket)packet; int start = 0; if (currentuploads.ContainsKey(sxpp.XferID.ID)) { if (currentuploads[sxpp.XferID.ID].proxySending) { Console.WriteLine("we are already sending this script, dont need its data"); return null; } if (currentuploads[sxpp.XferID.ID].curentdatalenght==0) { Console.WriteLine("This was the first packet"); byte [] temp = new byte[sxpp.DataPacket.Data.Length]; Buffer.BlockCopy(sxpp.DataPacket.Data,4,temp,0,sxpp.DataPacket.Data.Length-4); string script = Utils.BytesToString(temp); string[] lines = script.Split('\n'); if(lines[0].Contains("(COMPILE_PROTECTED)")) { form.log("We got a script meant to be protected!", System.Drawing.Color.DarkBlue, System.Drawing.Color.Black); frame.SendUserAlert("Uploading Script Protected"); start = 4; } else { form.log("This Script was not meant to be protected ABANDON SHIP!", System.Drawing.Color.DarkBlue, System.Drawing.Color.Black); currentuploads.Remove(sxpp.XferID.ID); if(OutgoingXfers.ContainsKey(sxpp.XferID.ID)) { OutgoingXfers.Remove(sxpp.XferID.ID); } return packet; } } form.log("We got a script packet sent from client with the actual stuff, get it!", System.Drawing.Color.DarkBlue, System.Drawing.Color.Black); Buffer.BlockCopy(sxpp.DataPacket.Data, start, currentuploads[sxpp.XferID.ID].oldscriptdata, currentuploads[sxpp.XferID.ID].curentdatalenght, sxpp.DataPacket.Data.Length-start); currentuploads[sxpp.XferID.ID].curentdatalenght += sxpp.DataPacket.Data.Length-start; if ((sxpp.XferID.Packet & 0x80000000) != 0) { form.log("we got the final packet sent from viewer to server, going to start upload now", System.Drawing.Color.Blue, System.Drawing.Color.Black); currentuploads[sxpp.XferID.ID].oldmaxsize = currentuploads[sxpp.XferID.ID].curentdatalenght; if (requests2Process.ContainsKey(sxpp.XferID.ID)) { ProcessRequest(requests2Process[sxpp.XferID.ID]); requests2Process.Remove(sxpp.XferID.ID); } //last packet } ConfirmXferPacketPacket fakeConf = new ConfirmXferPacketPacket(); fakeConf.XferID.ID = sxpp.XferID.ID; fakeConf.XferID.Packet = sxpp.XferID.Packet; proxy.InjectPacket(fakeConf, Direction.Incoming); return null;//block the packets the cliet is sending } //Console.WriteLine("Not one we are loking for"); return packet; }
public void HandleXferPacket(SendXferPacketPacket xferPacket) { lock (this.transactions) { foreach (AssetTransaction trans in this.transactions.Values) { if (trans.XferID == xferPacket.XferID.ID) { if (trans.Asset.Data.Length > 1) { byte[] newArray = new byte[trans.Asset.Data.Length + xferPacket.DataPacket.Data.Length]; Array.Copy(trans.Asset.Data, 0, newArray, 0, trans.Asset.Data.Length); Array.Copy(xferPacket.DataPacket.Data, 0, newArray, trans.Asset.Data.Length, xferPacket.DataPacket.Data.Length); trans.Asset.Data = newArray; } else { byte[] newArray = new byte[xferPacket.DataPacket.Data.Length - 4]; Array.Copy(xferPacket.DataPacket.Data, 4, newArray, 0, xferPacket.DataPacket.Data.Length - 4); trans.Asset.Data = newArray; } if ((xferPacket.XferID.Packet & 2147483648) != 0) { //end of transfer trans.UploadComplete = true; AssetUploadCompletePacket response = new AssetUploadCompletePacket(); response.AssetBlock.Type = trans.Asset.Type; response.AssetBlock.Success = true; response.AssetBlock.UUID = trans.TransactionID.Combine(this.ourClient.SecureSessionID); this.ourClient.OutPacket(response); m_assetCache.AddAsset(trans.Asset); //check if we should add it to inventory if (trans.AddToInventory) { // m_assetCache.AddAsset(trans.Asset); m_inventoryCache.AddNewInventoryItem(this.ourClient, trans.InventFolder, trans.Asset); } } break; } } } ConfirmXferPacketPacket confirmXfer = new ConfirmXferPacketPacket(); confirmXfer.XferID.ID = xferPacket.XferID.ID; confirmXfer.XferID.Packet = xferPacket.XferID.Packet; this.ourClient.OutPacket(confirmXfer); }
private Packet InConfirmXferPacketHandler(Packet packet, IPEndPoint sim) { if (Enabled) { ConfirmXferPacketPacket ConfirmXferPacket = (ConfirmXferPacketPacket)packet; ulong XferID = ConfirmXferPacket.XferID.ID; if (OutgoingXfers.ContainsKey(XferID)) { // This is one of our Xfers //SayToUser("sending the script packets..."); //OutgoingXfers[XferID].PacketIndex++; //form.setProgress(OutgoingXfers[XferID].PacketIndex++); OutgoingXfers[XferID].PacketIndex++; Console.WriteLine("progress is " + OutgoingXfers[XferID].PacketIndex + " of " + currentuploads[XferID].size.ToString()); if (OutgoingXfers[XferID].PacketIndex < (currentuploads[XferID].size)) { // Send the next packet proxy.InjectPacket(OutgoingXfers[XferID].Packets[(uint)OutgoingXfers[XferID].PacketIndex], Direction.Outgoing); } else { // Done done done //form.setProgress(curentUpload.size); Console.WriteLine("<>>Upload successful!"); /* * UpdateInventoryItemPacket p = new UpdateInventoryItemPacket(); * * CreateInventoryItemPacket create = new CreateInventoryItemPacket(); * create.AgentData = new CreateInventoryItemPacket.AgentDataBlock(); * create.AgentData.AgentID = frame.AgentID; * create.AgentData.SessionID = frame.SessionID; * create.InventoryBlock = new CreateInventoryItemPacket.InventoryBlockBlock(); * create.InventoryBlock.CallbackID = 0; // What's this? * create.InventoryBlock.FolderID = UUID.Zero; * create.InventoryBlock.TransactionID = currentuploads[XferID].uploadID; * create.InventoryBlock.NextOwnerMask = currentuploads[XferID].ownerMask; * create.InventoryBlock.Type = currentuploads[XferID].type; * create.InventoryBlock.InvType = currentuploads[XferID].type; * create.InventoryBlock.WearableType = (byte)0; * string name = "New Text Preview - Delete Me"; * * if (currentuploads[XferID].temp) * name += "-temp"; * if (currentuploads[XferID].local) * name += "-local"; * if (currentuploads[XferID].paid) * name += "-paid"; * * //name += "-t=" + curentUpload.type.ToString(); * * * create.InventoryBlock.Name = Utils.StringToBytes(name); * * * create.InventoryBlock.Description = Utils.StringToBytes(name); * * //proxy.InjectPacket(create, Direction.Outgoing); * //string filename = ""; */ /*if (trans2Item.ContainsKey(curentUpload.uploadID)) * { * filename = trans2Item[curentUpload.uploadID].ToString(); * * File.WriteAllBytes("Scripts Cache\\" + filename, curentUpload.oldscriptdata); * } * else * { * name2SaveBuffer.Add(curentUpload); * }*/ form.log("blocked " + ConfirmXferPacket.XferID.Packet.ToString() + ";", System.Drawing.Color.DarkCyan, System.Drawing.Color.Black); OutgoingXfers.Remove(XferID); currentuploads.Remove(XferID); return(null); } // Don't send this to the client //if (currentuploads.ContainsKey(XferID)) // if (currentuploads[XferID].proxySending) form.log("blocked " + ConfirmXferPacket.XferID.Packet.ToString() + ";", System.Drawing.Color.DarkCyan, System.Drawing.Color.Black); return(null); } } //form.log("we let this confirm packet go! " + packet.ToString(), System.Drawing.Color.DarkBlue, System.Drawing.Color.Black); return(packet); }
/*private bool UploadStart(CapsRequest capReq, CapsStage stage) * { * Console.WriteLine(capReq.ToString()); * Console.WriteLine("drrr"); * Console.WriteLine(capReq.Request.ToString()); * * //RequestXferPacket requestRecived = (RequestXferPacket)Packet.BuildPacket("RequestXfer", (OpenMetaverse.StructuredData.LLSDMap)capReq.Response); * * return false; * }*/ /*private Packet OutDialogFromViewer(Packet packet, IPEndPoint sim) * { * ScriptDialogReplyPacket DialogFromViewer = (ScriptDialogReplyPacket)packet; * if (handeledViewerOutput(Utils.BytesToString(DialogFromViewer.Data.ButtonLabel).Trim().ToLower()) == "die") * return null; * * return packet; * } * * public string handeledViewerOutput(string mssage) * { * * if (mssage.ToLower().Contains(this.brand.ToLower() + "-on")) * { * Enabled = true; * //form.setBox(Enabled); * * SendUserAlert("AwesomeSauce Enabled"); * return "die"; * } * else if (mssage.ToLower().Contains(this.brand.ToLower() + "-off")) * { * Enabled = false; * * SendUserAlert("AwesomeSauce Disabled"); * //form.setBox(Enabled); * return "die"; * } * else if (mssage.ToLower().Contains(this.brand.ToLower() + "-help")) * { * SayToUser("Thanks for using the AwesomeSauce script text remover system :).\n" + "To make it work, just enable it and upload scripts in no mono\n"+ * "You have to use DisableCaps.dll to UpdateScriptTask, and UpdateScriptAgent. (put them into the dropped side, and tp or relog)\n"+ * "Then, just add \"//(COMPILE_PROTECTED)\"at the top of your script, and the rest is automatic.\n"+ * "Your script wil be saved to your hard drive, and the server script will contain the top three lines of it only"+ * "(maybe put copywright comments there)"); * } * else if (mssage.ToLower().Contains(this.brand.ToLower() + "-about")) * { * SayToUser("This program was made by LordGregGreg for the purpose of allowing\nscripts to be uploaded without their text.\nMight be good for securty if you don't trust sl to keep your perms right"); * SayToUser("Special Thanks to \"Philip Linden\" (yeah, thats not his actual sl name)\n" + * "and Darling Brody for ideas and motivation\n"+ * "and the OpenMetaverse project, and all it's contributors."); * * } * else if (mssage.ToLower().Contains(this.brand.ToLower() + "-")) * { * SendUserDialog(this.brand + "", "AwesomeSauce", "Messenger", "What do you want me to do?", new string[] { this.brand+"-ON", this.brand+"-OFF", this.brand+"-HELP", this.brand+"-ABOUT" }); * return "die"; * } * * return "go"; * } * private Packet OutChatFromViewerHandler(Packet packet, IPEndPoint sim) * { * ChatFromViewerPacket ChatFromViewer = (ChatFromViewerPacket)packet; * string message = Utils.BytesToString(ChatFromViewer.ChatData.Message); * if (handeledViewerOutput(message) == "die") * { * return null; * } * return packet; * * }*/ private Packet ClientSentThisScript(Packet packet, IPEndPoint sim) { if (packet.Header.Resent) { return(packet); } SendXferPacketPacket sxpp = (SendXferPacketPacket)packet; int start = 0; if (currentuploads.ContainsKey(sxpp.XferID.ID)) { if (currentuploads[sxpp.XferID.ID].proxySending) { Console.WriteLine("we are already sending this script, dont need its data"); return(null); } if (currentuploads[sxpp.XferID.ID].curentdatalenght == 0) { Console.WriteLine("This was the first packet"); byte [] temp = new byte[sxpp.DataPacket.Data.Length]; Buffer.BlockCopy(sxpp.DataPacket.Data, 4, temp, 0, sxpp.DataPacket.Data.Length - 4); string script = Utils.BytesToString(temp); string[] lines = script.Split('\n'); if (lines[0].Contains("(COMPILE_PROTECTED)")) { form.log("We got a script meant to be protected!", System.Drawing.Color.DarkBlue, System.Drawing.Color.Black); frame.SendUserAlert("Uploading Script Protected"); start = 4; } else { form.log("This Script was not meant to be protected ABANDON SHIP!", System.Drawing.Color.DarkBlue, System.Drawing.Color.Black); currentuploads.Remove(sxpp.XferID.ID); if (OutgoingXfers.ContainsKey(sxpp.XferID.ID)) { OutgoingXfers.Remove(sxpp.XferID.ID); } return(packet); } } form.log("We got a script packet sent from client with the actual stuff, get it!", System.Drawing.Color.DarkBlue, System.Drawing.Color.Black); Buffer.BlockCopy(sxpp.DataPacket.Data, start, currentuploads[sxpp.XferID.ID].oldscriptdata, currentuploads[sxpp.XferID.ID].curentdatalenght, sxpp.DataPacket.Data.Length - start); currentuploads[sxpp.XferID.ID].curentdatalenght += sxpp.DataPacket.Data.Length - start; if ((sxpp.XferID.Packet & 0x80000000) != 0) { form.log("we got the final packet sent from viewer to server, going to start upload now", System.Drawing.Color.Blue, System.Drawing.Color.Black); currentuploads[sxpp.XferID.ID].oldmaxsize = currentuploads[sxpp.XferID.ID].curentdatalenght; if (requests2Process.ContainsKey(sxpp.XferID.ID)) { ProcessRequest(requests2Process[sxpp.XferID.ID]); requests2Process.Remove(sxpp.XferID.ID); } //last packet } ConfirmXferPacketPacket fakeConf = new ConfirmXferPacketPacket(); fakeConf.XferID.ID = sxpp.XferID.ID; fakeConf.XferID.Packet = sxpp.XferID.Packet; proxy.InjectPacket(fakeConf, Direction.Incoming); return(null);//block the packets the cliet is sending } //Console.WriteLine("Not one we are loking for"); return(packet); }
protected void SendConfirmXfer(uint PacketID) { ConfirmXferPacketPacket newPack = new ConfirmXferPacketPacket(); newPack.XferID.ID = XferID; newPack.XferID.Packet = PacketID; newPack.Header.Zerocoded = true; //OutPacket(newPack, ThrottleOutPacketType.Asset); proxy.InjectPacket(newPack, Direction.Incoming); }
void SendXferPacketHandler(Packet packet, Agent agent) { SendXferPacketPacket xfer = (SendXferPacketPacket)packet; Asset asset; if (CurrentUploads.TryGetValue(xfer.XferID.ID, out asset)) { if (asset.AssetData == null) { if (xfer.XferID.Packet != 0) { Logger.Log(String.Format("Received Xfer packet {0} before the first packet!", xfer.XferID.Packet), Helpers.LogLevel.Error); return; } uint size = Utils.BytesToUInt(xfer.DataPacket.Data); asset.AssetData = new byte[size]; Buffer.BlockCopy(xfer.DataPacket.Data, 4, asset.AssetData, 0, xfer.DataPacket.Data.Length - 4); // Confirm the first upload packet ConfirmXferPacketPacket confirm = new ConfirmXferPacketPacket(); confirm.XferID.ID = xfer.XferID.ID; confirm.XferID.Packet = xfer.XferID.Packet; server.UDP.SendPacket(agent.AgentID, confirm, PacketCategory.Asset); } else { Buffer.BlockCopy(xfer.DataPacket.Data, 0, asset.AssetData, (int)xfer.XferID.Packet * 1000, xfer.DataPacket.Data.Length); // Confirm this upload packet ConfirmXferPacketPacket confirm = new ConfirmXferPacketPacket(); confirm.XferID.ID = xfer.XferID.ID; confirm.XferID.Packet = xfer.XferID.Packet; server.UDP.SendPacket(agent.AgentID, confirm, PacketCategory.Asset); if ((xfer.XferID.Packet & (uint)0x80000000) != 0) { // Asset upload finished Logger.DebugLog(String.Format("Completed Xfer upload of asset {0} ({1}", asset.AssetID, asset.AssetType)); lock (CurrentUploads) CurrentUploads.Remove(xfer.XferID.ID); StoreAsset(asset); AssetUploadCompletePacket complete = new AssetUploadCompletePacket(); complete.AssetBlock.Success = true; complete.AssetBlock.Type = (sbyte)asset.AssetType; complete.AssetBlock.UUID = asset.AssetID; server.UDP.SendPacket(agent.AgentID, complete, PacketCategory.Asset); } } } else { Logger.DebugLog("Received a SendXferPacket for an unknown upload"); } }
void SendXferPacketHandler(Packet packet, Agent agent) { SendXferPacketPacket xfer = (SendXferPacketPacket)packet; Asset asset; if (CurrentUploads.TryGetValue(xfer.XferID.ID, out asset)) { if (asset.AssetData == null) { if (xfer.XferID.Packet != 0) { Logger.Log(String.Format("Received Xfer packet {0} before the first packet!", xfer.XferID.Packet), Helpers.LogLevel.Error); return; } uint size = Utils.BytesToUInt(xfer.DataPacket.Data); asset.AssetData = new byte[size]; Buffer.BlockCopy(xfer.DataPacket.Data, 4, asset.AssetData, 0, xfer.DataPacket.Data.Length - 4); // Confirm the first upload packet ConfirmXferPacketPacket confirm = new ConfirmXferPacketPacket(); confirm.XferID.ID = xfer.XferID.ID; confirm.XferID.Packet = xfer.XferID.Packet; scene.UDP.SendPacket(agent.ID, confirm, PacketCategory.Asset); } else { Buffer.BlockCopy(xfer.DataPacket.Data, 0, asset.AssetData, (int)xfer.XferID.Packet * 1000, xfer.DataPacket.Data.Length); // Confirm this upload packet ConfirmXferPacketPacket confirm = new ConfirmXferPacketPacket(); confirm.XferID.ID = xfer.XferID.ID; confirm.XferID.Packet = xfer.XferID.Packet; scene.UDP.SendPacket(agent.ID, confirm, PacketCategory.Asset); if ((xfer.XferID.Packet & (uint)0x80000000) != 0) { // Asset upload finished Logger.DebugLog(String.Format("Completed Xfer upload of asset {0} ({1}", asset.AssetID, asset.AssetType)); lock (CurrentUploads) CurrentUploads.Remove(xfer.XferID.ID); scene.Server.Assets.StoreAsset(asset); AssetUploadCompletePacket complete = new AssetUploadCompletePacket(); complete.AssetBlock.Success = true; complete.AssetBlock.Type = (sbyte)asset.AssetType; complete.AssetBlock.UUID = asset.AssetID; scene.UDP.SendPacket(agent.ID, complete, PacketCategory.Asset); } } } else { Logger.DebugLog("Received a SendXferPacket for an unknown upload"); } }
private void SendConfirmXferPacket(ulong xferID, uint packetNum) { ConfirmXferPacketPacket confirm = new ConfirmXferPacketPacket(); confirm.XferID.ID = xferID; confirm.XferID.Packet = packetNum; Client.Network.SendPacket(confirm); }
private Packet InConfirmXferPacketHandler(Packet packet, IPEndPoint sim) { ConfirmXferPacketPacket ConfirmXferPacket = (ConfirmXferPacketPacket)packet; ulong XferID = ConfirmXferPacket.XferID.ID; if (OutgoingXfers.ContainsKey(XferID)) { // This is one of our Xfers //SayToUser("sending the script packets..."); //OutgoingXfers[XferID].PacketIndex++; form.setProgress(OutgoingXfers[XferID].PacketIndex++); Console.WriteLine("progress is " + OutgoingXfers[XferID].PacketIndex + " of " + curentUpload.size.ToString()); if (OutgoingXfers[XferID].PacketIndex < (curentUpload.size)) { // Send the next packet proxy.InjectPacket(OutgoingXfers[XferID].Packets[(uint)OutgoingXfers[XferID].PacketIndex], Direction.Outgoing); } else { // Done done done form.setProgress(curentUpload.size); Console.WriteLine("<>>Upload successful!"); if (grabbed == 1) { grabbed += 200; CreateInventoryItemPacket create = new CreateInventoryItemPacket(); create.AgentData = new CreateInventoryItemPacket.AgentDataBlock(); create.AgentData.AgentID = frame.AgentID; create.AgentData.SessionID = frame.SessionID; create.InventoryBlock = new CreateInventoryItemPacket.InventoryBlockBlock(); create.InventoryBlock.CallbackID = 0; // What's this? create.InventoryBlock.FolderID = UUID.Zero; create.InventoryBlock.TransactionID = uploadID; create.InventoryBlock.NextOwnerMask = curentUpload.ownerMask; create.InventoryBlock.Type = curentUpload.type; create.InventoryBlock.InvType = curentUpload.type; create.InventoryBlock.WearableType = (byte)0; string name = curentUpload.name; if (curentUpload.temp) { name += "-temp"; } if (curentUpload.local) { name += "-local"; } if (curentUpload.paid) { name += "-paid"; } //name += "-t=" + curentUpload.type.ToString(); create.InventoryBlock.Name = Utils.StringToBytes(name); create.InventoryBlock.Description = Utils.StringToBytes(name); proxy.InjectPacket(create, Direction.Outgoing); } OutgoingXfers.Remove(XferID); } // Don't send this to the client return(null); } return(packet); }