Moved circuit authorisation to the ClientConnection class

standalone
MW 2007-02-17 10:50:19 +00:00
parent 6ce493947d
commit 10956993b7
6 changed files with 68 additions and 57 deletions

View File

@ -61,10 +61,6 @@ namespace OpenSim
formatter.RegisterField<AssetBase>(new AssetBaseField(formatter));
}
~BerkeleyDatabases()
{
this.Close();
}
public BerkeleyDatabases dbs;

View File

@ -42,7 +42,9 @@ namespace OpenSim
public static SceneGraph Scene;
public static AgentManager AgentManager;
public static PrimManager PrimManager;
public static UserServer UserServer;
public byte ConnectionType=1;
private bool _authorised = false;
private Thread _mthread;
@ -69,32 +71,29 @@ namespace OpenSim
{
case PacketType.UseCircuitCode:
Console.WriteLine("new circuit");
//should be a new user/circuit joining
// add agents profile to agentmanager
string first = "",last ="";
LLUUID baseFolder = null, inventoryFolder =null;
//rather than use IncomingLogins list, the logon object could be passed to this connection on creation
lock(Globals.Instance.IncomingLogins)
//should check that this session/circuit is authorised
UseCircuitCodePacket circuitPacket=(UseCircuitCodePacket)packet;
AuthenticateResponse sessionInfo = UserServer.AuthenticateSession(circuitPacket.CircuitCode.SessionID, circuitPacket.CircuitCode.ID, circuitPacket.CircuitCode.Code);
if(!sessionInfo.Authorised)
{
for(int i = 0; i < Globals.Instance.IncomingLogins.Count; i++)
{
if(Globals.Instance.IncomingLogins[i].Agent == this.NetInfo.User.AgentID)
{
first = Globals.Instance.IncomingLogins[i].First;
last = Globals.Instance.IncomingLogins[i].Last;
baseFolder = Globals.Instance.IncomingLogins[i].BaseFolder;
inventoryFolder = Globals.Instance.IncomingLogins[i].InventoryFolder;
Globals.Instance.IncomingLogins.RemoveAt(i);
break;
}
}
//session/circuit not authorised
//so do something about it
}
if(first != "")
else
{
//is authorised
string first = "",last ="";
LLUUID baseFolder = null, inventoryFolder =null;
first = sessionInfo.LogonInfo.First;
last = sessionInfo.LogonInfo.Last;
baseFolder = sessionInfo.LogonInfo.BaseFolder;
inventoryFolder = sessionInfo.LogonInfo.InventoryFolder;
AgentManager.NewAgent(this.NetInfo, first, last, baseFolder, inventoryFolder);
this._authorised = true;
}
break;
//should check this circuit is authorised before processing any other packets
case PacketType.CompleteAgentMovement:
//Agent completing movement to region
// so send region handshake

View File

@ -47,7 +47,7 @@ namespace OpenSim
public static void Main(string[] args)
{
Controller c = new Controller();
bool Run=true;
bool Run = true;
while( Run )
{
@ -74,6 +74,7 @@ namespace OpenSim
ClientConnection.Grid = _gridManager;
ClientConnection.Scene = _scene;
ClientConnection.AgentManager = _agentManager;
ClientConnection.UserServer = _backboneServers.UserServer;
_viewerServer.Startup();
BerkeleyDatabases.Instance.Startup();
_primManager = new PrimManager();

View File

@ -51,8 +51,9 @@ namespace OpenSim
PrimAsset prim1 = this._localPrimDB.GetPrimFromStroage( new LLUUID("00000000-0000-0000-0000-000000000008"));
Console.WriteLine("prim recieved : "+prim1.Name + " "+ prim1.Description);
*/
//this._localPrimDB.ReadWholedatabase();
*/
}
}

View File

@ -41,6 +41,8 @@ namespace OpenSim
{
public Node RootNode;
public Terrain Terrain;
private Thread _mthread;
private PhysicsManager _physics;
private Server _server;
private System.Text.Encoding _enc = System.Text.Encoding.ASCII;
@ -71,6 +73,28 @@ namespace OpenSim
_updateSender.Startup();
}
public void Startup()
{
_mthread = new Thread(new System.Threading.ThreadStart(RunScene));
_mthread.IsBackground = true;
_mthread.Start();
}
public void RunScene()
{
try
{
for(;;)
{
this.Update();
}
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
}
public void Update()
{
// run physics engine to update positions etc since last frame
@ -516,7 +540,7 @@ namespace OpenSim
public class UpdateSender
{
public BlockingQueue<SendInfo> SendList;
private Thread mthread;
private Thread _mthread;
private Server _server;
private AgentManager _agentManager;
@ -529,9 +553,9 @@ namespace OpenSim
public void Startup()
{
mthread = new Thread(new System.Threading.ThreadStart(RunSender));
mthread.IsBackground = true;
mthread.Start();
_mthread = new Thread(new System.Threading.ThreadStart(RunSender));
_mthread.IsBackground = true;
_mthread.Start();
}
private void RunSender()

View File

@ -117,14 +117,14 @@ namespace OpenSim
private System.Timers.Timer AckTimer;
private Server_Settings Settings=new Server_Settings();
public ArrayList User_agents=new ArrayList();
private IUserServer _userServer;
//private IUserServer _userServer;
/// <summary>
///
/// </summary>
public Server(IUserServer userServer)
{
this._userServer = userServer;
//this._userServer = userServer;
}
/// <summary>
@ -429,24 +429,8 @@ namespace OpenSim
if (packet.Type == PacketType.UseCircuitCode)
{
//new connection
//for now it isn't authorised but we will let the clientconnection thread deal with that
UseCircuitCodePacket cir_pack=(UseCircuitCodePacket)packet;
//should check that this session/circuit is authorised
AuthenticateResponse sessionInfo = this._userServer.AuthenticateSession(cir_pack.CircuitCode.SessionID, cir_pack.CircuitCode.ID, cir_pack.CircuitCode.Code);
if(!sessionInfo.Authorised)
{
//session/circuit not authorised
//so do something about it
}
else
{
//is authorised so add the logon object to the incominglogin list
//should be a better way of doing this now the login server connects to the user server
// like passing the logon object straight to the ClientConnection
lock(Globals.Instance.IncomingLogins)
{
Globals.Instance.IncomingLogins.Add(sessionInfo.LogonInfo);
}
}
NetworkInfo new_user=new NetworkInfo();
new_user.CircuitCode=cir_pack.CircuitCode.Code;
new_user.User.AgentID=cir_pack.CircuitCode.ID;
@ -458,7 +442,10 @@ namespace OpenSim
new_user.Connection.Start();
//this.CallbackObject.NewUserCallback(new_user);
lock(this.User_agents)
{
this.User_agents.Add(new_user);
}
}
@ -466,17 +453,20 @@ namespace OpenSim
IPEndPoint send_ip=(IPEndPoint)epSender;
// this.callback_object.error("incoming: address is "+send_ip.Address +"port number is: "+send_ip.Port.ToString());
for(int ii=0; ii<this.User_agents.Count ; ii++)
lock(this.User_agents)
{
temp_agent=(NetworkInfo)this.User_agents[ii];
IPEndPoint ag_ip=(IPEndPoint)temp_agent.endpoint;
//this.callback_object.error("searching: address is "+ag_ip.Address +"port number is: "+ag_ip.Port.ToString());
if((ag_ip.Address.ToString()==send_ip.Address.ToString()) && (ag_ip.Port.ToString()==send_ip.Port.ToString()))
for(int ii=0; ii<this.User_agents.Count ; ii++)
{
//this.callback_object.error("found user");
User_info=temp_agent;
break;
temp_agent=(NetworkInfo)this.User_agents[ii];
IPEndPoint ag_ip=(IPEndPoint)temp_agent.endpoint;
//this.callback_object.error("searching: address is "+ag_ip.Address +"port number is: "+ag_ip.Port.ToString());
if((ag_ip.Address.ToString()==send_ip.Address.ToString()) && (ag_ip.Port.ToString()==send_ip.Port.ToString()))
{
//this.callback_object.error("found user");
User_info=temp_agent;
break;
}
}
}