aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorgareth2007-04-13 15:14:21 +0000
committergareth2007-04-13 15:14:21 +0000
commitdd5f4abdb9423dd767ccb1c8be310e40fdd1ad43 (patch)
treea9a3647fca57f49e00fed77006bd5379841f5828
parentaaaaaaarrrrrrrrrggggghhhhhhhh why oh why? (diff)
downloadopensim-SC_OLD-dd5f4abdb9423dd767ccb1c8be310e40fdd1ad43.zip
opensim-SC_OLD-dd5f4abdb9423dd767ccb1c8be310e40fdd1ad43.tar.gz
opensim-SC_OLD-dd5f4abdb9423dd767ccb1c8be310e40fdd1ad43.tar.bz2
opensim-SC_OLD-dd5f4abdb9423dd767ccb1c8be310e40fdd1ad43.tar.xz
Fixed weird XML/HTTP bugs
Can now update a sim profile at startup automatically! W00t! Untested neighbours code (for sim crossings) Didn't drink any red bull today :( Used liquid guarana extract + cola
-rw-r--r--OpenGridServices.GridServer/Main.cs20
-rw-r--r--OpenGridServices.GridServer/SimProfiles.cs65
-rw-r--r--OpenSim.RegionServer/RegionInfo.cs6
-rw-r--r--OpenSim.Servers/BaseHttpServer.cs6
4 files changed, 56 insertions, 41 deletions
diff --git a/OpenGridServices.GridServer/Main.cs b/OpenGridServices.GridServer/Main.cs
index c69b6dc..55e2b00 100644
--- a/OpenGridServices.GridServer/Main.cs
+++ b/OpenGridServices.GridServer/Main.cs
@@ -47,20 +47,10 @@ namespace OpenGridServices.GridServer
47 public class OpenGrid_Main : BaseServer, conscmd_callback 47 public class OpenGrid_Main : BaseServer, conscmd_callback
48 { 48 {
49 private string ConfigDll = "OpenGrid.Config.GridConfigDb4o.dll"; 49 private string ConfigDll = "OpenGrid.Config.GridConfigDb4o.dll";
50 private GridConfig Cfg; 50 public GridConfig Cfg;
51 51
52 public static OpenGrid_Main thegrid; 52 public static OpenGrid_Main thegrid;
53 53
54 public string GridOwner;
55 public string DefaultStartupMsg;
56 public string DefaultAssetServer;
57 public string AssetSendKey;
58 public string AssetRecvKey;
59 public string DefaultUserServer;
60 public string UserSendKey;
61 public string UserRecvKey;
62 public string SimSendKey;
63 public string SimRecvKey;
64 //public LLUUID highestUUID; 54 //public LLUUID highestUUID;
65 55
66 private SimProfileManager m_simProfileManager; 56 private SimProfileManager m_simProfileManager;
@@ -109,10 +99,10 @@ namespace OpenGridServices.GridServer
109 99
110 httpServer.AddXmlRPCHandler("simulator_login", m_simProfileManager.XmlRpcLoginToSimulatorMethod); 100 httpServer.AddXmlRPCHandler("simulator_login", m_simProfileManager.XmlRpcLoginToSimulatorMethod);
111 101
112 httpServer.AddRestHandler("GET", "/sims", m_simProfileManager.RestGetSimMethod); 102 httpServer.AddRestHandler("GET", "/sims/", m_simProfileManager.RestGetSimMethod);
113 httpServer.AddRestHandler("POST", "/sims", m_simProfileManager.RestSetSimMethod); 103 httpServer.AddRestHandler("POST", "/sims/", m_simProfileManager.RestSetSimMethod);
114 httpServer.AddRestHandler("GET", "/regions", m_simProfileManager.RestGetRegionMethod); 104 httpServer.AddRestHandler("GET", "/regions/", m_simProfileManager.RestGetRegionMethod);
115 httpServer.AddRestHandler("POST", "/regions", m_simProfileManager.RestSetRegionMethod); 105 httpServer.AddRestHandler("POST", "/regions/", m_simProfileManager.RestSetRegionMethod);
116 106
117 107
118 // lbsa71 : This code snippet taken from old http server. 108 // lbsa71 : This code snippet taken from old http server.
diff --git a/OpenGridServices.GridServer/SimProfiles.cs b/OpenGridServices.GridServer/SimProfiles.cs
index 9e93db0..5e02b4f 100644
--- a/OpenGridServices.GridServer/SimProfiles.cs
+++ b/OpenGridServices.GridServer/SimProfiles.cs
@@ -71,7 +71,10 @@ namespace OpenGridServices.GridServer
71 } 71 }
72 72
73 public SimProfileBase GetProfileByLLUUID(LLUUID ProfileLLUUID) { 73 public SimProfileBase GetProfileByLLUUID(LLUUID ProfileLLUUID) {
74 return SimProfiles[ProfileLLUUID]; 74 foreach (libsecondlife.LLUUID UUID in SimProfiles.Keys) {
75 if(SimProfiles[UUID].UUID==ProfileLLUUID) return SimProfiles[UUID];
76 }
77 return null;
75 } 78 }
76 79
77 public bool AuthenticateSim(LLUUID RegionUUID, uint regionhandle, string simrecvkey) { 80 public bool AuthenticateSim(LLUUID RegionUUID, uint regionhandle, string simrecvkey) {
@@ -172,13 +175,13 @@ namespace OpenGridServices.GridServer
172 responseData["estate_id"] = "1"; 175 responseData["estate_id"] = "1";
173 responseData["neighbours"] = SimNeighboursData; 176 responseData["neighbours"] = SimNeighboursData;
174 177
175 responseData["asset_url"] = m_gridManager.DefaultAssetServer; 178 responseData["asset_url"] = m_gridManager.Cfg.DefaultAssetServer;
176 responseData["asset_sendkey"] = m_gridManager.AssetSendKey; 179 responseData["asset_sendkey"] = m_gridManager.Cfg.AssetSendKey;
177 responseData["asset_recvkey"] = m_gridManager.AssetRecvKey; 180 responseData["asset_recvkey"] = m_gridManager.Cfg.AssetRecvKey;
178 responseData["user_url"] = m_gridManager.DefaultUserServer; 181 responseData["user_url"] = m_gridManager.Cfg.DefaultUserServer;
179 responseData["user_sendkey"] = m_gridManager.UserSendKey; 182 responseData["user_sendkey"] = m_gridManager.Cfg.UserSendKey;
180 responseData["user_recvkey"] = m_gridManager.UserRecvKey; 183 responseData["user_recvkey"] = m_gridManager.Cfg.UserRecvKey;
181 responseData["authkey"] = m_gridManager.SimSendKey; 184 responseData["authkey"] = m_gridManager.Cfg.SimSendKey;
182 } 185 }
183 186
184 return response; 187 return response;
@@ -188,30 +191,33 @@ namespace OpenGridServices.GridServer
188 { 191 {
189 Console.WriteLine("SimProfiles.cs:RestSetSimMethod() - processing request......"); 192 Console.WriteLine("SimProfiles.cs:RestSetSimMethod() - processing request......");
190 SimProfileBase TheSim; 193 SimProfileBase TheSim;
191 LLUUID UUID = new LLUUID(param); 194 TheSim = GetProfileByLLUUID(new LLUUID(param));
192 TheSim = GetProfileByLLUUID(UUID); 195 if ((TheSim) == null) {
193 if ((TheSim) == null) TheSim = new SimProfileBase(); 196 TheSim = new SimProfileBase();
194 197 LLUUID UUID = new LLUUID(param);
198 TheSim.UUID=UUID;
199 }
200
195 XmlDocument doc = new XmlDocument(); 201 XmlDocument doc = new XmlDocument();
196 doc.LoadXml(request); 202 doc.LoadXml(request);
197 XmlNode authkeynode = doc.FirstChild; 203 XmlNode rootnode=doc.FirstChild;
204 XmlNode authkeynode = rootnode.ChildNodes[0];
198 if (authkeynode.Name != "authkey") 205 if (authkeynode.Name != "authkey")
199 { 206 {
200 return "ERROR! bad XML - expected authkey tag"; 207 return "ERROR! bad XML - expected authkey tag";
201 } 208 }
202 209
203 XmlNode simnode = doc.ChildNodes[1]; 210 XmlNode simnode = rootnode.ChildNodes[1];
204 if (simnode.Name != "sim") 211 if (simnode.Name != "sim")
205 { 212 {
206 return "ERROR! bad XML - expected sim tag"; 213 return "ERROR! bad XML - expected sim tag";
207 } 214 }
208 215
209 if (authkeynode.InnerText != m_gridManager.SimRecvKey) 216 if (authkeynode.InnerText != m_gridManager.Cfg.SimRecvKey)
210 { 217 {
211 return "ERROR! invalid key"; 218 return "ERROR! invalid key";
212 } 219 }
213 220 for (int i = 0; i < simnode.ChildNodes.Count; i++) {
214 for (int i = 0; i <= simnode.ChildNodes.Count; i++) {
215 switch (simnode.ChildNodes[i].Name) { 221 switch (simnode.ChildNodes[i].Name) {
216 case "regionname": 222 case "regionname":
217 TheSim.regionname = simnode.ChildNodes[i].InnerText; 223 TheSim.regionname = simnode.ChildNodes[i].InnerText;
@@ -231,12 +237,23 @@ namespace OpenGridServices.GridServer
231 break; 237 break;
232 238
233 case "region_locy": 239 case "region_locy":
234 TheSim.RegionLocY = Convert.ToUInt32((string)simnode.ChildNodes[i].InnerText); 240 TheSim.RegionLocY = Convert.ToUInt32((string)simnode.ChildNodes[i].InnerText);
235 TheSim.regionhandle = Helpers.UIntsToLong((TheSim.RegionLocX * 256), (TheSim.RegionLocY * 256)); 241 TheSim.regionhandle = Helpers.UIntsToLong((TheSim.RegionLocX * 256), (TheSim.RegionLocY * 256));
236 break; 242 break;
237 } 243 }
238 } 244 }
239 return "OK"; 245
246 try {
247 SimProfiles.Add(TheSim.UUID, TheSim);
248 IObjectContainer db;
249 db = Db4oFactory.OpenFile("simprofiles.yap");
250 db.Set(TheSim);
251 db.Close();
252 return "OK";
253 } catch(Exception e) {
254 return "ERROR! could not save to database!";
255 }
256
240 } 257 }
241 258
242 public string RestGetRegionMethod(string request, string path, string param ) 259 public string RestGetRegionMethod(string request, string path, string param )
@@ -261,7 +278,8 @@ namespace OpenGridServices.GridServer
261 278
262 if (!(TheSim == null)) 279 if (!(TheSim == null))
263 { 280 {
264 respstring = "<authkey>" + m_gridManager.SimSendKey + "</authkey>"; 281 respstring = "<Root>";
282 respstring += "<authkey>" + m_gridManager.Cfg.SimSendKey + "</authkey>";
265 respstring += "<sim>"; 283 respstring += "<sim>";
266 respstring += "<uuid>" + TheSim.UUID.ToString() + "</uuid>"; 284 respstring += "<uuid>" + TheSim.UUID.ToString() + "</uuid>";
267 respstring += "<regionname>" + TheSim.regionname + "</regionname>"; 285 respstring += "<regionname>" + TheSim.regionname + "</regionname>";
@@ -271,6 +289,7 @@ namespace OpenGridServices.GridServer
271 respstring += "<region_locy>" + TheSim.RegionLocY.ToString() + "</region_locy>"; 289 respstring += "<region_locy>" + TheSim.RegionLocY.ToString() + "</region_locy>";
272 respstring += "<estate_id>1</estate_id>"; 290 respstring += "<estate_id>1</estate_id>";
273 respstring += "</sim>"; 291 respstring += "</sim>";
292 respstring += "</Root>";
274 } 293 }
275 294
276 return respstring; 295 return respstring;
diff --git a/OpenSim.RegionServer/RegionInfo.cs b/OpenSim.RegionServer/RegionInfo.cs
index 9958f1a..abc674f 100644
--- a/OpenSim.RegionServer/RegionInfo.cs
+++ b/OpenSim.RegionServer/RegionInfo.cs
@@ -44,7 +44,8 @@ namespace OpenSim
44 //we really want to keep any server connection code out of here and out of the code code 44 //we really want to keep any server connection code out of here and out of the code code
45 // and put it in the server connection classes (those inheriting from IGridServer etc) 45 // and put it in the server connection classes (those inheriting from IGridServer etc)
46 string reqtext; 46 string reqtext;
47 reqtext = "<authkey>" + this.GridSendKey + "</authkey>"; 47 reqtext = "<Root>";
48 reqtext += "<authkey>" + this.GridSendKey + "</authkey>";
48 reqtext += "<sim>"; 49 reqtext += "<sim>";
49 reqtext += "<uuid>" + this.SimUUID.ToString() + "</uuid>"; 50 reqtext += "<uuid>" + this.SimUUID.ToString() + "</uuid>";
50 reqtext += "<regionname>" + this.RegionName + "</regionname>"; 51 reqtext += "<regionname>" + this.RegionName + "</regionname>";
@@ -54,6 +55,7 @@ namespace OpenSim
54 reqtext += "<region_locy>" + this.RegionLocY.ToString() + "</region_locy>"; 55 reqtext += "<region_locy>" + this.RegionLocY.ToString() + "</region_locy>";
55 reqtext += "<estate_id>1</estate_id>"; 56 reqtext += "<estate_id>1</estate_id>";
56 reqtext += "</sim>"; 57 reqtext += "</sim>";
58 reqtext += "</Root>";
57 59
58 byte[] reqdata = (new System.Text.ASCIIEncoding()).GetBytes(reqtext); 60 byte[] reqdata = (new System.Text.ASCIIEncoding()).GetBytes(reqtext);
59 61
@@ -67,7 +69,7 @@ namespace OpenSim
67 stOut.Close(); 69 stOut.Close();
68 70
69 WebResponse gridresp = GridSaveReq.GetResponse(); 71 WebResponse gridresp = GridSaveReq.GetResponse();
70 StreamReader stIn = new StreamReader(gridresp.GetResponseStream()); 72 StreamReader stIn = new StreamReader(gridresp.GetResponseStream(), Encoding.ASCII);
71 string GridResponse = stIn.ReadToEnd(); 73 string GridResponse = stIn.ReadToEnd();
72 stIn.Close(); 74 stIn.Close();
73 gridresp.Close(); 75 gridresp.Close();
diff --git a/OpenSim.Servers/BaseHttpServer.cs b/OpenSim.Servers/BaseHttpServer.cs
index 0a123b7..bb8f0ad 100644
--- a/OpenSim.Servers/BaseHttpServer.cs
+++ b/OpenSim.Servers/BaseHttpServer.cs
@@ -154,6 +154,7 @@ namespace OpenSim.Servers
154 154
155 public virtual void HandleRequest(Object stateinfo) 155 public virtual void HandleRequest(Object stateinfo)
156 { 156 {
157 try {
157 HttpListenerContext context = (HttpListenerContext)stateinfo; 158 HttpListenerContext context = (HttpListenerContext)stateinfo;
158 159
159 HttpListenerRequest request = context.Request; 160 HttpListenerRequest request = context.Request;
@@ -210,7 +211,10 @@ namespace OpenSim.Servers
210 response.SendChunked = false; 211 response.SendChunked = false;
211 response.ContentLength64 = buffer.Length; 212 response.ContentLength64 = buffer.Length;
212 output.Write(buffer, 0, buffer.Length); 213 output.Write(buffer, 0, buffer.Length);
213 output.Close(); 214 output.Close();
215 } catch (Exception e) {
216 Console.WriteLine(e.ToString());
217 }
214 } 218 }
215 219
216 public void Start() 220 public void Start()