aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenGridServices.GridServer
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenGridServices.GridServer/Main.cs20
-rw-r--r--OpenGridServices.GridServer/SimProfiles.cs65
2 files changed, 47 insertions, 38 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;