Added option to start in sandbox mode and to run a local login server
parent
ce70bd6b42
commit
e0f74692ad
|
@ -0,0 +1,73 @@
|
||||||
|
/*
|
||||||
|
* 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 <organization> 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 <copyright holder> ``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 <copyright holder> 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 libsecondlife;
|
||||||
|
|
||||||
|
namespace OpenSim.GridServers
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Description of IAssetServer.
|
||||||
|
/// </summary>
|
||||||
|
public class LocalAssetServer : IAssetServer
|
||||||
|
{
|
||||||
|
public LocalAssetServer()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetReceiver(IAssetReceived receiver)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
public void RequestAsset(LLUUID assetID)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
public void UpdateAsset()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
public void UploadNewAsset()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface IAssetServer
|
||||||
|
{
|
||||||
|
void SetReceiver(IAssetReceived receiver);
|
||||||
|
void RequestAsset(LLUUID assetID);
|
||||||
|
void UpdateAsset();
|
||||||
|
void UploadNewAsset();
|
||||||
|
}
|
||||||
|
|
||||||
|
// could change to delegate
|
||||||
|
public interface IAssetReceived
|
||||||
|
{
|
||||||
|
void AssetReceived();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,196 @@
|
||||||
|
/*
|
||||||
|
* 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 <organization> 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 <copyright holder> ``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 <copyright holder> 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.Net;
|
||||||
|
using System.Net.Sockets;
|
||||||
|
using System.IO;
|
||||||
|
using libsecondlife;
|
||||||
|
|
||||||
|
namespace OpenSim.GridServers
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Handles connection to Grid Servers.
|
||||||
|
/// also Sim to Sim connections?
|
||||||
|
/// </summary>
|
||||||
|
public class LocalGridServer :IGridServer
|
||||||
|
{
|
||||||
|
public List<Login> Sessions = new List<Login>();
|
||||||
|
|
||||||
|
public LocalGridServer()
|
||||||
|
{
|
||||||
|
Sessions = new List<Login>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool RequestConnection()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
public AuthenticateResponse AuthenticateSession(LLUUID sessionID, LLUUID agentID, uint circuitCode)
|
||||||
|
{
|
||||||
|
//For Grid use:
|
||||||
|
//should check to see if it is a teleportation, if so then we should be expecting this session, agent. (?)
|
||||||
|
//if not check with User server/ login server that it is authorised.
|
||||||
|
|
||||||
|
//but for now we are running local
|
||||||
|
AuthenticateResponse user = new AuthenticateResponse();
|
||||||
|
|
||||||
|
lock(this.Sessions)
|
||||||
|
{
|
||||||
|
|
||||||
|
for(int i = 0; i < Sessions.Count; i++)
|
||||||
|
{
|
||||||
|
if((Sessions[i].Agent == agentID) && (Sessions[i].Session == sessionID))
|
||||||
|
{
|
||||||
|
user.Authorised = true;
|
||||||
|
user.LoginInfo = Sessions[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return(user);
|
||||||
|
}
|
||||||
|
|
||||||
|
public UUIDBlock RequestUUIDBlock()
|
||||||
|
{
|
||||||
|
UUIDBlock uuidBlock = new UUIDBlock();
|
||||||
|
return(uuidBlock);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RequestNeighbours()
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// used by the local login server to inform us of new sessions
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="session"></param>
|
||||||
|
public void AddNewSession(Login session)
|
||||||
|
{
|
||||||
|
lock(this.Sessions)
|
||||||
|
{
|
||||||
|
this.Sessions.Add(session);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class RemoteGridServer :IGridServer
|
||||||
|
{
|
||||||
|
|
||||||
|
public RemoteGridServer()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool RequestConnection()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
public AuthenticateResponse AuthenticateSession(LLUUID sessionID, LLUUID agentID, uint circuitCode)
|
||||||
|
{
|
||||||
|
AuthenticateResponse user = new AuthenticateResponse();
|
||||||
|
|
||||||
|
WebRequest CheckSession = WebRequest.Create(OpenSim_Main.cfg.GridURL + "/usersessions/" + OpenSim_Main.cfg.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"))
|
||||||
|
{
|
||||||
|
// YAY! Valid login
|
||||||
|
user.Authorised = true;
|
||||||
|
user.LoginInfo = new Login();
|
||||||
|
user.LoginInfo.Agent = agentID;
|
||||||
|
user.LoginInfo.Session = sessionID;
|
||||||
|
user.LoginInfo.First = "";
|
||||||
|
user.LoginInfo.Last = "";
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Invalid
|
||||||
|
user.Authorised = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return(user);
|
||||||
|
}
|
||||||
|
|
||||||
|
public UUIDBlock RequestUUIDBlock()
|
||||||
|
{
|
||||||
|
UUIDBlock uuidBlock = new UUIDBlock();
|
||||||
|
return(uuidBlock);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RequestNeighbours()
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface IGridServer
|
||||||
|
{
|
||||||
|
bool RequestConnection();
|
||||||
|
UUIDBlock RequestUUIDBlock();
|
||||||
|
void RequestNeighbours(); //should return a array of neighbouring regions
|
||||||
|
AuthenticateResponse AuthenticateSession(LLUUID sessionID, LLUUID agentID, uint circuitCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
public struct UUIDBlock
|
||||||
|
{
|
||||||
|
public LLUUID BlockStart;
|
||||||
|
public LLUUID BlockEnd;
|
||||||
|
}
|
||||||
|
|
||||||
|
public class AuthenticateResponse
|
||||||
|
{
|
||||||
|
public bool Authorised;
|
||||||
|
public Login LoginInfo;
|
||||||
|
|
||||||
|
public AuthenticateResponse()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Login
|
||||||
|
{
|
||||||
|
public string First = "Test";
|
||||||
|
public string Last = "User";
|
||||||
|
public LLUUID Agent;
|
||||||
|
public LLUUID Session;
|
||||||
|
public LLUUID InventoryFolder;
|
||||||
|
public LLUUID BaseFolder;
|
||||||
|
public Login()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,322 @@
|
||||||
|
/*
|
||||||
|
* 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 <organization> 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 <copyright holder> ``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 <copyright holder> 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 Nwc.XmlRpc;
|
||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Net;
|
||||||
|
using System.Net.Sockets;
|
||||||
|
using System.Text;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Security.Cryptography;
|
||||||
|
using System.Xml;
|
||||||
|
using libsecondlife;
|
||||||
|
using OpenSim;
|
||||||
|
|
||||||
|
namespace OpenSim.GridServers
|
||||||
|
{
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// When running in local (default) mode , handles client logins.
|
||||||
|
/// </summary>
|
||||||
|
public class LoginServer
|
||||||
|
{
|
||||||
|
public LoginServer(IGridServer gridServer)
|
||||||
|
{
|
||||||
|
_gridServer = gridServer;
|
||||||
|
}
|
||||||
|
private Login _login;
|
||||||
|
private IGridServer _gridServer;
|
||||||
|
private ushort _loginPort = 8080;
|
||||||
|
public IPAddress clientAddress = IPAddress.Loopback;
|
||||||
|
public IPAddress remoteAddress = IPAddress.Any;
|
||||||
|
private Socket loginServer;
|
||||||
|
private Random RandomClass = new Random();
|
||||||
|
private int NumClients;
|
||||||
|
private string _defaultResponse;
|
||||||
|
|
||||||
|
private string _mpasswd;
|
||||||
|
private bool _needPasswd=false;
|
||||||
|
|
||||||
|
// InitializeLoginProxy: initialize the login proxy
|
||||||
|
private void InitializeLoginProxy() {
|
||||||
|
loginServer = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
|
||||||
|
loginServer.Bind(new IPEndPoint(remoteAddress, _loginPort));
|
||||||
|
loginServer.Listen(1);
|
||||||
|
|
||||||
|
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");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Startup()
|
||||||
|
{
|
||||||
|
this.InitializeLoginProxy();
|
||||||
|
Thread runLoginProxy = new Thread(new ThreadStart(RunLoginProxy));
|
||||||
|
runLoginProxy.IsBackground = true;
|
||||||
|
runLoginProxy.Start();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void RunLoginProxy()
|
||||||
|
{
|
||||||
|
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
|
||||||
|
{
|
||||||
|
ProxyLogin(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 ProxyLogin(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);
|
||||||
|
|
||||||
|
XmlRpcRequest request = (XmlRpcRequest)(new XmlRpcRequestDeserializer()).Deserialize(new String(content));
|
||||||
|
if(request.MethodName == "login_to_simulator")
|
||||||
|
{
|
||||||
|
Hashtable requestData = (Hashtable)request.Params[0];
|
||||||
|
string first;
|
||||||
|
string last;
|
||||||
|
string passwd;
|
||||||
|
LLUUID Agent;
|
||||||
|
LLUUID Session;
|
||||||
|
|
||||||
|
//get login name
|
||||||
|
if(requestData.Contains("first"))
|
||||||
|
{
|
||||||
|
first = (string)requestData["first"];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
first = "test";
|
||||||
|
}
|
||||||
|
|
||||||
|
if(requestData.Contains("last"))
|
||||||
|
{
|
||||||
|
last = (string)requestData["last"];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
last = "User"+NumClients.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(requestData.Contains("passwd"))
|
||||||
|
{
|
||||||
|
passwd = (string)requestData["passwd"];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
passwd = "notfound";
|
||||||
|
}
|
||||||
|
|
||||||
|
if( !Authenticate(first, last, passwd))
|
||||||
|
{
|
||||||
|
// Fail miserably
|
||||||
|
writer.WriteLine("HTTP/1.0 403 Authentication Forbidden");
|
||||||
|
writer.WriteLine();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
NumClients++;
|
||||||
|
|
||||||
|
//create a agent and session LLUUID
|
||||||
|
Agent = GetAgentId( first, last );
|
||||||
|
int SessionRand = this.RandomClass.Next(1,999);
|
||||||
|
Session = new LLUUID("aaaabbbb-0200-"+SessionRand.ToString("0000")+"-8664-58f53e442797");
|
||||||
|
|
||||||
|
|
||||||
|
XmlRpcResponse response =(XmlRpcResponse)(new XmlRpcResponseDeserializer()).Deserialize(this._defaultResponse);
|
||||||
|
Hashtable responseData = (Hashtable)response.Value;
|
||||||
|
|
||||||
|
responseData["sim_port"] = OpenSim_Main.cfg.IPListenPort;
|
||||||
|
responseData["sim_ip"] = OpenSim_Main.cfg.IPListenAddr;
|
||||||
|
responseData["agent_id"] = Agent.ToStringHyphenated();
|
||||||
|
responseData["session_id"] = Session.ToStringHyphenated();
|
||||||
|
ArrayList InventoryList = (ArrayList) responseData["inventory-skeleton"];
|
||||||
|
Hashtable Inventory1 = (Hashtable)InventoryList[0];
|
||||||
|
Hashtable Inventory2 = (Hashtable)InventoryList[1];
|
||||||
|
LLUUID BaseFolderID = LLUUID.Random();
|
||||||
|
LLUUID InventoryFolderID = LLUUID.Random();
|
||||||
|
Inventory2["name"] = "Base";
|
||||||
|
Inventory2["folder_id"] = BaseFolderID.ToStringHyphenated();
|
||||||
|
Inventory2["type_default"] =6;
|
||||||
|
Inventory1["folder_id"] = InventoryFolderID.ToStringHyphenated();
|
||||||
|
|
||||||
|
ArrayList InventoryRoot = (ArrayList) responseData["inventory-root"];
|
||||||
|
Hashtable Inventoryroot = (Hashtable)InventoryRoot[0];
|
||||||
|
Inventoryroot["folder_id"] = InventoryFolderID.ToStringHyphenated();
|
||||||
|
|
||||||
|
CustomiseLoginResponse( responseData, first, last );
|
||||||
|
|
||||||
|
this._login = new Login();
|
||||||
|
//copy data to login object
|
||||||
|
_login.First = first;
|
||||||
|
_login.Last = last;
|
||||||
|
_login.Agent = Agent;
|
||||||
|
_login.Session = Session;
|
||||||
|
_login.BaseFolder = BaseFolderID;
|
||||||
|
_login.InventoryFolder = InventoryFolderID;
|
||||||
|
|
||||||
|
//working on local computer so lets add to the gridserver's list of sessions
|
||||||
|
((LocalGridServer)this._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();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
writer.WriteLine("HTTP/1.0 403 Authentication Forbidden");
|
||||||
|
writer.WriteLine();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual void CustomiseLoginResponse( Hashtable responseData, string first, string last )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual LLUUID GetAgentId(string firstName, string lastName)
|
||||||
|
{
|
||||||
|
LLUUID Agent;
|
||||||
|
int AgentRand = this.RandomClass.Next(1,9999);
|
||||||
|
Agent = new LLUUID("99998888-0100-"+AgentRand.ToString("0000")+"-8ec1-0b1d5cd6aead");
|
||||||
|
return Agent;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual bool Authenticate(string first, string last, string passwd)
|
||||||
|
{
|
||||||
|
if(this._needPasswd)
|
||||||
|
{
|
||||||
|
//every user needs the password to login
|
||||||
|
string encodedPass = passwd.Remove(0,3); //remove $1$
|
||||||
|
if(encodedPass == this._mpasswd)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//do not need password to login
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string EncodePassword(string passwd)
|
||||||
|
{
|
||||||
|
Byte[] originalBytes;
|
||||||
|
Byte[] encodedBytes;
|
||||||
|
MD5 md5;
|
||||||
|
|
||||||
|
md5 = new MD5CryptoServiceProvider();
|
||||||
|
originalBytes = ASCIIEncoding.Default.GetBytes(passwd);
|
||||||
|
encodedBytes = md5.ComputeHash(originalBytes);
|
||||||
|
|
||||||
|
return Regex.Replace(BitConverter.ToString(encodedBytes), "-", "").ToLower();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
73
Main.cs
73
Main.cs
|
@ -39,6 +39,7 @@ using System.Collections.Generic;
|
||||||
using libsecondlife;
|
using libsecondlife;
|
||||||
using libsecondlife.Packets;
|
using libsecondlife.Packets;
|
||||||
using OpenSim.world;
|
using OpenSim.world;
|
||||||
|
using OpenSim.GridServers;
|
||||||
using PhysicsSystem;
|
using PhysicsSystem;
|
||||||
|
|
||||||
namespace OpenSim
|
namespace OpenSim
|
||||||
|
@ -51,8 +52,9 @@ namespace OpenSim
|
||||||
public static OpenSim_Main sim;
|
public static OpenSim_Main sim;
|
||||||
public static SimConfig cfg;
|
public static SimConfig cfg;
|
||||||
public static World local_world;
|
public static World local_world;
|
||||||
private static Thread MainListener;
|
public static Grid gridServers;
|
||||||
private static Thread PingRespponder;
|
//private static Thread MainListener;
|
||||||
|
//private static Thread PingRespponder;
|
||||||
public static Socket Server;
|
public static Socket Server;
|
||||||
private static IPEndPoint ServerIncoming;
|
private static IPEndPoint ServerIncoming;
|
||||||
private static byte[] RecvBuffer = new byte[4096];
|
private static byte[] RecvBuffer = new byte[4096];
|
||||||
|
@ -69,7 +71,37 @@ namespace OpenSim
|
||||||
{
|
{
|
||||||
//Console.WriteLine("OpenSim " + VersionInfo.Version + "\n");
|
//Console.WriteLine("OpenSim " + VersionInfo.Version + "\n");
|
||||||
Console.WriteLine("Starting...\n");
|
Console.WriteLine("Starting...\n");
|
||||||
sim = new OpenSim_Main();
|
sim = new OpenSim_Main();
|
||||||
|
|
||||||
|
bool sandbox = false;
|
||||||
|
bool loginserver = false;
|
||||||
|
for (int i = 0; i < args.Length; i++)
|
||||||
|
{
|
||||||
|
if(args[i] == "-sandbox")
|
||||||
|
{
|
||||||
|
sandbox = true;
|
||||||
|
}
|
||||||
|
if(args[i] == "-loginserver")
|
||||||
|
{
|
||||||
|
loginserver = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(sandbox)
|
||||||
|
{
|
||||||
|
OpenSim_Main.gridServers = new Grid(true);
|
||||||
|
Console.WriteLine("Starting in Sandbox mode");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
OpenSim_Main.gridServers = new Grid(false);
|
||||||
|
Console.WriteLine("Starting in Grid mode");
|
||||||
|
}
|
||||||
|
if(loginserver && sandbox)
|
||||||
|
{
|
||||||
|
LoginServer loginServer = new LoginServer(OpenSim_Main.gridServers.GridServer);
|
||||||
|
loginServer.Startup();
|
||||||
|
}
|
||||||
|
|
||||||
sim.Startup();
|
sim.Startup();
|
||||||
while(true) {
|
while(true) {
|
||||||
Thread.Sleep(1000);
|
Thread.Sleep(1000);
|
||||||
|
@ -100,8 +132,9 @@ namespace OpenSim
|
||||||
Console.WriteLine("Main.cs:Startup() - Starting up messaging system");
|
Console.WriteLine("Main.cs:Startup() - Starting up messaging system");
|
||||||
local_world.PhysScene = this.physManager.GetPhysicsScene("PhysX"); //should be reading from the config file what physics engine to use
|
local_world.PhysScene = this.physManager.GetPhysicsScene("PhysX"); //should be reading from the config file what physics engine to use
|
||||||
|
|
||||||
MainListener = new Thread(new ThreadStart(MainServerListener));
|
//MainListener = new Thread(new ThreadStart(MainServerListener));
|
||||||
MainListener.Start();
|
//MainListener.Start();
|
||||||
|
MainServerListener();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -142,14 +175,34 @@ namespace OpenSim
|
||||||
Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null);
|
Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null);
|
||||||
|
|
||||||
Console.WriteLine("Main.cs:MainServerListener() - Listening...");
|
Console.WriteLine("Main.cs:MainServerListener() - Listening...");
|
||||||
while(true) {
|
/*while(true) {
|
||||||
Thread.Sleep(1000);
|
Thread.Sleep(1000);
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
void Timer1Tick( object sender, System.EventArgs e )
|
void Timer1Tick( object sender, System.EventArgs e )
|
||||||
{
|
{
|
||||||
local_world.Update();
|
local_world.Update();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Grid
|
||||||
|
{
|
||||||
|
public IAssetServer AssetServer;
|
||||||
|
public IGridServer GridServer;
|
||||||
|
|
||||||
|
public Grid(bool sandbox)
|
||||||
|
{
|
||||||
|
if(sandbox)
|
||||||
|
{
|
||||||
|
this.AssetServer =(IAssetServer) new LocalAssetServer();
|
||||||
|
this.GridServer =(IGridServer) new LocalGridServer();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.AssetServer =(IAssetServer) new LocalAssetServer(); //assets not implemented yet
|
||||||
|
this.GridServer =(IGridServer) new RemoteGridServer();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,6 +34,7 @@ using System.Net.Sockets;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Timers;
|
using System.Timers;
|
||||||
|
using OpenSim.GridServers;
|
||||||
|
|
||||||
namespace OpenSim
|
namespace OpenSim
|
||||||
{
|
{
|
||||||
|
@ -45,6 +46,8 @@ namespace OpenSim
|
||||||
|
|
||||||
public LLUUID AgentID;
|
public LLUUID AgentID;
|
||||||
public LLUUID SessionID;
|
public LLUUID SessionID;
|
||||||
|
private string AgentFirstName;
|
||||||
|
private string AgentLastName;
|
||||||
public uint CircuitCode;
|
public uint CircuitCode;
|
||||||
public world.Avatar ClientAvatar;
|
public world.Avatar ClientAvatar;
|
||||||
private UseCircuitCodePacket cirpack;
|
private UseCircuitCodePacket cirpack;
|
||||||
|
@ -79,7 +82,7 @@ namespace OpenSim
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AssetLoader() {
|
public void AssetLoader() {
|
||||||
|
/*
|
||||||
Console.WriteLine("OpenSimClient.cs:AssetLoader() - Starting new thread");
|
Console.WriteLine("OpenSimClient.cs:AssetLoader() - Starting new thread");
|
||||||
TransferRequestPacket reqPacket = AssetRequests.Dequeue();
|
TransferRequestPacket reqPacket = AssetRequests.Dequeue();
|
||||||
Console.WriteLine("OpenSimClient.cs:AssetLoader() - Got a request, processing it");
|
Console.WriteLine("OpenSimClient.cs:AssetLoader() - Got a request, processing it");
|
||||||
|
@ -128,7 +131,7 @@ namespace OpenSim
|
||||||
OutPacket(TransferPacket);
|
OutPacket(TransferPacket);
|
||||||
}
|
}
|
||||||
AssetResponse.Close();
|
AssetResponse.Close();
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ProcessInPacket(Packet Pack) {
|
public void ProcessInPacket(Packet Pack) {
|
||||||
|
@ -145,12 +148,12 @@ namespace OpenSim
|
||||||
ClientAvatar.SendInitialAppearance();
|
ClientAvatar.SendInitialAppearance();
|
||||||
break;
|
break;
|
||||||
case PacketType.TransferRequest:
|
case PacketType.TransferRequest:
|
||||||
Console.WriteLine("OpenSimClient.cs:ProcessInPacket() - Got transfer request");
|
//Console.WriteLine("OpenSimClient.cs:ProcessInPacket() - Got transfer request");
|
||||||
// We put transfer requests into a big queue and then spawn a thread for each new one
|
// We put transfer requests into a big queue and then spawn a thread for each new one
|
||||||
TransferRequestPacket transfer = (TransferRequestPacket)Pack;
|
//TransferRequestPacket transfer = (TransferRequestPacket)Pack;
|
||||||
AssetRequests.Enqueue(transfer);
|
//AssetRequests.Enqueue(transfer);
|
||||||
Thread AssetLoaderThread = new Thread(new ThreadStart(AssetLoader));
|
//Thread AssetLoaderThread = new Thread(new ThreadStart(AssetLoader));
|
||||||
AssetLoaderThread.Start();
|
//AssetLoaderThread.Start();
|
||||||
break;
|
break;
|
||||||
case PacketType.AgentUpdate:
|
case PacketType.AgentUpdate:
|
||||||
ClientAvatar.HandleUpdate((AgentUpdatePacket)Pack);
|
ClientAvatar.HandleUpdate((AgentUpdatePacket)Pack);
|
||||||
|
@ -404,35 +407,32 @@ namespace OpenSim
|
||||||
OpenSim_Main.local_world.AddViewerAgent(this);
|
OpenSim_Main.local_world.AddViewerAgent(this);
|
||||||
world.Entity tempent=OpenSim_Main.local_world.Entities[this.AgentID];
|
world.Entity tempent=OpenSim_Main.local_world.Entities[this.AgentID];
|
||||||
this.ClientAvatar=(world.Avatar)tempent;
|
this.ClientAvatar=(world.Avatar)tempent;
|
||||||
|
this.ClientAvatar.firstname = this.AgentFirstName;
|
||||||
|
this.ClientAvatar.lastname = this.AgentLastName;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AuthUser() {
|
private void AuthUser()
|
||||||
Console.WriteLine("OpenSimClient.cs:AuthUser() - Authenticating new user request with grid");
|
{
|
||||||
WebRequest CheckSession = WebRequest.Create(OpenSim_Main.cfg.GridURL + "/usersessions/" + OpenSim_Main.cfg.GridSendKey + "/" + cirpack.CircuitCode.ID.ToString() + "/" + cirpack.CircuitCode.Code.ToString() + "/exists");
|
AuthenticateResponse sessionInfo = OpenSim_Main.gridServers.GridServer.AuthenticateSession(cirpack.CircuitCode.SessionID, cirpack.CircuitCode.ID, cirpack.CircuitCode.Code);
|
||||||
WebResponse GridResponse = CheckSession.GetResponse();
|
if(!sessionInfo.Authorised)
|
||||||
StreamReader sr = new StreamReader(GridResponse.GetResponseStream());
|
{
|
||||||
String grTest = sr.ReadLine();
|
//session/circuit not authorised
|
||||||
sr.Close();
|
Console.WriteLine("OpenSimClient.cs:AuthUser() - New user request denied to " + userEP.ToString());
|
||||||
GridResponse.Close();
|
ClientThread.Abort();
|
||||||
if(String.IsNullOrEmpty(grTest) || grTest.Equals("1")) { // YAY! Valid login
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
Console.WriteLine("OpenSimClient.cs:AuthUser() - Got authenticated connection from " + userEP.ToString());
|
Console.WriteLine("OpenSimClient.cs:AuthUser() - Got authenticated connection from " + userEP.ToString());
|
||||||
|
//session is authorised
|
||||||
|
this.AgentFirstName = sessionInfo.LoginInfo.First;
|
||||||
|
this.AgentLastName = sessionInfo.LoginInfo.Last;
|
||||||
this.AgentID=cirpack.CircuitCode.ID;
|
this.AgentID=cirpack.CircuitCode.ID;
|
||||||
this.SessionID=cirpack.CircuitCode.SessionID;
|
this.SessionID=cirpack.CircuitCode.SessionID;
|
||||||
this.CircuitCode=cirpack.CircuitCode.Code;
|
this.CircuitCode=cirpack.CircuitCode.Code;
|
||||||
InitNewClient();
|
InitNewClient();
|
||||||
ClientLoop();
|
ClientLoop();
|
||||||
} else { // Invalid
|
|
||||||
Console.WriteLine("OpenSimClient.cs:AuthUser() - New user request denied to " + userEP.ToString());
|
|
||||||
ClientThread.Abort();
|
|
||||||
}
|
}
|
||||||
// quick hack so we don't use the grid server for local testing
|
}
|
||||||
/*this.AgentID=cirpack.CircuitCode.ID;
|
|
||||||
this.SessionID=cirpack.CircuitCode.SessionID;
|
|
||||||
this.CircuitCode=cirpack.CircuitCode.Code;
|
|
||||||
InitNewClient();
|
|
||||||
ClientLoop();
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,6 +65,12 @@
|
||||||
<Compile Include="world\SurfacePatch.cs" />
|
<Compile Include="world\SurfacePatch.cs" />
|
||||||
<Compile Include="world\TerrainDecoder.cs" />
|
<Compile Include="world\TerrainDecoder.cs" />
|
||||||
<Compile Include="world\World.cs" />
|
<Compile Include="world\World.cs" />
|
||||||
|
<Compile Include="GridServers\IGridServer.cs" />
|
||||||
|
<Compile Include="GridServers\IAssetServer.cs" />
|
||||||
|
<Compile Include="GridServers\LoginServer.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Folder Include="GridServers" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
|
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
|
||||||
</Project>
|
</Project>
|
|
@ -114,6 +114,8 @@ namespace PhysicsSystem
|
||||||
|
|
||||||
public abstract void GetResults();
|
public abstract void GetResults();
|
||||||
|
|
||||||
|
public abstract void SetTerrain(float[] heightMap);
|
||||||
|
|
||||||
public abstract bool IsThreaded
|
public abstract bool IsThreaded
|
||||||
{
|
{
|
||||||
get;
|
get;
|
||||||
|
|
|
@ -126,6 +126,11 @@ namespace PhysXplugin
|
||||||
return(false); // for now we won't be multithreaded
|
return(false); // for now we won't be multithreaded
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void SetTerrain(float[] heightMap)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class PhysXActor : PhysicsActor
|
public class PhysXActor : PhysicsActor
|
||||||
|
|
|
@ -4,4 +4,14 @@ Microsoft Visual Studio Solution File, Format Version 9.00
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PhysXplugin", "PhysXplugin.csproj", "{ADB751AA-8426-4668-B1FA-43762126CEB3}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PhysXplugin", "PhysXplugin.csproj", "{ADB751AA-8426-4668-B1FA-43762126CEB3}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{ADB751AA-8426-4668-B1FA-43762126CEB3}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{ADB751AA-8426-4668-B1FA-43762126CEB3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{ADB751AA-8426-4668-B1FA-43762126CEB3}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{ADB751AA-8426-4668-B1FA-43762126CEB3}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
EndGlobal
|
EndGlobal
|
||||||
|
|
Loading…
Reference in New Issue