From 7a54467bed7e1da77f7e1a45ee01dfc709b5608d Mon Sep 17 00:00:00 2001 From: gareth Date: Wed, 14 Mar 2007 03:34:49 +0000 Subject: merged new OpenSim from branches/ogs-cs --- opensim.build | 1 + src/CAPS/SimHttp.cs | 152 +++++++++++++++++++++ src/Config/SimConfig/AssemblyInfo.cs | 2 +- src/GridInterfaces/AssemblyInfo.cs | 2 +- src/GridInterfaces/IGridServer.cs | 17 +++ src/LocalServers/LocalGridServers/AssemblyInfo.cs | 2 +- src/LocalServers/LocalGridServers/LocalGrid.cs | 9 +- src/LocalStorage/Db4LocalStorage/AssemblyInfo.cs | 2 +- src/Main.cs | 6 +- src/OpenSimConsole.cs | 2 +- .../RemoteGridServers/AssemblyInfo.cs | 2 +- src/RemoteServers/RemoteGridServers/RemoteGrid.cs | 48 ++++--- src/ServerConsole/ServerConsole/AssemblyInfo.cs | 2 +- src/Util.cs | 10 ++ src/VersionInfo.cs | 2 +- src/physics/AssemblyInfo.cs | 2 +- src/physics/plugins/AssemblyInfo.cs | 2 +- 17 files changed, 230 insertions(+), 33 deletions(-) create mode 100644 src/CAPS/SimHttp.cs diff --git a/opensim.build b/opensim.build index d2d20f1..a08a486 100644 --- a/opensim.build +++ b/opensim.build @@ -69,6 +69,7 @@ + diff --git a/src/CAPS/SimHttp.cs b/src/CAPS/SimHttp.cs new file mode 100644 index 0000000..eb20f3e --- /dev/null +++ b/src/CAPS/SimHttp.cs @@ -0,0 +1,152 @@ +/* +Copyright (c) OpenSimCAPS project, http://osgrid.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. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the 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 ``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 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.Text; +using Nwc.XmlRpc; +using System.Threading; +using System.Text.RegularExpressions; +using System.Net; +using System.IO; +using System.Collections; +using System.Collections.Generic; +using libsecondlife; +using ServerConsole; + +namespace OpenSim +{ + // Dummy HTTP server, does nothing useful for now + + public class SimCAPSHTTPServer { + public Thread HTTPD; + public HttpListener Listener; + + public SimCAPSHTTPServer() { + ServerConsole.MainConsole.Instance.WriteLine("Starting up HTTP Server"); + HTTPD = new Thread(new ThreadStart(StartHTTP)); + HTTPD.Start(); + } + + public void StartHTTP() { + ServerConsole.MainConsole.Instance.WriteLine("SimHttp.cs:StartHTTP() - Spawned main thread OK"); + Listener = new HttpListener(); + + Listener.Prefixes.Add("http://+:" + OpenSim_Main.cfg.IPListenPort + "/"); + Listener.Start(); + + HttpListenerContext context; + while(true) { + context = Listener.GetContext(); + ThreadPool.QueueUserWorkItem(new WaitCallback(HandleRequest), context); + } + } + + static string ParseXMLRPC(string requestBody) { + try{ + XmlRpcRequest request = (XmlRpcRequest)(new XmlRpcRequestDeserializer()).Deserialize(requestBody); + + Hashtable requestData = (Hashtable)request.Params[0]; + switch(request.MethodName) { + case "expect_user": + GridServers.agentcircuitdata agent_data = new GridServers.agentcircuitdata(); + agent_data.SessionID = new LLUUID((string)requestData["session_id"]); + agent_data.SecureSessionID = new LLUUID((string)requestData["secure_session_id"]); + agent_data.firstname = (string)requestData["firstname"]; + agent_data.lastname = (string)requestData["lastname"]; + agent_data.AgentID = new LLUUID((string)requestData["agent_id"]); + agent_data.circuitcode = Convert.ToUInt32(requestData["circuit_code"]); + OpenSim_Main.gridServers.GridServer.agentcircuits.Add((uint)agent_data.circuitcode,agent_data); + return ""; + break; + } + } catch(Exception e) { + Console.WriteLine(e.ToString()); + } + return ""; + } + + static string ParseREST(string requestBody, string requestURL) { + return ""; + } + + static string ParseLLSDXML(string requestBody) { + // dummy function for now - IMPLEMENT ME! + return ""; + } + + static void HandleRequest(Object stateinfo) { + HttpListenerContext context=(HttpListenerContext)stateinfo; + + HttpListenerRequest request = context.Request; + HttpListenerResponse response = context.Response; + + response.KeepAlive=false; + response.SendChunked=false; + + System.IO.Stream body = request.InputStream; + System.Text.Encoding encoding = System.Text.Encoding.UTF8; + System.IO.StreamReader reader = new System.IO.StreamReader(body, encoding); + + string requestBody = reader.ReadToEnd(); + body.Close(); + reader.Close(); + + string responseString=""; + switch(request.ContentType) { + case "text/xml": + // must be XML-RPC, so pass to the XML-RPC parser + + responseString=ParseXMLRPC(requestBody); + response.AddHeader("Content-type","text/xml"); + break; + + case "application/xml": + // probably LLSD we hope, otherwise it should be ignored by the parser + responseString=ParseLLSDXML(requestBody); + response.AddHeader("Content-type","application/xml"); + break; + + case null: + // must be REST or invalid crap, so pass to the REST parser + responseString=ParseREST(request.Url.OriginalString,requestBody); + break; + } + + + byte[] buffer = System.Text.Encoding.UTF8.GetBytes(responseString); + System.IO.Stream output = response.OutputStream; + response.SendChunked=false; + response.ContentLength64=buffer.Length; + output.Write(buffer,0,buffer.Length); + output.Close(); + } + } + + +} diff --git a/src/Config/SimConfig/AssemblyInfo.cs b/src/Config/SimConfig/AssemblyInfo.cs index 88a940b..daffc5e 100644 --- a/src/Config/SimConfig/AssemblyInfo.cs +++ b/src/Config/SimConfig/AssemblyInfo.cs @@ -14,7 +14,7 @@ using System.Runtime.InteropServices; [assembly: ComVisibleAttribute(false)] [assembly: CLSCompliantAttribute(false)] -[assembly: AssemblyVersionAttribute("0.1.*.192")] +[assembly: AssemblyVersionAttribute("0.1.*.193206")] [assembly: AssemblyTitleAttribute("opensim-simconfig")] [assembly: AssemblyDescriptionAttribute("The default configuration handler")] [assembly: AssemblyCopyrightAttribute("Copyright © OGS development team 2007")] diff --git a/src/GridInterfaces/AssemblyInfo.cs b/src/GridInterfaces/AssemblyInfo.cs index a62dcdc..42f45fc 100644 --- a/src/GridInterfaces/AssemblyInfo.cs +++ b/src/GridInterfaces/AssemblyInfo.cs @@ -14,7 +14,7 @@ using System.Runtime.InteropServices; [assembly: ComVisibleAttribute(false)] [assembly: CLSCompliantAttribute(false)] -[assembly: AssemblyVersionAttribute("0.1.*.192")] +[assembly: AssemblyVersionAttribute("0.1.*.193206")] [assembly: AssemblyTitleAttribute("opensim-gridinterfaces")] [assembly: AssemblyDescriptionAttribute("Definitions for OGS interface")] [assembly: AssemblyCopyrightAttribute("Copyright © OGS development team 2007")] diff --git a/src/GridInterfaces/IGridServer.cs b/src/GridInterfaces/IGridServer.cs index fef4c3e..c2d7172 100644 --- a/src/GridInterfaces/IGridServer.cs +++ b/src/GridInterfaces/IGridServer.cs @@ -32,6 +32,7 @@ using System.Net; using System.Net.Sockets; using System.IO; using libsecondlife; +using OpenSim; namespace OpenSim.GridServers { @@ -46,6 +47,10 @@ namespace OpenSim.GridServers public interface IGridServer { bool RequestConnection(); + Dictionary agentcircuits { + get; + set; + } UUIDBlock RequestUUIDBlock(); void RequestNeighbours(); //should return a array of neighbouring regions AuthenticateResponse AuthenticateSession(LLUUID sessionID, LLUUID agentID, uint circuitCode); @@ -91,4 +96,16 @@ namespace OpenSim.GridServers { IGridServer GetGridServer(); } + + public class agentcircuitdata { + public agentcircuitdata() { } + public LLUUID AgentID; + public LLUUID SessionID; + public LLUUID SecureSessionID; + public string firstname; + public string lastname; + public uint circuitcode; + } + + } diff --git a/src/LocalServers/LocalGridServers/AssemblyInfo.cs b/src/LocalServers/LocalGridServers/AssemblyInfo.cs index e25895f..943f5e7 100644 --- a/src/LocalServers/LocalGridServers/AssemblyInfo.cs +++ b/src/LocalServers/LocalGridServers/AssemblyInfo.cs @@ -14,7 +14,7 @@ using System.Runtime.InteropServices; [assembly: ComVisibleAttribute(false)] [assembly: CLSCompliantAttribute(false)] -[assembly: AssemblyVersionAttribute("0.1.*.192")] +[assembly: AssemblyVersionAttribute("0.1.*.193206")] [assembly: AssemblyTitleAttribute("opensim-localservers")] [assembly: AssemblyDescriptionAttribute("local grid servers")] [assembly: AssemblyCopyrightAttribute("Copyright © OGS development team 2007")] diff --git a/src/LocalServers/LocalGridServers/LocalGrid.cs b/src/LocalServers/LocalGridServers/LocalGrid.cs index 5adce27..86a68d5 100644 --- a/src/LocalServers/LocalGridServers/LocalGrid.cs +++ b/src/LocalServers/LocalGridServers/LocalGrid.cs @@ -113,7 +113,14 @@ namespace LocalGridServers public class LocalGridServer :IGridServer { public List Sessions = new List(); - + + private Dictionary AgentCircuits = new Dictionary(); + + public Dictionary agentcircuits { + get {return agentcircuits;} + set {agentcircuits=value;} + } + public LocalGridServer() { Sessions = new List(); diff --git a/src/LocalStorage/Db4LocalStorage/AssemblyInfo.cs b/src/LocalStorage/Db4LocalStorage/AssemblyInfo.cs index 28db549..3a8caf5 100644 --- a/src/LocalStorage/Db4LocalStorage/AssemblyInfo.cs +++ b/src/LocalStorage/Db4LocalStorage/AssemblyInfo.cs @@ -14,7 +14,7 @@ using System.Runtime.InteropServices; [assembly: ComVisibleAttribute(false)] [assembly: CLSCompliantAttribute(false)] -[assembly: AssemblyVersionAttribute("0.1.*.192")] +[assembly: AssemblyVersionAttribute("0.1.*.193206")] [assembly: AssemblyTitleAttribute("opensim-localstorage")] [assembly: AssemblyDescriptionAttribute("The local storage handler")] [assembly: AssemblyCopyrightAttribute("Copyright © OGS development team 2007")] diff --git a/src/Main.cs b/src/Main.cs index 79c0782..506f87b 100644 --- a/src/Main.cs +++ b/src/Main.cs @@ -56,7 +56,8 @@ namespace OpenSim public static SimConfig cfg; public static World local_world; public static Grid gridServers; - + public static SimCAPSHTTPServer http_server; + public static Socket Server; private static IPEndPoint ServerIncoming; private static byte[] RecvBuffer = new byte[4096]; @@ -169,6 +170,9 @@ namespace OpenSim local_world.LoadStorageDLL("Db4LocalStorage.dll"); //all these dll names shouldn't be hard coded. local_world.LoadPrimsFromStorage(); + ServerConsole.MainConsole.Instance.WriteLine("Main.cs:Startup() - Starting CAPS HTTP server"); + http_server = new SimCAPSHTTPServer(); + MainServerListener(); } diff --git a/src/OpenSimConsole.cs b/src/OpenSimConsole.cs index 00a4cee..cf8b648 100644 --- a/src/OpenSimConsole.cs +++ b/src/OpenSimConsole.cs @@ -175,7 +175,7 @@ namespace OpenSim break; case "users": OpenSim.world.Avatar TempAv; - this.WriteLine(String.Format("{0,-16}{1,-16}{2,-25}{3,-25}{4,-16},{5,-16}","Firstname", "Lastname","Agent ID", "Session ID", "Circuit", "IP")); + this.WriteLine(String.Format("{0,-16}{1,-16}{2,-25}{3,-25}{4,-16}{5,-16}","Firstname", "Lastname","Agent ID", "Session ID", "Circuit", "IP")); foreach (libsecondlife.LLUUID UUID in OpenSim_Main.local_world.Entities.Keys) { if(OpenSim_Main.local_world.Entities[UUID].ToString()== "OpenSim.world.Avatar") { diff --git a/src/RemoteServers/RemoteGridServers/AssemblyInfo.cs b/src/RemoteServers/RemoteGridServers/AssemblyInfo.cs index 3978650..b6953d4 100644 --- a/src/RemoteServers/RemoteGridServers/AssemblyInfo.cs +++ b/src/RemoteServers/RemoteGridServers/AssemblyInfo.cs @@ -14,7 +14,7 @@ using System.Runtime.InteropServices; [assembly: ComVisibleAttribute(false)] [assembly: CLSCompliantAttribute(false)] -[assembly: AssemblyVersionAttribute("0.1.*.192")] +[assembly: AssemblyVersionAttribute("0.1.*.193206")] [assembly: AssemblyTitleAttribute("opensim-remoteservers")] [assembly: AssemblyDescriptionAttribute("Connects to remote OGS installation")] [assembly: AssemblyCopyrightAttribute("Copyright © OGS development team 2007")] diff --git a/src/RemoteServers/RemoteGridServers/RemoteGrid.cs b/src/RemoteServers/RemoteGridServers/RemoteGrid.cs index 428d5f5..26cd137 100644 --- a/src/RemoteServers/RemoteGridServers/RemoteGrid.cs +++ b/src/RemoteServers/RemoteGridServers/RemoteGrid.cs @@ -69,7 +69,13 @@ namespace RemoteGridServers { private string GridServerUrl; private string GridSendKey; - + private Dictionary AgentCircuits = new Dictionary(); + + public Dictionary agentcircuits { + get {return AgentCircuits;} + set {AgentCircuits=value;} + } + public RemoteGridServer() { ServerConsole.MainConsole.Instance.WriteLine("Remote Grid Server class created"); @@ -79,26 +85,21 @@ namespace RemoteGridServers { return true; } - public AuthenticateResponse AuthenticateSession(LLUUID sessionID, LLUUID agentID, uint circuitCode) + + + public AuthenticateResponse AuthenticateSession(LLUUID sessionID, LLUUID agentID, uint circuitcode) { + agentcircuitdata validcircuit=this.AgentCircuits[circuitcode]; AuthenticateResponse user = new AuthenticateResponse(); - - WebRequest CheckSession = WebRequest.Create(GridServerUrl + "/usersessions/" + GridSendKey + "/" + agentID.ToString() + "/" + circuitCode.ToString() + "/exists"); - WebResponse GridResponse = CheckSession.GetResponse(); - StreamReader sr = new StreamReader(GridResponse.GetResponseStream()); - String grTest = sr.ReadLine(); - sr.Close(); - GridResponse.Close(); - if(String.IsNullOrEmpty(grTest) || grTest.Equals("1")) + if((sessionID==validcircuit.SessionID) && (agentID==validcircuit.AgentID)) { // YAY! Valid login user.Authorised = true; user.LoginInfo = new Login(); user.LoginInfo.Agent = agentID; user.LoginInfo.Session = sessionID; - user.LoginInfo.First = ""; - user.LoginInfo.Last = ""; - + user.LoginInfo.First = validcircuit.firstname; + user.LoginInfo.Last = validcircuit.lastname; } else { @@ -111,13 +112,18 @@ namespace RemoteGridServers public bool LogoutSession(LLUUID sessionID, LLUUID agentID, uint circuitCode) { - WebRequest DeleteSession = WebRequest.Create(GridServerUrl + "/usersessions/" + GridSendKey + "/" + agentID.ToString() + "/" + circuitCode.ToString() + "/delete"); - WebResponse GridResponse = DeleteSession.GetResponse(); - StreamReader sr = new StreamReader(GridResponse.GetResponseStream()); - String grTest = sr.ReadLine(); - sr.Close(); - GridResponse.Close(); - ServerConsole.MainConsole.Instance.WriteLine("DEBUG: " + grTest); + WebRequest DeleteSession = WebRequest.Create(GridServerUrl + "/usersessions/" + sessionID.ToString()); + DeleteSession.Method="DELETE"; + DeleteSession.ContentType="text/plaintext"; + DeleteSession.ContentLength=0; + + StreamWriter stOut = new StreamWriter (DeleteSession.GetRequestStream(), System.Text.Encoding.ASCII); + stOut.Write(""); + stOut.Close(); + + StreamReader stIn = new StreamReader(DeleteSession.GetResponse().GetResponseStream()); + string GridResponse = stIn.ReadToEnd(); + stIn.Close(); return(true); } @@ -213,7 +219,7 @@ namespace RemoteGridServers } } } - + public class BlockingQueue< T > { private Queue< T > _queue = new Queue< T >(); private object _queueSync = new object(); diff --git a/src/ServerConsole/ServerConsole/AssemblyInfo.cs b/src/ServerConsole/ServerConsole/AssemblyInfo.cs index 57481fc..1c5f7a0 100644 --- a/src/ServerConsole/ServerConsole/AssemblyInfo.cs +++ b/src/ServerConsole/ServerConsole/AssemblyInfo.cs @@ -14,7 +14,7 @@ using System.Runtime.InteropServices; [assembly: ComVisibleAttribute(false)] [assembly: CLSCompliantAttribute(false)] -[assembly: AssemblyVersionAttribute("0.1.*.192")] +[assembly: AssemblyVersionAttribute("0.1.*.193206")] [assembly: AssemblyTitleAttribute("opensim-serverconsole")] [assembly: AssemblyDescriptionAttribute("The default server console")] [assembly: AssemblyCopyrightAttribute("Copyright © OGS development team 2007")] diff --git a/src/Util.cs b/src/Util.cs index d575bee..e7ca608 100644 --- a/src/Util.cs +++ b/src/Util.cs @@ -59,6 +59,16 @@ namespace OpenSim public bool Incoming; } + public class agentcircuitdata { + public agentcircuitdata() { } + public LLUUID AgentID; + public LLUUID SessionID; + public LLUUID SecureSessionID; + public string firstname; + public string lastname; + public uint circuitcode; + } + public class BlockingQueue< T > { private Queue< T > _queue = new Queue< T >(); diff --git a/src/VersionInfo.cs b/src/VersionInfo.cs index 94f0810..5994b49 100644 --- a/src/VersionInfo.cs +++ b/src/VersionInfo.cs @@ -32,6 +32,6 @@ namespace OpenSim /// public class VersionInfo { - public static string Version = "0.1, Build 1173785234, Revision 192M"; + public static string Version = "0.1, Build 1173843165, Revision 193:206M"; } } diff --git a/src/physics/AssemblyInfo.cs b/src/physics/AssemblyInfo.cs index c78d44c..c7b2255 100644 --- a/src/physics/AssemblyInfo.cs +++ b/src/physics/AssemblyInfo.cs @@ -14,7 +14,7 @@ using System.Runtime.InteropServices; [assembly: ComVisibleAttribute(false)] [assembly: CLSCompliantAttribute(false)] -[assembly: AssemblyVersionAttribute("0.1.*.192")] +[assembly: AssemblyVersionAttribute("0.1.*.193206")] [assembly: AssemblyTitleAttribute("opensim-physicsmanager")] [assembly: AssemblyDescriptionAttribute("Handles physics plugins")] [assembly: AssemblyCopyrightAttribute("Copyright © OGS development team 2007")] diff --git a/src/physics/plugins/AssemblyInfo.cs b/src/physics/plugins/AssemblyInfo.cs index a24c947..dc7d0a7 100644 --- a/src/physics/plugins/AssemblyInfo.cs +++ b/src/physics/plugins/AssemblyInfo.cs @@ -14,7 +14,7 @@ using System.Runtime.InteropServices; [assembly: ComVisibleAttribute(false)] [assembly: CLSCompliantAttribute(false)] -[assembly: AssemblyVersionAttribute("0.1.*.192")] +[assembly: AssemblyVersionAttribute("0.1.*.193206")] [assembly: AssemblyTitleAttribute("opensim-physicsmanager-physx")] [assembly: AssemblyDescriptionAttribute("PhysX plugin for OpenSim")] [assembly: AssemblyCopyrightAttribute("Copyright © OGS development team 2007")] -- cgit v1.1