From 17b00785ee10a71d290cbcddca9b0152fdf60c8f Mon Sep 17 00:00:00 2001 From: MW Date: Thu, 29 Mar 2007 11:08:42 +0000 Subject: Added lbsa71's http server changes. So it now has a single http listener that passes incoming requests to the correct handler. This means that logins (in sandbox mode) now go through this listener, which for now is listening on the port you set in startup (default 9000). (This needs changing so that the http listener and udp server are not using the same port) --- OpenSim.RegionServer/OpenSimMain.cs | 86 +++++++++++++++++++++++++++---------- 1 file changed, 63 insertions(+), 23 deletions(-) (limited to 'OpenSim.RegionServer/OpenSimMain.cs') diff --git a/OpenSim.RegionServer/OpenSimMain.cs b/OpenSim.RegionServer/OpenSimMain.cs index 07a2d6d..651c0c6 100644 --- a/OpenSim.RegionServer/OpenSimMain.cs +++ b/OpenSim.RegionServer/OpenSimMain.cs @@ -45,6 +45,8 @@ using OpenSim.Assets; using OpenSim.CAPS; using OpenSim.Framework.Console; using OpenSim.Physics.Manager; +using Nwc.XmlRpc; +using OpenSim.Servers; namespace OpenSim { @@ -54,7 +56,8 @@ namespace OpenSim private World LocalWorld; private Grid GridServers; private SimConfig Cfg; - private SimCAPSHTTPServer HttpServer; + //private SimCAPSHTTPServer HttpServer; + private BaseHttpServer HttpServer; private AssetCache AssetCache; private InventoryCache InventoryCache; //public Dictionary ClientThreads = new Dictionary(); @@ -78,13 +81,13 @@ namespace OpenSim public bool user_accounts = false; protected ConsoleBase m_console; - - public OpenSimMain( bool sandBoxMode, bool startLoginServer, string physicsEngine ) + + public OpenSimMain(bool sandBoxMode, bool startLoginServer, string physicsEngine) { m_sandbox = sandBoxMode; m_loginserver = startLoginServer; m_physicsEngine = physicsEngine; - + m_console = new ConsoleBase("region-console.log", "Region", this); OpenSim.Framework.Console.MainConsole.Instance = m_console; } @@ -92,11 +95,11 @@ namespace OpenSim public virtual void StartUp() { GridServers = new Grid(); - if ( m_sandbox ) + if (m_sandbox) { GridServers.AssetDll = "OpenSim.GridInterfaces.Local.dll"; GridServers.GridDll = "OpenSim.GridInterfaces.Local.dll"; - + m_console.WriteLine("Starting in Sandbox mode"); } else @@ -108,7 +111,7 @@ namespace OpenSim } GridServers.Initialise(); - + startuptime = DateTime.Now; AssetCache = new AssetCache(GridServers.AssetServer); @@ -134,36 +137,74 @@ namespace OpenSim LocalWorld.PhysScene.SetTerrain(LocalWorld.LandMap); GridServers.AssetServer.SetServerInfo(Cfg.AssetURL, Cfg.AssetSendKey); - GridServers.GridServer.SetServerInfo(Cfg.GridURL, Cfg.GridSendKey, Cfg.GridRecvKey); + //GridServers.GridServer.SetServerInfo(Cfg.GridURL, Cfg.GridSendKey, Cfg.GridRecvKey); + IGridServer gridServer = GridServers.GridServer; + gridServer.SetServerInfo(Cfg.GridURL, Cfg.GridSendKey, Cfg.GridRecvKey); LocalWorld.LoadStorageDLL("OpenSim.Storage.LocalStorageDb4o.dll"); //all these dll names shouldn't be hard coded. LocalWorld.LoadPrimsFromStorage(); - if ( m_sandbox) + if (m_sandbox) { AssetCache.LoadDefaultTextureSet(); } - m_console.WriteLine("Main.cs:Startup() - Starting CAPS HTTP server"); - HttpServer = new SimCAPSHTTPServer(GridServers.GridServer, Cfg.IPListenPort); + m_console.WriteLine("Main.cs:Startup() - Initialising HTTP server"); + // HttpServer = new SimCAPSHTTPServer(GridServers.GridServer, Cfg.IPListenPort); + HttpServer = new BaseHttpServer(Cfg.IPListenPort); + + if (gridServer.GetName() == "Remote") + { + //we are in Grid mode so set a XmlRpc handler to handle "expect_user" calls from the user server + HttpServer.AddXmlRPCHandler("expect_user", + delegate(XmlRpcRequest request) + { + Hashtable requestData = (Hashtable)request.Params[0]; + AgentCircuitData agent_data = new 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"]); + + ((RemoteGridBase)gridServer).agentcircuits.Add((uint)agent_data.circuitcode, agent_data); + + return new XmlRpcResponse(); + }); + } + LoginServer loginServer = null; if (m_loginserver && m_sandbox) { - loginServer = new LoginServer(GridServers.GridServer, Cfg.IPListenAddr, Cfg.IPListenPort, this.user_accounts); + loginServer = new LoginServer(gridServer, Cfg.IPListenAddr, Cfg.IPListenPort, this.user_accounts); loginServer.Startup(); - + } - if((m_loginserver) && (m_sandbox) && (user_accounts)) + + if ((m_loginserver) && (m_sandbox) && (user_accounts)) { + //sandbox mode with loginserver using accounts this.GridServers.UserServer = loginServer; HttpServer.AddRestHandler("Admin", new AdminWebFront("Admin", LocalWorld, loginServer)); + HttpServer.AddXmlRPCHandler("login_to_simulator", loginServer.LocalUserManager.XmlRpcLoginMethod); } - else + else if ((m_loginserver) && (m_sandbox)) + { + //sandbox mode with loginserver not using accounts + HttpServer.AddRestHandler("Admin", new AdminWebFront("Admin", LocalWorld, null)); + HttpServer.AddXmlRPCHandler("login_to_simulator", loginServer.XmlRpcLoginMethod); + } + else { + //not in sandbox mode so no loginserver, so we don't handle login attempts HttpServer.AddRestHandler("Admin", new AdminWebFront("Admin", LocalWorld, null)); } + m_console.WriteLine("Main.cs:Startup() - Starting HTTP server"); + HttpServer.Start(); + MainServerListener(); timer1.Enabled = true; @@ -207,12 +248,12 @@ namespace OpenSim int numBytes = Server.EndReceiveFrom(result, ref epSender); int packetEnd = numBytes - 1; packet = Packet.BuildPacket(RecvBuffer, ref packetEnd, ZeroBuffer); - + // This is either a new client or a packet to send to an old one - // if (OpenSimRoot.Instance.ClientThreads.ContainsKey(epSender)) + // if (OpenSimRoot.Instance.ClientThreads.ContainsKey(epSender)) // do we already have a circuit for this endpoint - if(this.clientCircuits.ContainsKey(epSender)) + if (this.clientCircuits.ContainsKey(epSender)) { ClientThreads[this.clientCircuits[epSender]].InPacket(packet); } @@ -223,7 +264,6 @@ namespace OpenSim SimClient newuser = new SimClient(epSender, useCircuit, LocalWorld, ClientThreads, AssetCache, GridServers.GridServer, this, InventoryCache, m_sandbox); if ((this.GridServers.UserServer != null) && (user_accounts)) { - Console.WriteLine("setting userserver"); newuser.UserServer = this.GridServers.UserServer; } //OpenSimRoot.Instance.ClientThreads.Add(epSender, newuser); @@ -256,11 +296,11 @@ namespace OpenSim } - public virtual void SendPacketTo(byte[] buffer, int size, SocketFlags flags, uint circuitcode )//EndPoint packetSender) + public virtual void SendPacketTo(byte[] buffer, int size, SocketFlags flags, uint circuitcode)//EndPoint packetSender) { // find the endpoint for this circuit EndPoint sendto = null; - foreach(KeyValuePair p in this.clientCircuits) + foreach (KeyValuePair p in this.clientCircuits) { if (p.Value == circuitcode) { @@ -304,7 +344,7 @@ namespace OpenSim { LocalWorld.Update(); } - + public void RunCmd(string command, string[] cmdparams) { switch (command) @@ -353,5 +393,5 @@ namespace OpenSim } } - + } -- cgit v1.1