aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services/HypergridService
diff options
context:
space:
mode:
authorMelanie2013-07-18 10:08:10 +0100
committerMelanie2013-07-18 10:08:10 +0100
commit7830cc995471120892a24a39e86283774fa07c4c (patch)
treed3f46b4f3ce95bb8572511c6f12c9f8ca86922c8 /OpenSim/Services/HypergridService
parentMerge branch 'master' into careminster (diff)
parentDocument obscure Groups config related to the user level required for creatin... (diff)
downloadopensim-SC_OLD-7830cc995471120892a24a39e86283774fa07c4c.zip
opensim-SC_OLD-7830cc995471120892a24a39e86283774fa07c4c.tar.gz
opensim-SC_OLD-7830cc995471120892a24a39e86283774fa07c4c.tar.bz2
opensim-SC_OLD-7830cc995471120892a24a39e86283774fa07c4c.tar.xz
Merge branch 'master' into careminster
Conflicts: OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs OpenSim/Region/ClientStack/Linden/Caps/UploadBakedTextureModule.cs OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs OpenSim/Region/Framework/Scenes/Scene.cs OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs OpenSim/Region/Framework/Scenes/SceneObjectPart.cs OpenSim/Region/Framework/Scenes/ScenePresence.cs OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs OpenSim/Server/Handlers/Simulation/AgentHandlers.cs OpenSim/Services/Connectors/Asset/AssetServicesConnector.cs OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs OpenSim/Services/HypergridService/UserAgentService.cs
Diffstat (limited to 'OpenSim/Services/HypergridService')
-rw-r--r--OpenSim/Services/HypergridService/GatekeeperService.cs6
-rw-r--r--OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs6
-rw-r--r--OpenSim/Services/HypergridService/UserAgentService.cs208
-rw-r--r--OpenSim/Services/HypergridService/UserAgentServiceBase.cs84
4 files changed, 212 insertions, 92 deletions
diff --git a/OpenSim/Services/HypergridService/GatekeeperService.cs b/OpenSim/Services/HypergridService/GatekeeperService.cs
index 0cf1c14..0a3e70b 100644
--- a/OpenSim/Services/HypergridService/GatekeeperService.cs
+++ b/OpenSim/Services/HypergridService/GatekeeperService.cs
@@ -419,6 +419,12 @@ namespace OpenSim.Services.HypergridService
419 if (!CheckAddress(aCircuit.ServiceSessionID)) 419 if (!CheckAddress(aCircuit.ServiceSessionID))
420 return false; 420 return false;
421 421
422 if (string.IsNullOrEmpty(aCircuit.IPAddress))
423 {
424 m_log.DebugFormat("[GATEKEEPER SERVICE]: Agent did not provide a client IP address.");
425 return false;
426 }
427
422 string userURL = string.Empty; 428 string userURL = string.Empty;
423 if (aCircuit.ServiceURLs.ContainsKey("HomeURI")) 429 if (aCircuit.ServiceURLs.ContainsKey("HomeURI"))
424 userURL = aCircuit.ServiceURLs["HomeURI"].ToString(); 430 userURL = aCircuit.ServiceURLs["HomeURI"].ToString();
diff --git a/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs b/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs
index 410916f..2567c8f 100644
--- a/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs
+++ b/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs
@@ -54,7 +54,7 @@ namespace OpenSim.Services.HypergridService
54 LogManager.GetLogger( 54 LogManager.GetLogger(
55 MethodBase.GetCurrentMethod().DeclaringType); 55 MethodBase.GetCurrentMethod().DeclaringType);
56 56
57 private string m_HomeURL; 57// private string m_HomeURL;
58 private IUserAccountService m_UserAccountService; 58 private IUserAccountService m_UserAccountService;
59 private IAvatarService m_AvatarService; 59 private IAvatarService m_AvatarService;
60 60
@@ -96,8 +96,8 @@ namespace OpenSim.Services.HypergridService
96 if (m_AvatarService == null) 96 if (m_AvatarService == null)
97 throw new Exception(String.Format("Unable to create m_AvatarService from {0}", avatarDll)); 97 throw new Exception(String.Format("Unable to create m_AvatarService from {0}", avatarDll));
98 98
99 m_HomeURL = Util.GetConfigVarFromSections<string>(config, "HomeURI", 99// m_HomeURL = Util.GetConfigVarFromSections<string>(config, "HomeURI",
100 new string[] { "Startup", "Hypergrid", m_ConfigName }, String.Empty); 100// new string[] { "Startup", "Hypergrid", m_ConfigName }, String.Empty);
101 101
102// m_Cache = UserAccountCache.CreateUserAccountCache(m_UserAccountService); 102// m_Cache = UserAccountCache.CreateUserAccountCache(m_UserAccountService);
103 } 103 }
diff --git a/OpenSim/Services/HypergridService/UserAgentService.cs b/OpenSim/Services/HypergridService/UserAgentService.cs
index a6b5fc2..b414aca 100644
--- a/OpenSim/Services/HypergridService/UserAgentService.cs
+++ b/OpenSim/Services/HypergridService/UserAgentService.cs
@@ -30,6 +30,7 @@ using System.Collections.Generic;
30using System.Net; 30using System.Net;
31using System.Reflection; 31using System.Reflection;
32 32
33using OpenSim.Data;
33using OpenSim.Framework; 34using OpenSim.Framework;
34using OpenSim.Services.Connectors.Friends; 35using OpenSim.Services.Connectors.Friends;
35using OpenSim.Services.Connectors.Hypergrid; 36using OpenSim.Services.Connectors.Hypergrid;
@@ -50,14 +51,14 @@ namespace OpenSim.Services.HypergridService
50 /// needs to do it for them. 51 /// needs to do it for them.
51 /// Once we have better clients, this shouldn't be needed. 52 /// Once we have better clients, this shouldn't be needed.
52 /// </summary> 53 /// </summary>
53 public class UserAgentService : IUserAgentService 54 public class UserAgentService : UserAgentServiceBase, IUserAgentService
54 { 55 {
55 private static readonly ILog m_log = 56 private static readonly ILog m_log =
56 LogManager.GetLogger( 57 LogManager.GetLogger(
57 MethodBase.GetCurrentMethod().DeclaringType); 58 MethodBase.GetCurrentMethod().DeclaringType);
58 59
59 // This will need to go into a DB table 60 // This will need to go into a DB table
60 static Dictionary<UUID, TravelingAgentInfo> m_TravelingAgents = new Dictionary<UUID, TravelingAgentInfo>(); 61 //static Dictionary<UUID, TravelingAgentInfo> m_Database = new Dictionary<UUID, TravelingAgentInfo>();
61 62
62 static bool m_Initialized = false; 63 static bool m_Initialized = false;
63 64
@@ -86,6 +87,7 @@ namespace OpenSim.Services.HypergridService
86 } 87 }
87 88
88 public UserAgentService(IConfigSource config, IFriendsSimConnector friendsConnector) 89 public UserAgentService(IConfigSource config, IFriendsSimConnector friendsConnector)
90 : base(config)
89 { 91 {
90 // Let's set this always, because we don't know the sequence 92 // Let's set this always, because we don't know the sequence
91 // of instantiations 93 // of instantiations
@@ -146,6 +148,9 @@ namespace OpenSim.Services.HypergridService
146 if (!m_GridName.EndsWith("/")) 148 if (!m_GridName.EndsWith("/"))
147 m_GridName = m_GridName + "/"; 149 m_GridName = m_GridName + "/";
148 150
151 // Finally some cleanup
152 m_Database.DeleteOld();
153
149 } 154 }
150 } 155 }
151 156
@@ -260,7 +265,8 @@ namespace OpenSim.Services.HypergridService
260 265
261 // Generate a new service session 266 // Generate a new service session
262 agentCircuit.ServiceSessionID = region.ServerURI + ";" + UUID.Random(); 267 agentCircuit.ServiceSessionID = region.ServerURI + ";" + UUID.Random();
263 TravelingAgentInfo old = UpdateTravelInfo(agentCircuit, region); 268 TravelingAgentInfo old = null;
269 TravelingAgentInfo travel = CreateTravelInfo(agentCircuit, region, fromLogin, out old);
264 270
265 bool success = false; 271 bool success = false;
266 string myExternalIP = string.Empty; 272 string myExternalIP = string.Empty;
@@ -282,23 +288,21 @@ namespace OpenSim.Services.HypergridService
282 m_log.DebugFormat("[USER AGENT SERVICE]: Unable to login user {0} {1} to grid {2}, reason: {3}", 288 m_log.DebugFormat("[USER AGENT SERVICE]: Unable to login user {0} {1} to grid {2}, reason: {3}",
283 agentCircuit.firstname, agentCircuit.lastname, region.ServerURI, reason); 289 agentCircuit.firstname, agentCircuit.lastname, region.ServerURI, reason);
284 290
285 // restore the old travel info 291 if (old != null)
286 lock (m_TravelingAgents) 292 StoreTravelInfo(old);
287 { 293 else
288 if (old == null) 294 m_Database.Delete(agentCircuit.SessionID);
289 m_TravelingAgents.Remove(agentCircuit.SessionID);
290 else
291 m_TravelingAgents[agentCircuit.SessionID] = old;
292 }
293 295
294 return false; 296 return false;
295 } 297 }
296 298
299 // Everything is ok
300
301 // Update the perceived IP Address of our grid
297 m_log.DebugFormat("[USER AGENT SERVICE]: Gatekeeper sees me as {0}", myExternalIP); 302 m_log.DebugFormat("[USER AGENT SERVICE]: Gatekeeper sees me as {0}", myExternalIP);
298 // else set the IP addresses associated with this client 303 travel.MyIpAddress = myExternalIP;
299 if (fromLogin) 304
300 m_TravelingAgents[agentCircuit.SessionID].ClientIPAddress = agentCircuit.IPAddress; 305 StoreTravelInfo(travel);
301 m_TravelingAgents[agentCircuit.SessionID].MyIpAddress = myExternalIP;
302 306
303 return true; 307 return true;
304 } 308 }
@@ -309,57 +313,39 @@ namespace OpenSim.Services.HypergridService
309 return LoginAgentToGrid(agentCircuit, gatekeeper, finalDestination, false, out reason); 313 return LoginAgentToGrid(agentCircuit, gatekeeper, finalDestination, false, out reason);
310 } 314 }
311 315
312 private void SetClientIP(UUID sessionID, string ip) 316 TravelingAgentInfo CreateTravelInfo(AgentCircuitData agentCircuit, GridRegion region, bool fromLogin, out TravelingAgentInfo existing)
313 { 317 {
314 if (m_TravelingAgents.ContainsKey(sessionID)) 318 HGTravelingData hgt = m_Database.Get(agentCircuit.SessionID);
315 { 319 existing = null;
316 m_log.DebugFormat("[USER AGENT SERVICE]: Setting IP {0} for session {1}", ip, sessionID);
317 m_TravelingAgents[sessionID].ClientIPAddress = ip;
318 }
319 }
320 320
321 TravelingAgentInfo UpdateTravelInfo(AgentCircuitData agentCircuit, GridRegion region) 321 if (hgt != null)
322 {
323 TravelingAgentInfo travel = new TravelingAgentInfo();
324 TravelingAgentInfo old = null;
325 lock (m_TravelingAgents)
326 { 322 {
327 if (m_TravelingAgents.ContainsKey(agentCircuit.SessionID)) 323 // Very important! Override whatever this agent comes with.
328 { 324 // UserAgentService always sets the IP for every new agent
329 // Very important! Override whatever this agent comes with. 325 // with the original IP address.
330 // UserAgentService always sets the IP for every new agent 326 existing = new TravelingAgentInfo(hgt);
331 // with the original IP address. 327 agentCircuit.IPAddress = existing.ClientIPAddress;
332 agentCircuit.IPAddress = m_TravelingAgents[agentCircuit.SessionID].ClientIPAddress;
333
334 old = m_TravelingAgents[agentCircuit.SessionID];
335 }
336
337 m_TravelingAgents[agentCircuit.SessionID] = travel;
338 } 328 }
329
330 TravelingAgentInfo travel = new TravelingAgentInfo(existing);
331 travel.SessionID = agentCircuit.SessionID;
339 travel.UserID = agentCircuit.AgentID; 332 travel.UserID = agentCircuit.AgentID;
340 travel.GridExternalName = region.ServerURI; 333 travel.GridExternalName = region.ServerURI;
341 travel.ServiceToken = agentCircuit.ServiceSessionID; 334 travel.ServiceToken = agentCircuit.ServiceSessionID;
342 if (old != null)
343 travel.ClientIPAddress = old.ClientIPAddress;
344 335
345 return old; 336 if (fromLogin)
337 travel.ClientIPAddress = agentCircuit.IPAddress;
338
339 StoreTravelInfo(travel);
340
341 return travel;
346 } 342 }
347 343
348 public void LogoutAgent(UUID userID, UUID sessionID) 344 public void LogoutAgent(UUID userID, UUID sessionID)
349 { 345 {
350 m_log.DebugFormat("[USER AGENT SERVICE]: User {0} logged out", userID); 346 m_log.DebugFormat("[USER AGENT SERVICE]: User {0} logged out", userID);
351 347
352 lock (m_TravelingAgents) 348 m_Database.Delete(sessionID);
353 {
354 List<UUID> travels = new List<UUID>();
355 foreach (KeyValuePair<UUID, TravelingAgentInfo> kvp in m_TravelingAgents)
356 if (kvp.Value == null) // do some clean up
357 travels.Add(kvp.Key);
358 else if (kvp.Value.UserID == userID)
359 travels.Add(kvp.Key);
360 foreach (UUID session in travels)
361 m_TravelingAgents.Remove(session);
362 }
363 349
364 GridUserInfo guinfo = m_GridUserService.GetGridUserInfo(userID.ToString()); 350 GridUserInfo guinfo = m_GridUserService.GetGridUserInfo(userID.ToString());
365 if (guinfo != null) 351 if (guinfo != null)
@@ -369,10 +355,11 @@ namespace OpenSim.Services.HypergridService
369 // We need to prevent foreign users with the same UUID as a local user 355 // We need to prevent foreign users with the same UUID as a local user
370 public bool IsAgentComingHome(UUID sessionID, string thisGridExternalName) 356 public bool IsAgentComingHome(UUID sessionID, string thisGridExternalName)
371 { 357 {
372 if (!m_TravelingAgents.ContainsKey(sessionID)) 358 HGTravelingData hgt = m_Database.Get(sessionID);
359 if (hgt == null)
373 return false; 360 return false;
374 361
375 TravelingAgentInfo travel = m_TravelingAgents[sessionID]; 362 TravelingAgentInfo travel = new TravelingAgentInfo(hgt);
376 363
377 return travel.GridExternalName.ToLower() == thisGridExternalName.ToLower(); 364 return travel.GridExternalName.ToLower() == thisGridExternalName.ToLower();
378 } 365 }
@@ -385,29 +372,32 @@ namespace OpenSim.Services.HypergridService
385 m_log.DebugFormat("[USER AGENT SERVICE]: Verifying Client session {0} with reported IP {1}.", 372 m_log.DebugFormat("[USER AGENT SERVICE]: Verifying Client session {0} with reported IP {1}.",
386 sessionID, reportedIP); 373 sessionID, reportedIP);
387 374
388 if (m_TravelingAgents.ContainsKey(sessionID)) 375 HGTravelingData hgt = m_Database.Get(sessionID);
389 { 376 if (hgt == null)
390 m_log.DebugFormat("[USER AGENT SERVICE]: Comparing with login IP {0} and MyIP {1}", 377 return false;
391 m_TravelingAgents[sessionID].ClientIPAddress, m_TravelingAgents[sessionID].MyIpAddress);
392 378
393 return m_TravelingAgents[sessionID].ClientIPAddress == reportedIP || 379 TravelingAgentInfo travel = new TravelingAgentInfo(hgt);
394 m_TravelingAgents[sessionID].MyIpAddress == reportedIP; // NATed
395 }
396 380
397 return false; 381 bool result = travel.ClientIPAddress == reportedIP || travel.MyIpAddress == reportedIP; // NATed
382
383 m_log.DebugFormat("[USER AGENT SERVICE]: Comparing {0} with login IP {1} and MyIP {1}; result is {3}",
384 reportedIP, travel.ClientIPAddress, travel.MyIpAddress, result);
385
386 return result;
398 } 387 }
399 388
400 public bool VerifyAgent(UUID sessionID, string token) 389 public bool VerifyAgent(UUID sessionID, string token)
401 { 390 {
402 if (m_TravelingAgents.ContainsKey(sessionID)) 391 HGTravelingData hgt = m_Database.Get(sessionID);
392 if (hgt == null)
403 { 393 {
404 m_log.DebugFormat("[USER AGENT SERVICE]: Verifying agent token {0} against {1}", token, m_TravelingAgents[sessionID].ServiceToken); 394 m_log.DebugFormat("[USER AGENT SERVICE]: Token verification for session {0}: no such session", sessionID);
405 return m_TravelingAgents[sessionID].ServiceToken == token; 395 return false;
406 } 396 }
407 397
408 m_log.DebugFormat("[USER AGENT SERVICE]: Token verification for session {0}: no such session", sessionID); 398 TravelingAgentInfo travel = new TravelingAgentInfo(hgt);
409 399 m_log.DebugFormat("[USER AGENT SERVICE]: Verifying agent token {0} against {1}", token, travel.ServiceToken);
410 return false; 400 return travel.ServiceToken == token;
411 } 401 }
412 402
413 [Obsolete] 403 [Obsolete]
@@ -470,17 +460,17 @@ namespace OpenSim.Services.HypergridService
470 } 460 }
471 } 461 }
472 462
473 // Lastly, let's notify the rest who may be online somewhere else 463 //// Lastly, let's notify the rest who may be online somewhere else
474 foreach (string user in usersToBeNotified) 464 //foreach (string user in usersToBeNotified)
475 { 465 //{
476 UUID id = new UUID(user); 466 // UUID id = new UUID(user);
477 if (m_TravelingAgents.ContainsKey(id) && m_TravelingAgents[id].GridExternalName != m_GridName) 467 // if (m_Database.ContainsKey(id) && m_Database[id].GridExternalName != m_GridName)
478 { 468 // {
479 string url = m_TravelingAgents[id].GridExternalName; 469 // string url = m_Database[id].GridExternalName;
480 // forward 470 // // forward
481 m_log.WarnFormat("[USER AGENT SERVICE]: User {0} is visiting {1}. HG Status notifications still not implemented.", user, url); 471 // m_log.WarnFormat("[USER AGENT SERVICE]: User {0} is visiting {1}. HG Status notifications still not implemented.", user, url);
482 } 472 // }
483 } 473 //}
484 474
485 // and finally, let's send the online friends 475 // and finally, let's send the online friends
486 if (online) 476 if (online)
@@ -607,16 +597,13 @@ namespace OpenSim.Services.HypergridService
607 597
608 public string LocateUser(UUID userID) 598 public string LocateUser(UUID userID)
609 { 599 {
610 foreach (TravelingAgentInfo t in m_TravelingAgents.Values) 600 HGTravelingData[] hgts = m_Database.GetSessions(userID);
611 { 601 if (hgts == null)
612 if (t == null) 602 return string.Empty;
613 { 603
614 m_log.ErrorFormat("[USER AGENT SERVICE]: Oops! Null TravelingAgentInfo. Please report this on mantis"); 604 foreach (HGTravelingData t in hgts)
615 continue; 605 if (t.Data.ContainsKey("GridExternalName") && !m_GridName.Equals(t.Data["GridExternalName"]))
616 } 606 return t.Data["GridExternalName"];
617 if (t.UserID == userID && !m_GridName.Equals(t.GridExternalName))
618 return t.GridExternalName;
619 }
620 607
621 return string.Empty; 608 return string.Empty;
622 } 609 }
@@ -687,17 +674,60 @@ namespace OpenSim.Services.HypergridService
687 return exception; 674 return exception;
688 } 675 }
689 676
677 private void StoreTravelInfo(TravelingAgentInfo travel)
678 {
679 if (travel == null)
680 return;
681
682 HGTravelingData hgt = new HGTravelingData();
683 hgt.SessionID = travel.SessionID;
684 hgt.UserID = travel.UserID;
685 hgt.Data = new Dictionary<string, string>();
686 hgt.Data["GridExternalName"] = travel.GridExternalName;
687 hgt.Data["ServiceToken"] = travel.ServiceToken;
688 hgt.Data["ClientIPAddress"] = travel.ClientIPAddress;
689 hgt.Data["MyIPAddress"] = travel.MyIpAddress;
690
691 m_Database.Store(hgt);
692 }
690 #endregion 693 #endregion
691 694
692 } 695 }
693 696
694 class TravelingAgentInfo 697 class TravelingAgentInfo
695 { 698 {
699 public UUID SessionID;
696 public UUID UserID; 700 public UUID UserID;
697 public string GridExternalName = string.Empty; 701 public string GridExternalName = string.Empty;
698 public string ServiceToken = string.Empty; 702 public string ServiceToken = string.Empty;
699 public string ClientIPAddress = string.Empty; // as seen from this user agent service 703 public string ClientIPAddress = string.Empty; // as seen from this user agent service
700 public string MyIpAddress = string.Empty; // the user agent service's external IP, as seen from the next gatekeeper 704 public string MyIpAddress = string.Empty; // the user agent service's external IP, as seen from the next gatekeeper
705
706 public TravelingAgentInfo(HGTravelingData t)
707 {
708 if (t.Data != null)
709 {
710 SessionID = new UUID(t.SessionID);
711 UserID = new UUID(t.UserID);
712 GridExternalName = t.Data["GridExternalName"];
713 ServiceToken = t.Data["ServiceToken"];
714 ClientIPAddress = t.Data["ClientIPAddress"];
715 MyIpAddress = t.Data["MyIPAddress"];
716 }
717 }
718
719 public TravelingAgentInfo(TravelingAgentInfo old)
720 {
721 if (old != null)
722 {
723 SessionID = old.SessionID;
724 UserID = old.UserID;
725 GridExternalName = old.GridExternalName;
726 ServiceToken = old.ServiceToken;
727 ClientIPAddress = old.ClientIPAddress;
728 MyIpAddress = old.MyIpAddress;
729 }
730 }
701 } 731 }
702 732
703} 733}
diff --git a/OpenSim/Services/HypergridService/UserAgentServiceBase.cs b/OpenSim/Services/HypergridService/UserAgentServiceBase.cs
new file mode 100644
index 0000000..a00e5a6
--- /dev/null
+++ b/OpenSim/Services/HypergridService/UserAgentServiceBase.cs
@@ -0,0 +1,84 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Reflection;
30using Nini.Config;
31using OpenSim.Framework;
32using OpenSim.Data;
33using OpenSim.Services.Interfaces;
34using OpenSim.Services.Base;
35
36namespace OpenSim.Services.HypergridService
37{
38 public class UserAgentServiceBase : ServiceBase
39 {
40 protected IHGTravelingData m_Database = null;
41
42 public UserAgentServiceBase(IConfigSource config)
43 : base(config)
44 {
45 string dllName = String.Empty;
46 string connString = String.Empty;
47 string realm = "hg_traveling_data";
48
49 //
50 // Try reading the [DatabaseService] section, if it exists
51 //
52 IConfig dbConfig = config.Configs["DatabaseService"];
53 if (dbConfig != null)
54 {
55 if (dllName == String.Empty)
56 dllName = dbConfig.GetString("StorageProvider", String.Empty);
57 if (connString == String.Empty)
58 connString = dbConfig.GetString("ConnectionString", String.Empty);
59 }
60
61 //
62 // [UserAgentService] section overrides [DatabaseService], if it exists
63 //
64 IConfig gridConfig = config.Configs["UserAgentService"];
65 if (gridConfig != null)
66 {
67 dllName = gridConfig.GetString("StorageProvider", dllName);
68 connString = gridConfig.GetString("ConnectionString", connString);
69 realm = gridConfig.GetString("Realm", realm);
70 }
71
72 //
73 // We tried, but this doesn't exist. We can't proceed.
74 //
75 if (dllName.Equals(String.Empty))
76 throw new Exception("No StorageProvider configured");
77
78 m_Database = LoadPlugin<IHGTravelingData>(dllName, new Object[] { connString, realm });
79 if (m_Database == null)
80 throw new Exception("Could not find a storage interface in the given module");
81
82 }
83 }
84}