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 int IPListenPort;
|
||||||
public string IPListenAddr;
|
public string IPListenAddr;
|
||||||
|
|
||||||
public string AssetURL;
|
public bool sandbox;
|
||||||
public string AssetSendKey;
|
public string AssetURL="";
|
||||||
|
public string AssetSendKey="";
|
||||||
|
|
||||||
public string GridURL;
|
public string GridURL="";
|
||||||
public string GridSendKey;
|
public string GridSendKey="";
|
||||||
|
|
||||||
private IObjectContainer db;
|
private IObjectContainer db;
|
||||||
|
|
||||||
public void LoadDefaults() {
|
public void LoadDefaults() {
|
||||||
this.RegionName = "OpenSim test\0";
|
string tempstring;
|
||||||
this.RegionLocX = 997;
|
Console.WriteLine("Config.cs:LoadDefaults() - Please press enter to retain default or enter new settings");
|
||||||
this.RegionLocY = 996;
|
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.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() {
|
public void InitConfig() {
|
||||||
|
@ -103,20 +159,30 @@ namespace OpenSim
|
||||||
Console.WriteLine("Config.cs:InitConfig() - Exception occured");
|
Console.WriteLine("Config.cs:InitConfig() - Exception occured");
|
||||||
Console.WriteLine(e.ToString());
|
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() {
|
public World LoadWorld() {
|
||||||
Console.WriteLine("Config.cs:LoadWorld() - Looking for a world object in local DB");
|
Console.WriteLine("Config.cs:LoadWorld() - Looking for a world object in local DB");
|
||||||
// IObjectSet world_result = db.Get(typeof(OpenSim.world.World));
|
// IObjectSet world_result = db.Get(typeof(OpenSim.world.World));
|
||||||
// if(world_result.Count==1) {
|
// 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();
|
//return (World)world_result.Next();
|
||||||
// } else {
|
// } else {
|
||||||
Console.WriteLine("Config.cs:LoadWorld() - Could not find the world or too many worlds! Constructing blank one");
|
Console.WriteLine("Config.cs:LoadWorld() - Could not find the world or too many worlds! Constructing blank one");
|
||||||
World blank = new World();
|
World blank = new World();
|
||||||
Console.WriteLine("Config.cs:LoadWorld() - Saving initial world state to disk");
|
Console.WriteLine("Config.cs:LoadWorld() - Saving initial world state to disk");
|
||||||
db.Set(blank);
|
//db.Set(blank);
|
||||||
db.Commit();
|
//db.Commit();
|
||||||
return blank;
|
return blank;
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
@ -124,14 +190,6 @@ namespace OpenSim
|
||||||
public void LoadFromGrid() {
|
public void LoadFromGrid() {
|
||||||
Console.WriteLine("Config.cs:LoadFromGrid() - dummy function, DOING ABSOLUTELY NOTHING AT ALL!!!");
|
Console.WriteLine("Config.cs:LoadFromGrid() - dummy function, DOING ABSOLUTELY NOTHING AT ALL!!!");
|
||||||
// TODO: Make this crap work
|
// 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() {
|
public void Shutdown() {
|
||||||
|
|
|
@ -80,6 +80,7 @@ namespace OpenSim
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AssetLoader() {
|
public void AssetLoader() {
|
||||||
|
if(OpenSim_Main.cfg.sandbox==false) {
|
||||||
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,6 +129,7 @@ namespace OpenSim
|
||||||
OutPacket(TransferPacket);
|
OutPacket(TransferPacket);
|
||||||
}
|
}
|
||||||
AssetResponse.Close();
|
AssetResponse.Close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ProcessInPacket(Packet Pack) {
|
public void ProcessInPacket(Packet Pack) {
|
||||||
|
@ -156,14 +158,16 @@ namespace OpenSim
|
||||||
lock(OpenSim_Main.local_world.Entities) {
|
lock(OpenSim_Main.local_world.Entities) {
|
||||||
OpenSim_Main.local_world.Entities.Remove(this.AgentID);
|
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();
|
WebResponse GridResponse = DeleteSession.GetResponse();
|
||||||
StreamReader sr = new StreamReader(GridResponse.GetResponseStream());
|
StreamReader sr = new StreamReader(GridResponse.GetResponseStream());
|
||||||
String grTest = sr.ReadLine();
|
String grTest = sr.ReadLine();
|
||||||
sr.Close();
|
sr.Close();
|
||||||
GridResponse.Close();
|
GridResponse.Close();
|
||||||
Console.WriteLine("DEBUG: " + grTest);
|
Console.WriteLine("DEBUG: " + grTest);
|
||||||
|
}
|
||||||
this.ClientThread.Abort();
|
this.ClientThread.Abort();
|
||||||
break;
|
break;
|
||||||
case PacketType.AgentUpdate:
|
case PacketType.AgentUpdate:
|
||||||
|
@ -426,24 +430,32 @@ namespace OpenSim
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AuthUser() {
|
private void AuthUser() {
|
||||||
Console.WriteLine("OpenSimClient.cs:AuthUser() - Authenticating new user request with grid");
|
if(OpenSim_Main.cfg.sandbox==false) {
|
||||||
WebRequest CheckSession = WebRequest.Create(OpenSim_Main.cfg.GridURL + "/usersessions/" + OpenSim_Main.cfg.GridSendKey + "/" + cirpack.CircuitCode.ID.ToString() + "/" + cirpack.CircuitCode.Code.ToString() + "/exists");
|
Console.WriteLine("OpenSimClient.cs:AuthUser() - Authenticating new user request with grid");
|
||||||
Console.WriteLine(OpenSim_Main.cfg.GridURL);
|
WebRequest CheckSession = WebRequest.Create(OpenSim_Main.cfg.GridURL + "/usersessions/" + OpenSim_Main.cfg.GridSendKey + "/" + cirpack.CircuitCode.ID.ToString() + "/" + cirpack.CircuitCode.Code.ToString() + "/exists");
|
||||||
WebResponse GridResponse = CheckSession.GetResponse();
|
Console.WriteLine(OpenSim_Main.cfg.GridURL);
|
||||||
StreamReader sr = new StreamReader(GridResponse.GetResponseStream());
|
WebResponse GridResponse = CheckSession.GetResponse();
|
||||||
String grTest = sr.ReadLine();
|
StreamReader sr = new StreamReader(GridResponse.GetResponseStream());
|
||||||
sr.Close();
|
String grTest = sr.ReadLine();
|
||||||
GridResponse.Close();
|
sr.Close();
|
||||||
if(String.IsNullOrEmpty(grTest) || grTest.Equals("1")) { // YAY! Valid login
|
GridResponse.Close();
|
||||||
Console.WriteLine("OpenSimClient.cs:AuthUser() - Got authenticated connection from " + userEP.ToString());
|
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.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();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue