From 761db20c5fdc155a8319c1a3efcad05eafe9acc2 Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Thu, 29 Mar 2007 18:21:04 +0000 Subject: * Tried to make the sandbox/useraccount sim setup a bit simpler * Removed some comments --- OpenSim.RegionServer/OpenSimMain.cs | 51 ++++---- .../UserServer/LocalUserProfileManager.cs | 27 ++++ OpenSim.RegionServer/UserServer/LoginServer.cs | 145 --------------------- 3 files changed, 52 insertions(+), 171 deletions(-) (limited to 'OpenSim.RegionServer') diff --git a/OpenSim.RegionServer/OpenSimMain.cs b/OpenSim.RegionServer/OpenSimMain.cs index 651c0c6..51ec12b 100644 --- a/OpenSim.RegionServer/OpenSimMain.cs +++ b/OpenSim.RegionServer/OpenSimMain.cs @@ -73,7 +73,7 @@ namespace OpenSim private EndPoint epSender; private AsyncCallback ReceivedData; - private System.Timers.Timer timer1 = new System.Timers.Timer(); + private System.Timers.Timer m_heartbeatTimer = new System.Timers.Timer(); private string ConfigDll = "OpenSim.Config.SimConfigDb4o.dll"; public string m_physicsEngine; public bool m_sandbox = false; @@ -176,40 +176,39 @@ namespace OpenSim LoginServer loginServer = null; - if (m_loginserver && m_sandbox) + LoginServer adminLoginServer = null; + + bool sandBoxWithLoginServer = m_loginserver && m_sandbox; + if (sandBoxWithLoginServer) { loginServer = new LoginServer(gridServer, Cfg.IPListenAddr, Cfg.IPListenPort, this.user_accounts); loginServer.Startup(); - - } - - 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 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)); + + if( user_accounts ) + { + //sandbox mode with loginserver using accounts + this.GridServers.UserServer = loginServer; + adminLoginServer = loginServer; + + HttpServer.AddXmlRPCHandler("login_to_simulator", loginServer.LocalUserManager.XmlRpcLoginMethod); + } + else + { + //sandbox mode with loginserver not using accounts + HttpServer.AddXmlRPCHandler("login_to_simulator", loginServer.XmlRpcLoginMethod); + } } + HttpServer.AddRestHandler("Admin", new AdminWebFront("Admin", LocalWorld, adminLoginServer )); + m_console.WriteLine("Main.cs:Startup() - Starting HTTP server"); HttpServer.Start(); MainServerListener(); - timer1.Enabled = true; - timer1.Interval = 100; - timer1.Elapsed += new ElapsedEventHandler(this.Timer1Tick); + m_heartbeatTimer.Enabled = true; + m_heartbeatTimer.Interval = 100; + m_heartbeatTimer.Elapsed += new ElapsedEventHandler(this.Heartbeat); } private SimConfig LoadConfigDll(string dllName) @@ -340,7 +339,7 @@ namespace OpenSim Environment.Exit(0); } - void Timer1Tick(object sender, System.EventArgs e) + void Heartbeat(object sender, System.EventArgs e) { LocalWorld.Update(); } diff --git a/OpenSim.RegionServer/UserServer/LocalUserProfileManager.cs b/OpenSim.RegionServer/UserServer/LocalUserProfileManager.cs index 3ae7878..6166e02 100644 --- a/OpenSim.RegionServer/UserServer/LocalUserProfileManager.cs +++ b/OpenSim.RegionServer/UserServer/LocalUserProfileManager.cs @@ -1,3 +1,30 @@ +/* +* Copyright (c) OpenSim project, http://sim.opensecondlife.org/ +* +* 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.Collections.Generic; using System.Collections; diff --git a/OpenSim.RegionServer/UserServer/LoginServer.cs b/OpenSim.RegionServer/UserServer/LoginServer.cs index a68e013..4c77389 100644 --- a/OpenSim.RegionServer/UserServer/LoginServer.cs +++ b/OpenSim.RegionServer/UserServer/LoginServer.cs @@ -84,28 +84,16 @@ namespace OpenSim.UserServer public void Startup() { - this.InitializeLogin(); - //Thread runLoginProxy = new Thread(new ThreadStart(RunLogin)); - //runLoginProxy.IsBackground = true; - //runLoginProxy.Start(); - } - - // InitializeLogin: initialize the login - private void InitializeLogin() - { this._needPasswd = false; //read in default response string StreamReader SR; string lines; SR = File.OpenText("new-login.dat"); - //lines=SR.ReadLine(); - while (!SR.EndOfStream) { lines = SR.ReadLine(); _defaultResponse += lines; - //lines = SR.ReadLine(); } SR.Close(); this._mpasswd = EncodePassword("testpass"); @@ -113,118 +101,8 @@ namespace OpenSim.UserServer userManager = new LocalUserProfileManager(this.m_gridServer, m_simPort, m_simAddr); userManager.InitUserProfiles(); userManager.SetKeys("", "", "", "Welcome to OpenSim"); - - //loginServer = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); - // loginServer.Bind(new IPEndPoint(remoteAddress, _loginPort)); - //loginServer.Listen(1); } - /* private void RunLogin() - { - Console.WriteLine("Starting Login Server"); - try - { - for (; ; ) - { - Socket client = loginServer.Accept(); - IPEndPoint clientEndPoint = (IPEndPoint)client.RemoteEndPoint; - - - NetworkStream networkStream = new NetworkStream(client); - StreamReader networkReader = new StreamReader(networkStream); - StreamWriter networkWriter = new StreamWriter(networkStream); - - try - { - LoginRequest(networkReader, networkWriter); - } - catch (Exception e) - { - Console.WriteLine(e.Message); - } - - networkWriter.Close(); - networkReader.Close(); - networkStream.Close(); - - client.Close(); - - // send any packets queued for injection - - } - } - catch (Exception e) - { - Console.WriteLine(e.Message); - Console.WriteLine(e.StackTrace); - } - } - - // ProxyLogin: proxy a login request - private void LoginRequest(StreamReader reader, StreamWriter writer) - { - lock (this) - { - string line; - int contentLength = 0; - // read HTTP header - do - { - // read one line of the header - line = reader.ReadLine(); - - // check for premature EOF - if (line == null) - throw new Exception("EOF in client HTTP header"); - - // look for Content-Length - Match match = (new Regex(@"Content-Length: (\d+)$")).Match(line); - if (match.Success) - contentLength = Convert.ToInt32(match.Groups[1].Captures[0].ToString()); - } while (line != ""); - - // read the HTTP body into a buffer - char[] content = new char[contentLength]; - reader.Read(content, 0, contentLength); - - if (this.userAccounts) - { - //ask the UserProfile Manager to process the request - string reply = this.userManager.ParseXMLRPC(new String(content)); - // forward the XML-RPC response to the client - writer.WriteLine("HTTP/1.0 200 OK"); - writer.WriteLine("Content-type: text/xml"); - writer.WriteLine(); - writer.WriteLine(reply); - } - else - { - //handle ourselves - XmlRpcRequest request = (XmlRpcRequest)(new XmlRpcRequestDeserializer()).Deserialize(new String(content)); - if (request.MethodName == "login_to_simulator") - { - this.ProcessXmlRequest(request, writer); - } - else - { - XmlRpcResponse PresenceErrorResp = new XmlRpcResponse(); - Hashtable PresenceErrorRespData = new Hashtable(); - PresenceErrorRespData["reason"] = "XmlRequest"; ; - PresenceErrorRespData["message"] = "Unknown Rpc request"; - PresenceErrorRespData["login"] = "false"; - PresenceErrorResp.Value = PresenceErrorRespData; - string reply = Regex.Replace(XmlRpcResponseSerializer.Singleton.Serialize(PresenceErrorResp), " encoding=\"utf-16\"", ""); - writer.WriteLine("HTTP/1.0 200 OK"); - writer.WriteLine("Content-type: text/xml"); - writer.WriteLine(); - writer.WriteLine(reply); - } - } - } - } - */ - //public bool ProcessXmlRequest(XmlRpcRequest request, StreamWriter writer) - public XmlRpcResponse XmlRpcLoginMethod(XmlRpcRequest request) { Console.WriteLine("login attempt"); @@ -267,19 +145,6 @@ namespace OpenSim.UserServer if (!Authenticate(first, last, passwd)) { - /* XmlRpcResponse PresenceErrorResp = new XmlRpcResponse(); - Hashtable PresenceErrorRespData = new Hashtable(); - PresenceErrorRespData["reason"] = "key"; ; - PresenceErrorRespData["message"] = "You have entered an invalid name/password combination. Check Caps/lock."; - PresenceErrorRespData["login"] = "false"; - PresenceErrorResp.Value = PresenceErrorRespData; - string reply = Regex.Replace(XmlRpcResponseSerializer.Singleton.Serialize(PresenceErrorResp), " encoding=\"utf-16\"", ""); - writer.WriteLine("HTTP/1.0 200 OK"); - writer.WriteLine("Content-type: text/xml"); - writer.WriteLine(); - writer.WriteLine(reply); - return false;*/ - Hashtable loginError = new Hashtable(); loginError["reason"] = "key"; ; loginError["message"] = "You have entered an invalid name/password combination. Check Caps/lock."; @@ -356,15 +221,6 @@ namespace OpenSim.UserServer ((LocalGridBase)m_gridServer).AddNewSession(_login); } - /* // forward the XML-RPC response to the client - writer.WriteLine("HTTP/1.0 200 OK"); - writer.WriteLine("Content-type: text/xml"); - writer.WriteLine(); - - XmlTextWriter responseWriter = new XmlTextWriter(writer); - XmlRpcResponseSerializer.Singleton.Serialize(responseWriter, response); - responseWriter.Close();*/ - return response; } @@ -445,7 +301,6 @@ namespace OpenSim.UserServer { } - } -- cgit v1.1