aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/Config.cs106
-rw-r--r--src/OpenSimClient.cs50
2 files changed, 113 insertions, 43 deletions
diff --git a/src/Config.cs b/src/Config.cs
index f85e4d5..dc01df9 100644
--- a/src/Config.cs
+++ b/src/Config.cs
@@ -53,25 +53,81 @@ namespace OpenSim
53 public int IPListenPort; 53 public int IPListenPort;
54 public string IPListenAddr; 54 public string IPListenAddr;
55 55
56 public string AssetURL; 56 public bool sandbox;
57 public string AssetSendKey; 57 public string AssetURL="";
58 public string AssetSendKey="";
58 59
59 public string GridURL; 60 public string GridURL="";
60 public string GridSendKey; 61 public string GridSendKey="";
61 62
62 private IObjectContainer db; 63 private IObjectContainer db;
63 64
64 public void LoadDefaults() { 65 public void LoadDefaults() {
65 this.RegionName = "OpenSim test\0"; 66 string tempstring;
66 this.RegionLocX = 997; 67 Console.WriteLine("Config.cs:LoadDefaults() - Please press enter to retain default or enter new settings");
67 this.RegionLocY = 996; 68 Console.Write("Name [OpenSim test]:");
69 tempstring=Console.ReadLine();
70 if(tempstring=="") {
71 this.RegionName = "OpenSim test";
72 } else {
73 this.RegionName = tempstring;
74 }
75
76 Console.Write("Grid location X [997]:");
77 tempstring=Console.ReadLine();
78 if(tempstring=="") {
79 this.RegionLocX = 997;
80 } else {
81 this.RegionLocX = (uint)Convert.ToInt32(tempstring);
82 }
83
84 Console.Write("Grid location Y [996]:");
85 tempstring=Console.ReadLine();
86 if(tempstring=="") {
87 this.RegionLocY = 996;
88 } else {
89 this.RegionLocY = (uint)Convert.ToInt32(tempstring);
90 }
91
92 Console.Write("Listen on UDP port for client connections [9000]:");
93 tempstring=Console.ReadLine();
94 if(tempstring=="") {
95 this.IPListenPort = 9000;
96 } else {
97 this.IPListenPort = Convert.ToInt32(tempstring);
98 }
99
100 Console.Write("Listen on IP address for client connections [127.0.0.1]:");
101 tempstring=Console.ReadLine();
102 if(tempstring=="") {
103 this.IPListenAddr = "127.0.0.1";
104 } else {
105 this.IPListenAddr = tempstring;
106 }
107
108
109 Console.Write("Run in sandbox or grid mode? [sandbox]:");
110 tempstring=Console.ReadLine();
111 if(tempstring=="") {
112 this.sandbox = true;
113 } else if(tempstring=="grid"){
114 this.sandbox = false;
115 } else if(tempstring=="sandbox"){
116 this.sandbox=true;
117 }
118
119 if(!this.sandbox) {
120 Console.Write("Asset server URL:");
121 this.AssetURL=Console.ReadLine();
122 Console.Write("Key to send to asset server:");
123 this.AssetSendKey=Console.ReadLine();
124 Console.Write("Grid server URL:");
125 this.GridURL=Console.ReadLine();
126 Console.Write("Key to send to gridserver:");
127 this.GridSendKey=Console.ReadLine();
128
129 }
68 this.RegionHandle = Helpers.UIntsToLong((RegionLocX*256), (RegionLocY*256)); 130 this.RegionHandle = Helpers.UIntsToLong((RegionLocX*256), (RegionLocY*256));
69 this.IPListenPort = 9000;
70 this.IPListenAddr = "4.78.190.75";
71 this.AssetURL = "http://www.osgrid.org/ogs/assetserver/";
72 this.AssetSendKey = "1234";
73 this.GridURL = "http://www.osgrid.org/ogs/gridserver/";
74 this.GridSendKey = "1234";
75 } 131 }
76 132
77 public void InitConfig() { 133 public void InitConfig() {
@@ -103,20 +159,30 @@ namespace OpenSim
103 Console.WriteLine("Config.cs:InitConfig() - Exception occured"); 159 Console.WriteLine("Config.cs:InitConfig() - Exception occured");
104 Console.WriteLine(e.ToString()); 160 Console.WriteLine(e.ToString());
105 } 161 }
162 Console.WriteLine("Sim settings loaded:");
163 Console.WriteLine("Name: " + this.RegionName);
164 Console.WriteLine("Region Location: [" + this.RegionLocX.ToString() + "," + this.RegionLocY + "]");
165 Console.WriteLine("Region Handle: " + this.RegionHandle.ToString());
166 Console.WriteLine("Listening on IP: " + this.IPListenAddr + ":" + this.IPListenPort);
167 Console.WriteLine("Sandbox Mode? " + this.sandbox.ToString());
168 Console.WriteLine("Asset URL: " + this.AssetURL);
169 Console.WriteLine("Asset key: " + this.AssetSendKey);
170 Console.WriteLine("Grid URL: " + this.GridURL);
171 Console.WriteLine("Grid key: " + this.GridSendKey);
106 } 172 }
107 173
108 public World LoadWorld() { 174 public World LoadWorld() {
109 Console.WriteLine("Config.cs:LoadWorld() - Looking for a world object in local DB"); 175 Console.WriteLine("Config.cs:LoadWorld() - Looking for a world object in local DB");
110 // IObjectSet world_result = db.Get(typeof(OpenSim.world.World)); 176 // IObjectSet world_result = db.Get(typeof(OpenSim.world.World));
111 // if(world_result.Count==1) { 177 // if(world_result.Count==1) {
112 Console.WriteLine("Config.cs:LoadWorld() - Found an OpenSim.world.World object in local database, loading"); 178 // Console.WriteLine("Config.cs:LoadWorld() - Found an OpenSim.world.World object in local database, loading");
113 //return (World)world_result.Next(); 179 //return (World)world_result.Next();
114 // } else { 180 // } else {
115 Console.WriteLine("Config.cs:LoadWorld() - Could not find the world or too many worlds! Constructing blank one"); 181 Console.WriteLine("Config.cs:LoadWorld() - Could not find the world or too many worlds! Constructing blank one");
116 World blank = new World(); 182 World blank = new World();
117 Console.WriteLine("Config.cs:LoadWorld() - Saving initial world state to disk"); 183 Console.WriteLine("Config.cs:LoadWorld() - Saving initial world state to disk");
118 db.Set(blank); 184 //db.Set(blank);
119 db.Commit(); 185 //db.Commit();
120 return blank; 186 return blank;
121 // } 187 // }
122 } 188 }
@@ -124,14 +190,6 @@ namespace OpenSim
124 public void LoadFromGrid() { 190 public void LoadFromGrid() {
125 Console.WriteLine("Config.cs:LoadFromGrid() - dummy function, DOING ABSOLUTELY NOTHING AT ALL!!!"); 191 Console.WriteLine("Config.cs:LoadFromGrid() - dummy function, DOING ABSOLUTELY NOTHING AT ALL!!!");
126 // TODO: Make this crap work 192 // TODO: Make this crap work
127 /* WebRequest GridLogin = WebRequest.Create(this.GridURL + "regions/" + this.RegionHandle.ToString() + "/login");
128 WebResponse GridResponse = GridLogin.GetResponse();
129 byte[] idata = new byte[(int)GridResponse.ContentLength];
130 BinaryReader br = new BinaryReader(GridResponse.GetResponseStream());
131
132 br.Close();
133 GridResponse.Close();
134 */
135 } 193 }
136 194
137 public void Shutdown() { 195 public void Shutdown() {
diff --git a/src/OpenSimClient.cs b/src/OpenSimClient.cs
index 2e8dbb5..6b00a0f 100644
--- a/src/OpenSimClient.cs
+++ b/src/OpenSimClient.cs
@@ -80,6 +80,7 @@ namespace OpenSim
80 } 80 }
81 81
82 public void AssetLoader() { 82 public void AssetLoader() {
83 if(OpenSim_Main.cfg.sandbox==false) {
83 Console.WriteLine("OpenSimClient.cs:AssetLoader() - Starting new thread"); 84 Console.WriteLine("OpenSimClient.cs:AssetLoader() - Starting new thread");
84 TransferRequestPacket reqPacket = AssetRequests.Dequeue(); 85 TransferRequestPacket reqPacket = AssetRequests.Dequeue();
85 Console.WriteLine("OpenSimClient.cs:AssetLoader() - Got a request, processing it"); 86 Console.WriteLine("OpenSimClient.cs:AssetLoader() - Got a request, processing it");
@@ -128,6 +129,7 @@ namespace OpenSim
128 OutPacket(TransferPacket); 129 OutPacket(TransferPacket);
129 } 130 }
130 AssetResponse.Close(); 131 AssetResponse.Close();
132 }
131 } 133 }
132 134
133 public void ProcessInPacket(Packet Pack) { 135 public void ProcessInPacket(Packet Pack) {
@@ -156,14 +158,16 @@ namespace OpenSim
156 lock(OpenSim_Main.local_world.Entities) { 158 lock(OpenSim_Main.local_world.Entities) {
157 OpenSim_Main.local_world.Entities.Remove(this.AgentID); 159 OpenSim_Main.local_world.Entities.Remove(this.AgentID);
158 } 160 }
159 WebRequest DeleteSession = WebRequest.Create(OpenSim_Main.cfg.GridURL + "/usersessions/" + OpenSim_Main.cfg.GridSendKey + "/" + this.AgentID.ToString() + this.CircuitCode.ToString() + "/delete"); 161
162 if(OpenSim_Main.cfg.sandbox==false) {
163 WebRequest DeleteSession = WebRequest.Create(OpenSim_Main.cfg.GridURL + "/usersessions/" + OpenSim_Main.cfg.GridSendKey + "/" + this.AgentID.ToString() + this.CircuitCode.ToString() + "/delete");
160 WebResponse GridResponse = DeleteSession.GetResponse(); 164 WebResponse GridResponse = DeleteSession.GetResponse();
161 StreamReader sr = new StreamReader(GridResponse.GetResponseStream()); 165 StreamReader sr = new StreamReader(GridResponse.GetResponseStream());
162 String grTest = sr.ReadLine(); 166 String grTest = sr.ReadLine();
163 sr.Close(); 167 sr.Close();
164 GridResponse.Close(); 168 GridResponse.Close();
165 Console.WriteLine("DEBUG: " + grTest); 169 Console.WriteLine("DEBUG: " + grTest);
166 170 }
167 this.ClientThread.Abort(); 171 this.ClientThread.Abort();
168 break; 172 break;
169 case PacketType.AgentUpdate: 173 case PacketType.AgentUpdate:
@@ -426,24 +430,32 @@ namespace OpenSim
426 } 430 }
427 431
428 private void AuthUser() { 432 private void AuthUser() {
429 Console.WriteLine("OpenSimClient.cs:AuthUser() - Authenticating new user request with grid"); 433 if(OpenSim_Main.cfg.sandbox==false) {
430 WebRequest CheckSession = WebRequest.Create(OpenSim_Main.cfg.GridURL + "/usersessions/" + OpenSim_Main.cfg.GridSendKey + "/" + cirpack.CircuitCode.ID.ToString() + "/" + cirpack.CircuitCode.Code.ToString() + "/exists"); 434 Console.WriteLine("OpenSimClient.cs:AuthUser() - Authenticating new user request with grid");
431 Console.WriteLine(OpenSim_Main.cfg.GridURL); 435 WebRequest CheckSession = WebRequest.Create(OpenSim_Main.cfg.GridURL + "/usersessions/" + OpenSim_Main.cfg.GridSendKey + "/" + cirpack.CircuitCode.ID.ToString() + "/" + cirpack.CircuitCode.Code.ToString() + "/exists");
432 WebResponse GridResponse = CheckSession.GetResponse(); 436 Console.WriteLine(OpenSim_Main.cfg.GridURL);
433 StreamReader sr = new StreamReader(GridResponse.GetResponseStream()); 437 WebResponse GridResponse = CheckSession.GetResponse();
434 String grTest = sr.ReadLine(); 438 StreamReader sr = new StreamReader(GridResponse.GetResponseStream());
435 sr.Close(); 439 String grTest = sr.ReadLine();
436 GridResponse.Close(); 440 sr.Close();
437 if(String.IsNullOrEmpty(grTest) || grTest.Equals("1")) { // YAY! Valid login 441 GridResponse.Close();
438 Console.WriteLine("OpenSimClient.cs:AuthUser() - Got authenticated connection from " + userEP.ToString()); 442 if(String.IsNullOrEmpty(grTest) || grTest.Equals("1")) { // YAY! Valid login
443 Console.WriteLine("OpenSimClient.cs:AuthUser() - Got authenticated connection from " + userEP.ToString());
444 this.AgentID=cirpack.CircuitCode.ID;
445 this.SessionID=cirpack.CircuitCode.SessionID;
446 this.CircuitCode=cirpack.CircuitCode.Code;
447 InitNewClient();
448 ClientLoop();
449 } else { // Invalid
450 Console.WriteLine("OpenSimClient.cs:AuthUser() - New user request denied to " + userEP.ToString());
451 ClientThread.Abort();
452 }
453 } else {
439 this.AgentID=cirpack.CircuitCode.ID; 454 this.AgentID=cirpack.CircuitCode.ID;
440 this.SessionID=cirpack.CircuitCode.SessionID; 455 this.SessionID=cirpack.CircuitCode.SessionID;
441 this.CircuitCode=cirpack.CircuitCode.Code; 456 this.CircuitCode=cirpack.CircuitCode.Code;
442 InitNewClient(); 457 InitNewClient();
443 ClientLoop(); 458 ClientLoop();
444 } else { // Invalid
445 Console.WriteLine("OpenSimClient.cs:AuthUser() - New user request denied to " + userEP.ToString());
446 ClientThread.Abort();
447 } 459 }
448 } 460 }
449 } 461 }