Added sandbox mode and setup facility
parent
ea28985d05
commit
560b46357e
106
src/Config.cs
106
src/Config.cs
|
@ -53,25 +53,81 @@ namespace OpenSim
|
|||
public int IPListenPort;
|
||||
public string IPListenAddr;
|
||||
|
||||
public string AssetURL;
|
||||
public string AssetSendKey;
|
||||
public bool sandbox;
|
||||
public string AssetURL="";
|
||||
public string AssetSendKey="";
|
||||
|
||||
public string GridURL;
|
||||
public string GridSendKey;
|
||||
public string GridURL="";
|
||||
public string GridSendKey="";
|
||||
|
||||
private IObjectContainer db;
|
||||
|
||||
public void LoadDefaults() {
|
||||
this.RegionName = "OpenSim test\0";
|
||||
this.RegionLocX = 997;
|
||||
this.RegionLocY = 996;
|
||||
string tempstring;
|
||||
Console.WriteLine("Config.cs:LoadDefaults() - Please press enter to retain default or enter new settings");
|
||||
Console.Write("Name [OpenSim test]:");
|
||||
tempstring=Console.ReadLine();
|
||||
if(tempstring=="") {
|
||||
this.RegionName = "OpenSim test";
|
||||
} else {
|
||||
this.RegionName = tempstring;
|
||||
}
|
||||
|
||||
Console.Write("Grid location X [997]:");
|
||||
tempstring=Console.ReadLine();
|
||||
if(tempstring=="") {
|
||||
this.RegionLocX = 997;
|
||||
} else {
|
||||
this.RegionLocX = (uint)Convert.ToInt32(tempstring);
|
||||
}
|
||||
|
||||
Console.Write("Grid location Y [996]:");
|
||||
tempstring=Console.ReadLine();
|
||||
if(tempstring=="") {
|
||||
this.RegionLocY = 996;
|
||||
} else {
|
||||
this.RegionLocY = (uint)Convert.ToInt32(tempstring);
|
||||
}
|
||||
|
||||
Console.Write("Listen on UDP port for client connections [9000]:");
|
||||
tempstring=Console.ReadLine();
|
||||
if(tempstring=="") {
|
||||
this.IPListenPort = 9000;
|
||||
} else {
|
||||
this.IPListenPort = Convert.ToInt32(tempstring);
|
||||
}
|
||||
|
||||
Console.Write("Listen on IP address for client connections [127.0.0.1]:");
|
||||
tempstring=Console.ReadLine();
|
||||
if(tempstring=="") {
|
||||
this.IPListenAddr = "127.0.0.1";
|
||||
} else {
|
||||
this.IPListenAddr = tempstring;
|
||||
}
|
||||
|
||||
|
||||
Console.Write("Run in sandbox or grid mode? [sandbox]:");
|
||||
tempstring=Console.ReadLine();
|
||||
if(tempstring=="") {
|
||||
this.sandbox = true;
|
||||
} else if(tempstring=="grid"){
|
||||
this.sandbox = false;
|
||||
} else if(tempstring=="sandbox"){
|
||||
this.sandbox=true;
|
||||
}
|
||||
|
||||
if(!this.sandbox) {
|
||||
Console.Write("Asset server URL:");
|
||||
this.AssetURL=Console.ReadLine();
|
||||
Console.Write("Key to send to asset server:");
|
||||
this.AssetSendKey=Console.ReadLine();
|
||||
Console.Write("Grid server URL:");
|
||||
this.GridURL=Console.ReadLine();
|
||||
Console.Write("Key to send to gridserver:");
|
||||
this.GridSendKey=Console.ReadLine();
|
||||
|
||||
}
|
||||
this.RegionHandle = Helpers.UIntsToLong((RegionLocX*256), (RegionLocY*256));
|
||||
this.IPListenPort = 9000;
|
||||
this.IPListenAddr = "4.78.190.75";
|
||||
this.AssetURL = "http://www.osgrid.org/ogs/assetserver/";
|
||||
this.AssetSendKey = "1234";
|
||||
this.GridURL = "http://www.osgrid.org/ogs/gridserver/";
|
||||
this.GridSendKey = "1234";
|
||||
}
|
||||
|
||||
public void InitConfig() {
|
||||
|
@ -103,20 +159,30 @@ namespace OpenSim
|
|||
Console.WriteLine("Config.cs:InitConfig() - Exception occured");
|
||||
Console.WriteLine(e.ToString());
|
||||
}
|
||||
Console.WriteLine("Sim settings loaded:");
|
||||
Console.WriteLine("Name: " + this.RegionName);
|
||||
Console.WriteLine("Region Location: [" + this.RegionLocX.ToString() + "," + this.RegionLocY + "]");
|
||||
Console.WriteLine("Region Handle: " + this.RegionHandle.ToString());
|
||||
Console.WriteLine("Listening on IP: " + this.IPListenAddr + ":" + this.IPListenPort);
|
||||
Console.WriteLine("Sandbox Mode? " + this.sandbox.ToString());
|
||||
Console.WriteLine("Asset URL: " + this.AssetURL);
|
||||
Console.WriteLine("Asset key: " + this.AssetSendKey);
|
||||
Console.WriteLine("Grid URL: " + this.GridURL);
|
||||
Console.WriteLine("Grid key: " + this.GridSendKey);
|
||||
}
|
||||
|
||||
public World LoadWorld() {
|
||||
Console.WriteLine("Config.cs:LoadWorld() - Looking for a world object in local DB");
|
||||
// IObjectSet world_result = db.Get(typeof(OpenSim.world.World));
|
||||
// if(world_result.Count==1) {
|
||||
Console.WriteLine("Config.cs:LoadWorld() - Found an OpenSim.world.World object in local database, loading");
|
||||
// Console.WriteLine("Config.cs:LoadWorld() - Found an OpenSim.world.World object in local database, loading");
|
||||
//return (World)world_result.Next();
|
||||
// } else {
|
||||
Console.WriteLine("Config.cs:LoadWorld() - Could not find the world or too many worlds! Constructing blank one");
|
||||
World blank = new World();
|
||||
Console.WriteLine("Config.cs:LoadWorld() - Saving initial world state to disk");
|
||||
db.Set(blank);
|
||||
db.Commit();
|
||||
//db.Set(blank);
|
||||
//db.Commit();
|
||||
return blank;
|
||||
// }
|
||||
}
|
||||
|
@ -124,14 +190,6 @@ namespace OpenSim
|
|||
public void LoadFromGrid() {
|
||||
Console.WriteLine("Config.cs:LoadFromGrid() - dummy function, DOING ABSOLUTELY NOTHING AT ALL!!!");
|
||||
// TODO: Make this crap work
|
||||
/* WebRequest GridLogin = WebRequest.Create(this.GridURL + "regions/" + this.RegionHandle.ToString() + "/login");
|
||||
WebResponse GridResponse = GridLogin.GetResponse();
|
||||
byte[] idata = new byte[(int)GridResponse.ContentLength];
|
||||
BinaryReader br = new BinaryReader(GridResponse.GetResponseStream());
|
||||
|
||||
br.Close();
|
||||
GridResponse.Close();
|
||||
*/
|
||||
}
|
||||
|
||||
public void Shutdown() {
|
||||
|
|
|
@ -80,6 +80,7 @@ namespace OpenSim
|
|||
}
|
||||
|
||||
public void AssetLoader() {
|
||||
if(OpenSim_Main.cfg.sandbox==false) {
|
||||
Console.WriteLine("OpenSimClient.cs:AssetLoader() - Starting new thread");
|
||||
TransferRequestPacket reqPacket = AssetRequests.Dequeue();
|
||||
Console.WriteLine("OpenSimClient.cs:AssetLoader() - Got a request, processing it");
|
||||
|
@ -128,6 +129,7 @@ namespace OpenSim
|
|||
OutPacket(TransferPacket);
|
||||
}
|
||||
AssetResponse.Close();
|
||||
}
|
||||
}
|
||||
|
||||
public void ProcessInPacket(Packet Pack) {
|
||||
|
@ -156,14 +158,16 @@ namespace OpenSim
|
|||
lock(OpenSim_Main.local_world.Entities) {
|
||||
OpenSim_Main.local_world.Entities.Remove(this.AgentID);
|
||||
}
|
||||
WebRequest DeleteSession = WebRequest.Create(OpenSim_Main.cfg.GridURL + "/usersessions/" + OpenSim_Main.cfg.GridSendKey + "/" + this.AgentID.ToString() + this.CircuitCode.ToString() + "/delete");
|
||||
|
||||
if(OpenSim_Main.cfg.sandbox==false) {
|
||||
WebRequest DeleteSession = WebRequest.Create(OpenSim_Main.cfg.GridURL + "/usersessions/" + OpenSim_Main.cfg.GridSendKey + "/" + this.AgentID.ToString() + this.CircuitCode.ToString() + "/delete");
|
||||
WebResponse GridResponse = DeleteSession.GetResponse();
|
||||
StreamReader sr = new StreamReader(GridResponse.GetResponseStream());
|
||||
String grTest = sr.ReadLine();
|
||||
sr.Close();
|
||||
GridResponse.Close();
|
||||
Console.WriteLine("DEBUG: " + grTest);
|
||||
|
||||
}
|
||||
this.ClientThread.Abort();
|
||||
break;
|
||||
case PacketType.AgentUpdate:
|
||||
|
@ -426,24 +430,32 @@ namespace OpenSim
|
|||
}
|
||||
|
||||
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");
|
||||
Console.WriteLine(OpenSim_Main.cfg.GridURL);
|
||||
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
|
||||
Console.WriteLine("OpenSimClient.cs:AuthUser() - Got authenticated connection from " + userEP.ToString());
|
||||
if(OpenSim_Main.cfg.sandbox==false) {
|
||||
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");
|
||||
Console.WriteLine(OpenSim_Main.cfg.GridURL);
|
||||
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
|
||||
Console.WriteLine("OpenSimClient.cs:AuthUser() - Got authenticated connection from " + userEP.ToString());
|
||||
this.AgentID=cirpack.CircuitCode.ID;
|
||||
this.SessionID=cirpack.CircuitCode.SessionID;
|
||||
this.CircuitCode=cirpack.CircuitCode.Code;
|
||||
InitNewClient();
|
||||
ClientLoop();
|
||||
} else { // Invalid
|
||||
Console.WriteLine("OpenSimClient.cs:AuthUser() - New user request denied to " + userEP.ToString());
|
||||
ClientThread.Abort();
|
||||
}
|
||||
} else {
|
||||
this.AgentID=cirpack.CircuitCode.ID;
|
||||
this.SessionID=cirpack.CircuitCode.SessionID;
|
||||
this.CircuitCode=cirpack.CircuitCode.Code;
|
||||
InitNewClient();
|
||||
ClientLoop();
|
||||
} else { // Invalid
|
||||
Console.WriteLine("OpenSimClient.cs:AuthUser() - New user request denied to " + userEP.ToString());
|
||||
ClientThread.Abort();
|
||||
this.SessionID=cirpack.CircuitCode.SessionID;
|
||||
this.CircuitCode=cirpack.CircuitCode.Code;
|
||||
InitNewClient();
|
||||
ClientLoop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue