LIBOMV-651 Corrects issue showing incorrect hex data on UDP packets after re-importing saved sessions

LIBOMV-650 Correctly displays capability messages after import
* Fixes saving and restoring sessions and filters in WinGridProxy
* Many Changes to WinGridProxy UI, AutoScroll is no longer an option, instead the Session ListView can be sorted by the # column to have this behavior, Hex/binary data can be saved to individual files for outside processing (tiny button on bottom toolbar of Hex tab when hex has data that can be exported)
* Filter save/restore options are now on the Filters tab since thats where they are most useful
* Adds support for decoding AgentGroupDataUpdate message which OpenSim sends as an "AvatarGroupsReply"
* Updates and additional documentation in AgentManager, Simulator and ObjectManager classes
* PacketDecoder class is now static
* Removed profanity in debugging Console write
* Updates to Decoders: Decode LayerData type, Show internal Animation constant for built in animations
* Moved Message decoder to PacketDecoder class
* Add some sanity checks in GridProxy to prevent throwing an exception when a GridProxy is restarted and a viewer wasn't informed.


git-svn-id: http://libopenmetaverse.googlecode.com/svn/libopenmetaverse/trunk@3205 52acb1d6-8a22-11de-b505-999d5b087335
This commit is contained in:
Jim Radford
2009-11-03 05:32:49 +00:00
parent ce737fbbc9
commit 5cd3013890
13 changed files with 2168 additions and 1315 deletions

View File

@@ -160,8 +160,8 @@
this.richTextBox1.Name = "richTextBox1";
this.richTextBox1.Size = new System.Drawing.Size(274, 79);
this.richTextBox1.TabIndex = 25;
this.richTextBox1.Text = "Icons Courtesy of http://www.famfamfam.com/lab/icons/silk/\n\nHexbox Control \nhttp:" +
"//sourceforge.net/projects/hexbox/";
this.richTextBox1.Text = "Written by Jim Radford <jradford@npl.com>\n\nIcons Courtesy of http://www.famfamfam" +
".com/lab/icons/silk/\n\nHexbox Control \nhttp://sourceforge.net/projects/hexbox/";
//
// AboutBox1
//

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -118,7 +118,16 @@
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="contextMenuStripSessions.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>524, 17</value>
<value>555, 17</value>
</metadata>
<metadata name="contextMenuStripRemove.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 56</value>
</metadata>
<metadata name="contextMenuStripSelect.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>1104, 17</value>
</metadata>
<metadata name="contextMenuStripMark.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>750, 17</value>
</metadata>
<metadata name="imageList1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>309, 17</value>
@@ -172,31 +181,61 @@
BQAD/wUACw==
</value>
</data>
<metadata name="contextMenuStripRemove.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>185, 54</value>
</metadata>
<metadata name="contextMenuStripSelect.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 54</value>
</metadata>
<metadata name="contextMenuStripMark.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>705, 17</value>
</metadata>
<metadata name="statusStrip2.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>414, 17</value>
</metadata>
<metadata name="statusStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>116, 17</value>
</metadata>
<metadata name="statusStrip2.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>414, 17</value>
</metadata>
<metadata name="statusStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>116, 17</value>
</metadata>
<metadata name="toolStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
<metadata name="toolStripFilters.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>339, 56</value>
</metadata>
<assembly alias="System.Drawing" name="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="loadFilterSelectionsToolStripMenuItem.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAlpJREFUOE+tk21I
k1EYhif0oyA0sqIQCix/+GcQFFH9CCmiUBTLLEjShJofVBgL2fxoU9Pp5ubUlS5rU9f8rCyjsA+pUCRC
TR1ppmVFUSlmhq78unrnQF1KGHTg/nEOz30993PO+7qJFrmUeiv2n+Mij+XLRLLYULdF2pxlEVIDcw0p
AsyxD5fmI/rQ94pqi26eOlsfuZj+7BgSm01QdA4ih7m73Yx9qGpavwatjPebqCzOprPt8YKQgzFagqL0
BEjyEFWVaBkdLHMxT34uYNwWR9nVTEoL0zHlp2DMSeaSRk6eKt4VWm5WM/rVPNN5SjDTLQebZEHNA1wr
UvHjk3E6tsNcV62e1r3KLGqtKm6WplNpSsVqVFJsOM8VfSKFWjkGtcyZptSYzvC7XByx3zQoqCnTMvlG
CX1prnornPUmQJcUXsbSVhGK5bIOkcmQyveeTHiv4VZ5Nk33Nc6iuSO8CIfmECYa/bE/8ON1iRipJNh5
F0V6Bd86lfQ1JlFj1TDVq4COKCegLVIwHmGiKRB7/V6G7+5koHozymgfYRy5E1CgTWKgXcZ1i5qWp0KS
rjgBcAJawph6FszYk/2M1O1isGYLX8p9ab6wgqP+3rMvYciS01GfzA1LFvQkQ6sQ9/khxhoCGHnox1Dt
NvorxXw0b8Km8UQh2cip6GOzgNyMeKqKM7HdjqFZJ5pRk2YJ9aql3EnxoCJxNaZ4Ly6e3UDY3O6OEXRp
59ApTpIhiyDh9GHORAZyPHQPB/ZtZ/cOMVvFPvh6e7F+3SrWrHRnraf7Xz/xf/rJ/kvxb84I3U1y+9/W
AAAAAElFTkSuQmCC
</value>
</data>
<data name="saveFilterSelectionsToolStripMenuItem.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAixJREFUOE+tk91L
k3EUx/cvdN9N0EW3NTWGa7EaPOUcyqphWBG9PZEv5dJlmqhYmUYtXyBb4dJJy+kknFT4BqZIjaFMJUsz
V7TEoabYRDD49ju/6Pm1Mi+iH5zLz+c855zvo1L9j/fsaRRUvvZltHmX8Ni9gMaGCO47ZlBb8wn22yHc
KJ9CackECgteIy93FBfOB6H0JrC3B6ipXsVGb2V1Dca0XhxOe8JLEXhbF7mgsuLLX3mCIwsr2G1+DrVa
huWQRwjcj+a5oLTk87qCn/D78CLiTD4UXJ7GAXOTEDjrZ7ngku3dH4Jf4ZHJCLZJXlhzxpGa4hSCurth
LsjOGo0R/A4PBsPYrHdDlgMwmRxCUF31kQvkMwFFsB7c4/+ATYkNOHL0BZKSaoXgZuU0urvATgkcP/kK
lmMDfNu0MJqZPps6/4D7cNDSCUmyC8HVskl0+MAyADS5vrG7f0X59Tm+VFoYzZyZEVTg5NR2GAwVQnCl
cByeZuChc40FJwpjek5MmU/YkH6uiHdOTmHwfg/0+jIhsOWNMRiouhPlnUnAQoI4rYSht7MYm5qDnHsN
e41tHNbucUGnKxICiqXjHpTPJgHBZ/Nv4U1oHqGZJVwstiNe72JwI+J3PYA2MV8IMjOG2dzLfOatBg+2
7JDQ0tEPX9cguvv8GHg5hH0mC9S6eiQweLumDhqNVQgo06dP9fN4UsIoJHRnOhVtmxZGM1NXKoJ3JmTH
Cv71r/4OTrQ4xWMwWlcAAAAASUVORK5CYII=
</value>
</data>
<data name="toolStripSplitButton1.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAgxJREFUOE+lkvtL
U2EYx+0PEbtpFwnBKPGKiJImGP0gYhIYs1E5GF5gIxkpA00JRSmMEF0ohMh+GaRWYlqabMVcNdS2QpaI
VqiDIYhk397vA6fXhCjyhYdzeM/5fp7vczkAdeL2cwho7v/wWzT1zcN+Pwhr51uY2/y41PQaF+wzKKiZ
QvaN58g0jyLd5KEUcQbg+84P/Cm2tncQjW3j68YWIqubCC3FcOJc478BAuGoZM6zvoRnakXEruEIjhc4
/g5gZop9c+voGAyLbQIfeBZxLL9BA1jzXvuGbWamuKh+GmmVbswE19A59FEBbmoAG7YbsLtm2mZmiml9
cvabNDwpz6YB7LYBoMXCumkJr7LOmnnHzBQ/9X2Bo2cOibm1GsBREbAQiYmw/8lnuCeWkVzcgnZlnw1j
3HV/wuNXK6i/9x5Hc6wawDlTXHbLJ+LZUBQPRyKwdQdxutwl1h+NLXHh5Ht1ewBHsiwawCW57HyDAfWR
dvl0uhZQ1eqX8aVc7EKLqrum651ATLf9OJx5XQM4KmY0xPzZ0hFAiQJnXB0WwME0E3IsL5B17ZlADqWb
NYDrOepdlcysmTWWOrxqbceRWtaLk0VO1XW72D5Vckd2gMBfq8zdpmUG62NJvKM4+XyziDk24xmfWoGE
s1c0gHPmbrPTpHNJKOCo2G1mZs20zcwUJ5yp1AB5+8/zEwgF5GMVDxh4AAAAAElFTkSuQmCC
</value>
</data>
<metadata name="toolStripMenu.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 0</value>
</metadata>
<data name="toolStripFileMenu.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
@@ -212,6 +251,9 @@
s1c0gHPmbrPTpHNJKOCo2G1mZs20zcwUJ5yp1AB5+8/zEwgF5GMVDxh4AAAAAElFTkSuQmCC
</value>
</data>
<metadata name="contextMenuStripCopy.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>927, 17</value>
</metadata>
<data name="EditToolStripButton.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
@@ -229,24 +271,6 @@
AAAAAElFTkSuQmCC
</value>
</data>
<data name="toolStripDropDownButton5.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAgxJREFUOE+lkvtL
U2EYx+0PEbtpFwnBKPGKiJImGP0gYhIYs1E5GF5gIxkpA00JRSmMEF0ohMh+GaRWYlqabMVcNdS2QpaI
VqiDIYhk397vA6fXhCjyhYdzeM/5fp7vczkAdeL2cwho7v/wWzT1zcN+Pwhr51uY2/y41PQaF+wzKKiZ
QvaN58g0jyLd5KEUcQbg+84P/Cm2tncQjW3j68YWIqubCC3FcOJc478BAuGoZM6zvoRnakXEruEIjhc4
/g5gZop9c+voGAyLbQIfeBZxLL9BA1jzXvuGbWamuKh+GmmVbswE19A59FEBbmoAG7YbsLtm2mZmiml9
cvabNDwpz6YB7LYBoMXCumkJr7LOmnnHzBQ/9X2Bo2cOibm1GsBREbAQiYmw/8lnuCeWkVzcgnZlnw1j
3HV/wuNXK6i/9x5Hc6wawDlTXHbLJ+LZUBQPRyKwdQdxutwl1h+NLXHh5Ht1ewBHsiwawCW57HyDAfWR
dvl0uhZQ1eqX8aVc7EKLqrum651ATLf9OJx5XQM4KmY0xPzZ0hFAiQJnXB0WwME0E3IsL5B17ZlADqWb
NYDrOepdlcysmTWWOrxqbceRWtaLk0VO1XW72D5Vckd2gMBfq8zdpmUG62NJvKM4+XyziDk24xmfWoGE
s1c0gHPmbrPTpHNJKOCo2G1mZs20zcwUJ5yp1AB5+8/zEwgF5GMVDxh4AAAAAElFTkSuQmCC
</value>
</data>
<metadata name="contextMenuStripCopy.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>919, 17</value>
</metadata>
<metadata name="timer1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>226, 17</value>
</metadata>
@@ -296,24 +320,27 @@
</value>
</data>
<metadata name="saveFileDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>364, 54</value>
<value>470, 56</value>
</metadata>
<metadata name="openFileDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>492, 54</value>
<value>606, 56</value>
</metadata>
<metadata name="saveFileDialog2.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>622, 54</value>
<value>746, 56</value>
</metadata>
<metadata name="openFileDialog2.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>750, 54</value>
</metadata>
<metadata name="statusStrip3.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>880, 54</value>
<value>882, 56</value>
</metadata>
<metadata name="contextMenuStripFilterOptions.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 91</value>
<value>17, 95</value>
</metadata>
<metadata name="colorDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>990, 54</value>
<value>1022, 56</value>
</metadata>
<metadata name="toolStripLogin.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>210, 56</value>
</metadata>
<metadata name="saveFileDialog3.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>419, 17</value>
</metadata>
</root>

View File

@@ -0,0 +1,711 @@
/*
* Copyright (c) 2009, openmetaverse.org
* All rights reserved.
*
* - Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* - Neither the name of the openmetaverse.org nor the names
* of its contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.Net;
using System.Text;
using System.Reflection;
using OpenMetaverse;
using OpenMetaverse.Packets;
using OpenMetaverse.Messages;
using OpenMetaverse.StructuredData;
using OpenMetaverse.Interfaces;
using GridProxy;
namespace WinGridProxy
{
#region Base Class
internal abstract class Session
{
private const string EmptyXml = "<?xml version=\"1.0\"?><Empty>XML representation of this item is not available.</Empty>";
private const string EmptyString = "String representation of this item is not available.";
private const string EmptyNotation = "Notation representation of this item is not available.";
public Direction Direction { get; set; }
public String Host { get; set; }
public String Protocol { get; set; }
public String Name { get; set; }
public String ContentType { get; set; }
public int Length { get; set; }
public Session()
{
this.Host = this.Protocol = this.Name = String.Empty;
this.Length = 0;
this.ContentType = String.Empty;
}
public virtual string ToRawString(Direction direction)
{
return EmptyString;
}
public virtual byte[] ToBytes(Direction direction)
{
return OpenMetaverse.Utils.EmptyBytes;
}
public virtual string ToXml(Direction direction)
{
return EmptyXml;
}
public virtual string ToStringNotation(Direction direction)
{
return EmptyNotation;
}
public abstract string ToPrettyString(Direction direction);
public abstract byte[] Serialize();
public abstract Session Deserialize(byte[] bytes);
}
#endregion
#region Packets
internal sealed class SessionPacket : Session
{
public Packet Packet { get; set; }
public SessionPacket() : base() { this.Protocol = "UDP"; }
public SessionPacket(Packet packet, Direction direction, IPEndPoint endpoint, String contentType)
: base()
{
this.Packet = packet;
this.Name = packet.Type.ToString();
this.Direction = direction;
this.Host = String.Format("{0}:{1}", endpoint.Address, endpoint.Port);
this.ContentType = contentType;
this.Length = packet.Length;
this.Protocol = "UDP";
}
public override string ToPrettyString(Direction direction)
{
if (direction == this.Direction)
return PacketDecoder.PacketToString(this.Packet);
else
return String.Empty;
}
public override string ToRawString(Direction direction)
{
if (direction == this.Direction)
return PacketDecoder.PacketToString(this.Packet);
else
return String.Empty;
}
public override byte[] ToBytes(Direction direction)
{
if (direction == this.Direction)
return Packet.ToBytes();
else
return base.ToBytes(direction);
}
//public override string ToXml(Direction direction)
//{
// if (direction == this.Direction)
// return Packet.ToXmlString(this.Packet);
// else
// return base.ToXml(direction);
//}
//public override string ToStringNotation(Direction direction)
//{
// if (direction == this.Direction)
// return Packet.GetLLSD(this.Packet).ToString();
// else
// return base.ToStringNotation(direction);
//}
public override byte[] Serialize()
{
OSDMap map = new OSDMap(5);
map["Name"] = OSD.FromString(this.Name);
map["Host"] = OSD.FromString(this.Host);
map["PacketBytes"] = OSD.FromBinary(this.Packet.ToBytes());
map["Direction"] = OSD.FromInteger((int)this.Direction);
map["ContentType"] = OSD.FromString(this.ContentType);
return OpenMetaverse.Utils.StringToBytes(map.ToString());
}
public override Session Deserialize(byte[] bytes)
{
OSDMap map = (OSDMap)OSDParser.DeserializeLLSDNotation(OpenMetaverse.Utils.BytesToString(bytes));
this.Host = map["Host"].AsString();
this.Direction = (Direction)map["Direction"].AsInteger();
this.ContentType = map["ContentType"].AsString();
byte[] packetData = map["PacketBytes"].AsBinary();
this.Length = packetData.Length;
int packetEnd = packetData.Length - 1;
this.Packet = Packet.BuildPacket(packetData, ref packetEnd, null);
this.Name = this.Packet.Type.ToString();
return this;
}
}
#endregion Packets
#region Capabilities
internal sealed class SessionCaps : Session
{
byte[] RequestBytes { get; set; }
byte[] ResponseBytes { get; set; }
WebHeaderCollection RequestHeaders { get; set; }
WebHeaderCollection ResponseHeaders { get; set; }
public SessionCaps() : base() { /*this.Protocol = "Caps";*/ }
public SessionCaps(byte[] requestBytes, byte[] responseBytes,
WebHeaderCollection requestHeaders, WebHeaderCollection responseHeaders,
Direction direction, string uri, string capsKey, String proto)
: base()
{
this.RequestBytes = requestBytes;
this.ResponseBytes = responseBytes;
this.RequestHeaders = requestHeaders;
this.ResponseHeaders = responseHeaders;
this.Protocol = proto;
this.Name = capsKey;
this.Direction = direction;
this.Host = uri;
this.ContentType = (direction == Direction.Incoming) ? this.ResponseHeaders.Get("Content-Type") : this.RequestHeaders.Get("Content-Type");
this.Length = (requestBytes != null) ? requestBytes.Length : 0;
this.Length += (responseBytes != null) ? responseBytes.Length : 0;
}
public override string ToPrettyString(Direction direction)
{
if (direction == Direction.Incoming)
{
if (this.ResponseBytes != null && this.ResponseBytes.Length > 0)
{
IMessage message = null;
OSD osd = OSDParser.Deserialize(this.ResponseBytes);
OSDMap data = (OSDMap)osd;
if (data.ContainsKey("body"))
message = OpenMetaverse.Messages.MessageUtils.DecodeEvent(this.Name, (OSDMap)data["body"]);
else
message = OpenMetaverse.Messages.MessageUtils.DecodeEvent(this.Name, data);
if (message != null)
return PacketDecoder.MessageToString(message, 0);
else
return "No Decoder for " + this.Name + Environment.NewLine + data.ToString() + Environment.NewLine +
"Please report this at http://jira.openmv.org Be sure to include the entire message.";
}
}
else
{
if (this.RequestBytes != null && this.RequestBytes.Length > 0)
{
if (this.RequestBytes[0] == 60)
{
OSD osd = OSDParser.Deserialize(this.RequestBytes);
if (osd is OSDMap)
{
IMessage message = null;
OSDMap data = (OSDMap)osd;
if (data.ContainsKey("body"))
message = MessageUtils.DecodeEvent(this.Name, (OSDMap)data["body"]);
else
message = MessageUtils.DecodeEvent(this.Name, data);
if (message != null)
return PacketDecoder.MessageToString(message, 0);
else
return "No Decoder for " + this.Name + Environment.NewLine + data.ToString() + Environment.NewLine +
"Please report this at http://jira.openmv.org Be sure to include the entire message.";
}
else
{
return osd.ToString();
}
}
else
{
// this means its probably a script or asset using the uploader capability
// so we'll just return the raw bytes as a string
//if (this.RequestBytes[0] == 100)
//{
return Utils.BytesToString(this.RequestBytes);
//}
}
}
else
{
return String.Empty;
}
}
return String.Empty;
}
public override string ToRawString(Direction direction)
{
if (direction == Direction.Incoming)
{
if (this.ResponseBytes != null)
{
StringBuilder result = new StringBuilder();
foreach (String key in ResponseHeaders.Keys)
{
result.AppendFormat("{0} {1}" + Environment.NewLine, key, ResponseHeaders[key]);
}
result.AppendLine();
result.AppendLine(OpenMetaverse.Utils.BytesToString(this.ResponseBytes));
return result.ToString();
}
else
return String.Empty;
}
else
{
if (this.RequestBytes != null)
{
StringBuilder result = new StringBuilder();
foreach (String key in RequestHeaders.Keys)
{
result.AppendFormat("{0} {1}" + Environment.NewLine, key, RequestHeaders[key]);
}
result.AppendLine();
result.AppendLine(OpenMetaverse.Utils.BytesToString(this.RequestBytes));
return result.ToString();
}
else
return String.Empty;
}
}
public override byte[] ToBytes(Direction direction)
{
if (direction == Direction.Incoming)
{
if (this.ResponseBytes != null)
return this.ResponseBytes;
else
return base.ToBytes(direction);
}
else
{
if (this.RequestBytes != null)
return this.RequestBytes;
else
return base.ToBytes(direction);
}
}
public override string ToStringNotation(Direction direction)
{
if (direction == Direction.Incoming)
{
if (this.ResponseBytes != null)
return BytesToOsd(this.ResponseBytes);
//return this.ResponseBytes;
else
return base.ToStringNotation(direction);
}
else
{
if (this.RequestBytes != null)
{
return BytesToOsd(this.RequestBytes);
}
else
return base.ToStringNotation(direction);
}
}
public override string ToXml(Direction direction)
{
if (direction == Direction.Incoming)
{
if (this.ResponseBytes != null)
return BytesToXml(this.ResponseBytes);
else
return base.ToXml(direction);
}
else
{
if (this.RequestBytes != null)
return BytesToXml(this.RequestBytes);
else
return base.ToXml(direction);
}
}
// Sanity check the bytes are infact OSD
private string BytesToOsd(byte[] bytes)
{
try
{
OSD osd = OSDParser.Deserialize(bytes);
return osd.ToString();
}
catch (LitJson.JsonException)
{
// unable to decode as notation format
return base.ToStringNotation(this.Direction);
}
}
// Sanity check the bytes are infact an XML
private string BytesToXml(byte[] bytes)
{
String result = Utils.BytesToString(bytes);
if (result.StartsWith("<?xml"))
return result;
else
return base.ToXml(this.Direction);
}
public override byte[] Serialize()
{
OSDMap map = new OSDMap(9);
map["Name"] = OSD.FromString(this.Name);
map["Host"] = OSD.FromString(this.Host);
map["RequestBytes"] = OSD.FromBinary(this.RequestBytes);
map["ResponseBytes"] = OSD.FromBinary(this.ResponseBytes);
map["Direction"] = OSD.FromInteger((int)this.Direction);
map["ContentType"] = OSD.FromString(this.ContentType);
map["Protocol"] = OSD.FromString(this.Protocol);
OSDArray requestHeadersArray = new OSDArray();
foreach (String key in this.RequestHeaders.Keys)
{
OSDMap rMap = new OSDMap(1);
rMap[key] = OSD.FromString(this.RequestHeaders[key]);
requestHeadersArray.Add(rMap);
}
map["RequestHeaders"] = requestHeadersArray;
OSDArray responseHeadersArray = new OSDArray();
foreach (String key in this.ResponseHeaders.Keys)
{
OSDMap rMap = new OSDMap(1);
rMap[key] = OSD.FromString(this.ResponseHeaders[key]);
responseHeadersArray.Add(rMap);
}
map["ResponseHeaders"] = responseHeadersArray;
return OpenMetaverse.Utils.StringToBytes(map.ToString());
}
public override Session Deserialize(byte[] bytes)
{
OSDMap map = (OSDMap)OSDParser.DeserializeLLSDNotation(OpenMetaverse.Utils.BytesToString(bytes));
this.Name = map["Name"].AsString();
this.Host = map["Host"].AsString();
this.RequestBytes = map["RequestBytes"].AsBinary();
this.ResponseBytes = map["ResponseBytes"].AsBinary();
this.Direction = (Direction)map["Direction"].AsInteger();
this.Length = ResponseBytes.Length + RequestBytes.Length;
this.ContentType = map["ContentType"].AsString();
this.Protocol = map["Protocol"].AsString();
this.RequestHeaders = new WebHeaderCollection();
OSDArray requestHeadersArray = (OSDArray)map["RequestHeaders"];
for (int i = 0; i < requestHeadersArray.Count; i++)
{
OSDMap rMap = (OSDMap)requestHeadersArray[i];
foreach (string key in rMap.Keys)
{
this.RequestHeaders.Add(key, rMap[key].AsString());
}
}
this.ResponseHeaders = new WebHeaderCollection();
OSDArray responseHeadersArray = (OSDArray)map["ResponseHeaders"];
for (int i = 0; i < responseHeadersArray.Count; i++)
{
OSDMap rMap = (OSDMap)responseHeadersArray[i];
foreach (string key in rMap.Keys)
{
this.ResponseHeaders.Add(key, rMap[key].AsString());
}
}
return this;
}
}
#endregion Capabilities
#region Login
internal sealed class SessionLogin : Session
{
private object Data { get; set; }
//request, direction, comboBoxLoginURL.Text
public SessionLogin() : base() { this.Protocol = "https"; }
public SessionLogin(object request, Direction direction, String url, String contentType)
: base()
{
this.Data = request;
this.Direction = direction;
this.Host = url;
this.ContentType = contentType;
this.Name = (direction == Direction.Incoming) ? "Login Response" : "Login Request";
this.Protocol = "https";
this.Length = this.Data.ToString().Length;
}
public override string ToPrettyString(Direction direction)
{
if (direction == this.Direction)
{
return this.Data.ToString();
}
else
{
return String.Empty;
}
}
public override string ToRawString(Direction direction)
{
if (direction == this.Direction)
{
return this.Data.ToString();
}
else
{
return String.Empty;
}
}
public override string ToXml(Direction direction)
{
if (direction == this.Direction)
{
return this.Data.ToString();
}
else
{
return base.ToXml(direction);
}
}
public override byte[] ToBytes(Direction direction)
{
if (direction == this.Direction)
{
return OpenMetaverse.Utils.StringToBytes(this.Data.ToString());
}
else
{
return base.ToBytes(direction);
}
}
public override byte[] Serialize()
{
OSDMap map = new OSDMap(6);
map["Name"] = OSD.FromString(this.Name);
map["Host"] = OSD.FromString(this.Host);
map["Data"] = OSD.FromString(this.Data.ToString());
map["Direction"] = OSD.FromInteger((int)this.Direction);
map["ContentType"] = OSD.FromString(this.ContentType);
map["Protocol"] = OSD.FromString(this.Protocol);
return OpenMetaverse.Utils.StringToBytes(map.ToString());
}
public override Session Deserialize(byte[] bytes)
{
OSDMap map = (OSDMap)OSDParser.DeserializeLLSDNotation(OpenMetaverse.Utils.BytesToString(bytes));
this.Name = map["Name"].AsString();
this.Host = map["Host"].AsString();
this.Data = map["Data"].AsString();
this.Length = this.Data.ToString().Length;
this.Direction = (Direction)map["Direction"].AsInteger();
this.ContentType = map["ContentType"].AsString();
this.Protocol = map["Protocol"].AsString();
return this;
}
}
#endregion Login
#region EventQueue Messages
internal class SessionEvent : Session
{
private byte[] ResponseBytes;
private WebHeaderCollection ResponseHeaders;
public SessionEvent() : base() { this.Protocol = "EventQ"; }
public SessionEvent(byte[] responseBytes, WebHeaderCollection responseHeaders,
String uri, String capsKey, String proto)
: base()
{
this.Protocol = proto;
this.Direction = Direction.Incoming; // EventQueue Messages are always inbound from the simulator
this.ResponseBytes = responseBytes;
this.ResponseHeaders = responseHeaders;
this.Host = uri;
this.Name = capsKey;
this.ContentType = responseHeaders.Get("Content-Type");
this.Length = Int32.Parse(responseHeaders.Get("Content-Length"));
}
public override string ToPrettyString(Direction direction)
{
if (direction == this.Direction)
{
IMessage message = null;
OSD osd = OSDParser.Deserialize(this.ResponseBytes);
OSDMap data = (OSDMap)osd;
if (data.ContainsKey("body"))
message = MessageUtils.DecodeEvent(this.Name, (OSDMap)data["body"]);
else
message = MessageUtils.DecodeEvent(this.Name, data);
if (message != null)
return PacketDecoder.MessageToString(message, 0);
else
return "No Decoder for " + this.Name + Environment.NewLine + osd.ToString();
}
else
{
return String.Empty;
}
}
public override byte[] ToBytes(Direction direction)
{
if (direction == this.Direction)
{
return this.ResponseBytes;
}
else
{
return base.ToBytes(direction);
}
}
public override string ToRawString(Direction direction)
{
if (direction == this.Direction)
{
StringBuilder result = new StringBuilder();
foreach (String key in ResponseHeaders.Keys)
{
result.AppendFormat("{0} {1}" + Environment.NewLine, key, ResponseHeaders[key]);
}
result.AppendLine();
result.AppendLine(this.ToXml(direction));
return result.ToString();
}
else
{
return String.Empty;
}
}
public override string ToXml(Direction direction)
{
if (direction == this.Direction)
{
return OpenMetaverse.Utils.BytesToString(this.ResponseBytes);
}
else
{
return base.ToXml(direction);
}
}
public override string ToStringNotation(Direction direction)
{
if (direction == this.Direction)
{
OSD osd = OSDParser.DeserializeLLSDXml(this.ResponseBytes);
return osd.ToString();
}
else
{
return base.ToStringNotation(direction);
}
}
public override byte[] Serialize()
{
OSDMap map = new OSDMap(7);
map["Name"] = OSD.FromString(this.Name);
map["Host"] = OSD.FromString(this.Host);
map["ResponseBytes"] = OSD.FromBinary(this.ResponseBytes);
map["Direction"] = OSD.FromInteger((int)this.Direction);
map["ContentType"] = OSD.FromString(this.ContentType);
map["Protocol"] = OSD.FromString(this.Protocol);
OSDArray responseHeadersArray = new OSDArray();
foreach (String key in this.ResponseHeaders.Keys)
{
OSDMap rMap = new OSDMap(1);
rMap[key] = OSD.FromString(this.ResponseHeaders[key]);
responseHeadersArray.Add(rMap);
}
map["ResponseHeaders"] = responseHeadersArray;
return Utils.StringToBytes(map.ToString());
}
public override Session Deserialize(byte[] bytes)
{
OSDMap map = (OSDMap)OSDParser.DeserializeLLSDNotation(OpenMetaverse.Utils.BytesToString(bytes));
this.Name = map["Name"].AsString();
this.Host = map["Host"].AsString();
this.ResponseBytes = map["ResponseBytes"].AsBinary();
this.Direction = (Direction)map["Direction"].AsInteger();
this.ContentType = map["ContentType"].AsString();
this.Protocol = map["Protocol"].AsString();
this.Length = ResponseBytes.Length;
if (map.ContainsKey("ResponseHeaders"))
{
this.ResponseHeaders = new WebHeaderCollection();
OSDArray responseHeadersArray = (OSDArray)map["ResponseHeaders"];
for (int i = 0; i < responseHeadersArray.Count; i++)
{
OSDMap rMap = (OSDMap)responseHeadersArray[i];
foreach (string key in rMap.Keys)
{
this.ResponseHeaders.Add(key, rMap[key].AsString());
}
}
}
return this;
}
}
#endregion
}

View File

@@ -32,25 +32,27 @@ using System.IO;
namespace WinGridProxy
{
public class FilterEntry
internal class FilterEntryOptions
{
public bool Checked;
public string pType;
public string Type { get; set; }
public bool Checked { get; set; }
public string Group { get; set; }
}
class SettingsStore
internal class SettingsStore
{
public Dictionary<string, FilterEntry> MessageSessions;
public Dictionary<string, FilterEntry> PacketSessions;
public bool AutoScrollEnabled;
private const int FileVersion = 1;
public Dictionary<string, FilterEntryOptions> MessageSessions;
public Dictionary<string, FilterEntryOptions> PacketSessions;
public bool StatisticsEnabled;
public bool SaveSessionOnExit;
public bool AutoCheckNewCaps;
public SettingsStore()
{
MessageSessions = new Dictionary<string, FilterEntry>();
PacketSessions = new Dictionary<string, FilterEntry>();
MessageSessions = new Dictionary<string, FilterEntryOptions>();
PacketSessions = new Dictionary<string, FilterEntryOptions>();
}
public OSDMap Serialize()
@@ -59,12 +61,13 @@ namespace WinGridProxy
if (MessageSessions.Count > 0)
{
OSDArray messageArray = new OSDArray(MessageSessions.Count);
foreach (KeyValuePair<string, FilterEntry> kvp in MessageSessions)
foreach (KeyValuePair<string, FilterEntryOptions> kvp in MessageSessions)
{
OSDMap sessionMap = new OSDMap(3);
sessionMap["Capability"] = OSD.FromString(kvp.Key);
OSDMap sessionMap = new OSDMap(4);
sessionMap["Name"] = OSD.FromString(kvp.Key);
sessionMap["Type"] = OSD.FromString(kvp.Value.Type);
sessionMap["Capture"] = OSD.FromBoolean(kvp.Value.Checked);
sessionMap["Type"] = OSD.FromString(kvp.Value.pType);
sessionMap["Group"] = OSD.FromString(kvp.Value.Group);
messageArray.Add(sessionMap);
}
map.Add("message_sessions", messageArray);
@@ -73,76 +76,78 @@ namespace WinGridProxy
if (PacketSessions.Count > 0)
{
OSDArray packetArray = new OSDArray(PacketSessions.Count);
foreach (KeyValuePair<string, FilterEntry> kvp in PacketSessions)
foreach (KeyValuePair<string, FilterEntryOptions> kvp in PacketSessions)
{
OSDMap sessionMap = new OSDMap(3);
sessionMap["PacketName"] = OSD.FromString(kvp.Key);
OSDMap sessionMap = new OSDMap(4);
sessionMap["Name"] = OSD.FromString(kvp.Key);
sessionMap["Type"] = OSD.FromString(kvp.Value.Type);
sessionMap["Capture"] = OSD.FromBoolean(kvp.Value.Checked);
sessionMap["Type"] = OSD.FromString(kvp.Value.pType);
sessionMap["Group"] = OSD.FromString(kvp.Value.Group);
packetArray.Add(sessionMap);
}
map.Add("packet_sessions", packetArray);
}
map.Add("AutoScrollSessions", OSD.FromBoolean(AutoScrollEnabled));
map.Add("CaptureStatistics", OSD.FromBoolean(StatisticsEnabled));
map.Add("SaveProfileOnExit", OSD.FromBoolean(SaveSessionOnExit));
map.Add("AutoCheckNewCaps", OSD.FromBoolean(AutoCheckNewCaps));
map.Add("FileVersion", OSD.FromInteger(FileVersion));
return map;
}
public void Deserialize(OSDMap map)
{
MessageSessions.Clear();
PacketSessions.Clear();
if (map.ContainsKey("message_sessions"))
if (map.ContainsKey("FileVersion") && map["FileVersion"].AsInteger() == FileVersion)
{
AutoScrollEnabled = map["AutoScrollSessions"].AsBoolean();
StatisticsEnabled = map["CaptureStatistics"].AsBoolean();
SaveSessionOnExit = map["SaveProfileOnExit"].AsBoolean();
AutoCheckNewCaps = map["AutoCheckNewCaps"].AsBoolean();
OSDArray messageArray = (OSDArray)map["message_sessions"];
MessageSessions = new Dictionary<string, FilterEntry>(messageArray.Count);
for (int i = 0; i < messageArray.Count; i++)
{
OSDMap m = (OSDMap)messageArray[i];
FilterEntry entry = new FilterEntry();
entry.Checked = m["Capture"].AsBoolean();
entry.pType = m["Type"].AsString();
MessageSessions.Add(m["Capability"].AsString(), entry);
}
}
else
{
//MessageSessions = new Dictionary<string, bool>();
Console.WriteLine("Error loading saved settings, FileVersion is null or out of date.");
StatisticsEnabled = true;
AutoCheckNewCaps = true;
SaveSessionOnExit = true;
return;
}
if (map.ContainsKey("message_sessions"))
{
OSDArray messageArray = (OSDArray)map["message_sessions"];
//MessageSessions = new Dictionary<string, FilterEntryOptions>(messageArray.Count);
for (int i = 0; i < messageArray.Count; i++)
{
OSDMap sessionsMap = (OSDMap)messageArray[i];
FilterEntryOptions entry = new FilterEntryOptions();
entry.Checked = sessionsMap["Capture"].AsBoolean();
entry.Group = sessionsMap["Group"].AsString();
entry.Type = sessionsMap["Type"].AsString();
MessageSessions.Add(sessionsMap["Name"].AsString(), entry);
}
}
if (map.ContainsKey("packet_sessions"))
{
OSDArray packetArray = (OSDArray)map["packet_sessions"];
PacketSessions = new Dictionary<string, FilterEntry>(packetArray.Count);
//PacketSessions = new Dictionary<string, FilterEntryOptions>(packetArray.Count);
for (int i = 0; i < packetArray.Count; i++)
{
OSDMap packetMap = (OSDMap)packetArray[i];
FilterEntry entry = new FilterEntry();
FilterEntryOptions entry = new FilterEntryOptions();
entry.Checked = packetMap["Capture"].AsBoolean();
entry.pType = packetMap["Type"].AsString();
PacketSessions.Add(packetMap["PacketName"].AsString(), entry);
entry.Group = packetMap["Group"].AsString();
entry.Type = packetMap["Type"].AsString();
PacketSessions.Add(packetMap["Name"].AsString(), entry);
}
}
else
{
//PacketSessions = new Dictionary<string, bool>();
}
}
public bool DeserializeFromFile(string fileName)
@@ -167,6 +172,5 @@ namespace WinGridProxy
{
File.WriteAllText(fileName, this.Serialize().ToString());
}
}
}