aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services/HypergridService
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Services/HypergridService')
-rw-r--r--OpenSim/Services/HypergridService/GatekeeperService.cs116
-rw-r--r--OpenSim/Services/HypergridService/HGAssetService.cs26
-rw-r--r--OpenSim/Services/HypergridService/HGFriendsService.cs2
-rw-r--r--OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs76
-rw-r--r--OpenSim/Services/HypergridService/Properties/AssemblyInfo.cs33
-rw-r--r--OpenSim/Services/HypergridService/UserAgentService.cs105
6 files changed, 330 insertions, 28 deletions
diff --git a/OpenSim/Services/HypergridService/GatekeeperService.cs b/OpenSim/Services/HypergridService/GatekeeperService.cs
index 47d22b9..7b84d55 100644
--- a/OpenSim/Services/HypergridService/GatekeeperService.cs
+++ b/OpenSim/Services/HypergridService/GatekeeperService.cs
@@ -57,14 +57,18 @@ namespace OpenSim.Services.HypergridService
57 private static IUserAccountService m_UserAccountService; 57 private static IUserAccountService m_UserAccountService;
58 private static IUserAgentService m_UserAgentService; 58 private static IUserAgentService m_UserAgentService;
59 private static ISimulationService m_SimulationService; 59 private static ISimulationService m_SimulationService;
60 private static IGridUserService m_GridUserService;
60 61
61 protected string m_AllowedClients = string.Empty; 62 private static string m_AllowedClients = string.Empty;
62 protected string m_DeniedClients = string.Empty; 63 private static string m_DeniedClients = string.Empty;
63 private static bool m_ForeignAgentsAllowed = true; 64 private static bool m_ForeignAgentsAllowed = true;
65 private static List<string> m_ForeignsAllowedExceptions = new List<string>();
66 private static List<string> m_ForeignsDisallowedExceptions = new List<string>();
64 67
65 private static UUID m_ScopeID; 68 private static UUID m_ScopeID;
66 private static bool m_AllowTeleportsToAnyRegion; 69 private static bool m_AllowTeleportsToAnyRegion;
67 private static string m_ExternalName; 70 private static string m_ExternalName;
71 private static Uri m_Uri;
68 private static GridRegion m_DefaultGatewayRegion; 72 private static GridRegion m_DefaultGatewayRegion;
69 73
70 public GatekeeperService(IConfigSource config, ISimulationService simService) 74 public GatekeeperService(IConfigSource config, ISimulationService simService)
@@ -82,8 +86,9 @@ namespace OpenSim.Services.HypergridService
82 string gridService = serverConfig.GetString("GridService", String.Empty); 86 string gridService = serverConfig.GetString("GridService", String.Empty);
83 string presenceService = serverConfig.GetString("PresenceService", String.Empty); 87 string presenceService = serverConfig.GetString("PresenceService", String.Empty);
84 string simulationService = serverConfig.GetString("SimulationService", String.Empty); 88 string simulationService = serverConfig.GetString("SimulationService", String.Empty);
89 string gridUserService = serverConfig.GetString("GridUserService", String.Empty);
85 90
86 // These 3 are mandatory, the others aren't 91 // These are mandatory, the others aren't
87 if (gridService == string.Empty || presenceService == string.Empty) 92 if (gridService == string.Empty || presenceService == string.Empty)
88 throw new Exception("Incomplete specifications, Gatekeeper Service cannot function."); 93 throw new Exception("Incomplete specifications, Gatekeeper Service cannot function.");
89 94
@@ -95,6 +100,15 @@ namespace OpenSim.Services.HypergridService
95 if (m_ExternalName != string.Empty && !m_ExternalName.EndsWith("/")) 100 if (m_ExternalName != string.Empty && !m_ExternalName.EndsWith("/"))
96 m_ExternalName = m_ExternalName + "/"; 101 m_ExternalName = m_ExternalName + "/";
97 102
103 try
104 {
105 m_Uri = new Uri(m_ExternalName);
106 }
107 catch
108 {
109 m_log.WarnFormat("[GATEKEEPER SERVICE]: Malformed gatekeeper address {0}", m_ExternalName);
110 }
111
98 Object[] args = new Object[] { config }; 112 Object[] args = new Object[] { config };
99 m_GridService = ServerUtils.LoadPlugin<IGridService>(gridService, args); 113 m_GridService = ServerUtils.LoadPlugin<IGridService>(gridService, args);
100 m_PresenceService = ServerUtils.LoadPlugin<IPresenceService>(presenceService, args); 114 m_PresenceService = ServerUtils.LoadPlugin<IPresenceService>(presenceService, args);
@@ -103,6 +117,8 @@ namespace OpenSim.Services.HypergridService
103 m_UserAccountService = ServerUtils.LoadPlugin<IUserAccountService>(accountService, args); 117 m_UserAccountService = ServerUtils.LoadPlugin<IUserAccountService>(accountService, args);
104 if (homeUsersService != string.Empty) 118 if (homeUsersService != string.Empty)
105 m_UserAgentService = ServerUtils.LoadPlugin<IUserAgentService>(homeUsersService, args); 119 m_UserAgentService = ServerUtils.LoadPlugin<IUserAgentService>(homeUsersService, args);
120 if (gridUserService != string.Empty)
121 m_GridUserService = ServerUtils.LoadPlugin<IGridUserService>(gridUserService, args);
106 122
107 if (simService != null) 123 if (simService != null)
108 m_SimulationService = simService; 124 m_SimulationService = simService;
@@ -113,6 +129,9 @@ namespace OpenSim.Services.HypergridService
113 m_DeniedClients = serverConfig.GetString("DeniedClients", string.Empty); 129 m_DeniedClients = serverConfig.GetString("DeniedClients", string.Empty);
114 m_ForeignAgentsAllowed = serverConfig.GetBoolean("ForeignAgentsAllowed", true); 130 m_ForeignAgentsAllowed = serverConfig.GetBoolean("ForeignAgentsAllowed", true);
115 131
132 LoadDomainExceptionsFromConfig(serverConfig, "AllowExcept", m_ForeignsAllowedExceptions);
133 LoadDomainExceptionsFromConfig(serverConfig, "DisallowExcept", m_ForeignsDisallowedExceptions);
134
116 if (m_GridService == null || m_PresenceService == null || m_SimulationService == null) 135 if (m_GridService == null || m_PresenceService == null || m_SimulationService == null)
117 throw new Exception("Unable to load a required plugin, Gatekeeper Service cannot function."); 136 throw new Exception("Unable to load a required plugin, Gatekeeper Service cannot function.");
118 137
@@ -125,6 +144,15 @@ namespace OpenSim.Services.HypergridService
125 { 144 {
126 } 145 }
127 146
147 protected void LoadDomainExceptionsFromConfig(IConfig config, string variable, List<string> exceptions)
148 {
149 string value = config.GetString(variable, string.Empty);
150 string[] parts = value.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
151
152 foreach (string s in parts)
153 exceptions.Add(s.Trim());
154 }
155
128 public bool LinkRegion(string regionName, out UUID regionID, out ulong regionHandle, out string externalName, out string imageURL, out string reason) 156 public bool LinkRegion(string regionName, out UUID regionID, out ulong regionHandle, out string externalName, out string imageURL, out string reason)
129 { 157 {
130 regionID = UUID.Zero; 158 regionID = UUID.Zero;
@@ -260,17 +288,26 @@ namespace OpenSim.Services.HypergridService
260 m_log.DebugFormat("[GATEKEEPER SERVICE]: User is ok"); 288 m_log.DebugFormat("[GATEKEEPER SERVICE]: User is ok");
261 289
262 // 290 //
263 // Foreign agents allowed 291 // Foreign agents allowed? Exceptions?
264 // 292 //
265 if (account == null && !m_ForeignAgentsAllowed) 293 if (account == null)
266 { 294 {
267 reason = "Unauthorized"; 295 bool allowed = m_ForeignAgentsAllowed;
268 m_log.InfoFormat("[GATEKEEPER SERVICE]: Foreign agents are not permitted {0} {1}. Refusing service.",
269 aCircuit.firstname, aCircuit.lastname);
270 return false;
271 }
272 296
273 // May want to authorize 297 if (m_ForeignAgentsAllowed && IsException(aCircuit, m_ForeignsAllowedExceptions))
298 allowed = false;
299
300 if (!m_ForeignAgentsAllowed && IsException(aCircuit, m_ForeignsDisallowedExceptions))
301 allowed = true;
302
303 if (!allowed)
304 {
305 reason = "Destination does not allow visitors from your world";
306 m_log.InfoFormat("[GATEKEEPER SERVICE]: Foreign agents are not permitted {0} {1} @ {2}. Refusing service.",
307 aCircuit.firstname, aCircuit.lastname, aCircuit.ServiceURLs["HomeURI"]);
308 return false;
309 }
310 }
274 311
275 bool isFirstLogin = false; 312 bool isFirstLogin = false;
276 // 313 //
@@ -280,7 +317,8 @@ namespace OpenSim.Services.HypergridService
280 if (presence != null) // it has been placed there by the login service 317 if (presence != null) // it has been placed there by the login service
281 isFirstLogin = true; 318 isFirstLogin = true;
282 319
283 else 320 else
321 {
284 if (!m_PresenceService.LoginAgent(aCircuit.AgentID.ToString(), aCircuit.SessionID, aCircuit.SecureSessionID)) 322 if (!m_PresenceService.LoginAgent(aCircuit.AgentID.ToString(), aCircuit.SessionID, aCircuit.SecureSessionID))
285 { 323 {
286 reason = "Unable to login presence"; 324 reason = "Unable to login presence";
@@ -290,6 +328,26 @@ namespace OpenSim.Services.HypergridService
290 } 328 }
291 m_log.DebugFormat("[GATEKEEPER SERVICE]: Login presence ok"); 329 m_log.DebugFormat("[GATEKEEPER SERVICE]: Login presence ok");
292 330
331 // Also login foreigners with GridUser service
332 if (m_GridUserService != null && account == null)
333 {
334 string userId = aCircuit.AgentID.ToString();
335 string first = aCircuit.firstname, last = aCircuit.lastname;
336 if (last.StartsWith("@"))
337 {
338 string[] parts = aCircuit.firstname.Split('.');
339 if (parts.Length >= 2)
340 {
341 first = parts[0];
342 last = parts[1];
343 }
344 }
345
346 userId += ";" + aCircuit.ServiceURLs["HomeURI"] + ";" + first + " " + last;
347 m_GridUserService.LoggedIn(userId);
348 }
349 }
350
293 // 351 //
294 // Get the region 352 // Get the region
295 // 353 //
@@ -385,7 +443,18 @@ namespace OpenSim.Services.HypergridService
385 string externalname = m_ExternalName.TrimEnd(trailing_slash); 443 string externalname = m_ExternalName.TrimEnd(trailing_slash);
386 m_log.DebugFormat("[GATEKEEPER SERVICE]: Verifying {0} against {1}", addressee, externalname); 444 m_log.DebugFormat("[GATEKEEPER SERVICE]: Verifying {0} against {1}", addressee, externalname);
387 445
388 return string.Equals(addressee, externalname, StringComparison.OrdinalIgnoreCase); 446 Uri uri;
447 try
448 {
449 uri = new Uri(addressee);
450 }
451 catch
452 {
453 m_log.DebugFormat("[GATEKEEPER SERVICE]: Visitor provided malformed service address {0}", addressee);
454 return false;
455 }
456
457 return string.Equals(uri.GetLeftPart(UriPartial.Authority), m_Uri.GetLeftPart(UriPartial.Authority), StringComparison.OrdinalIgnoreCase) ;
389 } 458 }
390 459
391 #endregion 460 #endregion
@@ -393,6 +462,27 @@ namespace OpenSim.Services.HypergridService
393 462
394 #region Misc 463 #region Misc
395 464
465 private bool IsException(AgentCircuitData aCircuit, List<string> exceptions)
466 {
467 bool exception = false;
468 if (exceptions.Count > 0) // we have exceptions
469 {
470 // Retrieve the visitor's origin
471 string userURL = aCircuit.ServiceURLs["HomeURI"].ToString();
472 if (!userURL.EndsWith("/"))
473 userURL += "/";
474
475 if (exceptions.Find(delegate(string s)
476 {
477 if (!s.EndsWith("/"))
478 s += "/";
479 return s == userURL;
480 }) != null)
481 exception = true;
482 }
483
484 return exception;
485 }
396 486
397 #endregion 487 #endregion
398 } 488 }
diff --git a/OpenSim/Services/HypergridService/HGAssetService.cs b/OpenSim/Services/HypergridService/HGAssetService.cs
index db98166..84dec8d 100644
--- a/OpenSim/Services/HypergridService/HGAssetService.cs
+++ b/OpenSim/Services/HypergridService/HGAssetService.cs
@@ -58,6 +58,8 @@ namespace OpenSim.Services.HypergridService
58 58
59 private UserAccountCache m_Cache; 59 private UserAccountCache m_Cache;
60 60
61 private AssetPermissions m_AssetPerms;
62
61 public HGAssetService(IConfigSource config, string configName) : base(config, configName) 63 public HGAssetService(IConfigSource config, string configName) : base(config, configName)
62 { 64 {
63 m_log.Debug("[HGAsset Service]: Starting"); 65 m_log.Debug("[HGAsset Service]: Starting");
@@ -80,6 +82,10 @@ namespace OpenSim.Services.HypergridService
80 m_HomeURL = assetConfig.GetString("HomeURI", m_HomeURL); 82 m_HomeURL = assetConfig.GetString("HomeURI", m_HomeURL);
81 83
82 m_Cache = UserAccountCache.CreateUserAccountCache(m_UserAccountService); 84 m_Cache = UserAccountCache.CreateUserAccountCache(m_UserAccountService);
85
86 // Permissions
87 m_AssetPerms = new AssetPermissions(assetConfig);
88
83 } 89 }
84 90
85 #region IAssetService overrides 91 #region IAssetService overrides
@@ -90,6 +96,9 @@ namespace OpenSim.Services.HypergridService
90 if (asset == null) 96 if (asset == null)
91 return null; 97 return null;
92 98
99 if (!m_AssetPerms.AllowedExport(asset.Type))
100 return null;
101
93 if (asset.Metadata.Type == (sbyte)AssetType.Object) 102 if (asset.Metadata.Type == (sbyte)AssetType.Object)
94 asset.Data = AdjustIdentifiers(asset.Data); ; 103 asset.Data = AdjustIdentifiers(asset.Data); ;
95 104
@@ -112,16 +121,27 @@ namespace OpenSim.Services.HypergridService
112 121
113 public override byte[] GetData(string id) 122 public override byte[] GetData(string id)
114 { 123 {
115 byte[] data = base.GetData(id); 124 AssetBase asset = Get(id);
125
126 if (asset == null)
127 return null;
116 128
117 if (data == null) 129 if (!m_AssetPerms.AllowedExport(asset.Type))
118 return null; 130 return null;
119 131
120 return AdjustIdentifiers(data); 132 return asset.Data;
121 } 133 }
122 134
123 //public virtual bool Get(string id, Object sender, AssetRetrieved handler) 135 //public virtual bool Get(string id, Object sender, AssetRetrieved handler)
124 136
137 public override string Store(AssetBase asset)
138 {
139 if (!m_AssetPerms.AllowedImport(asset.Type))
140 return string.Empty;
141
142 return base.Store(asset);
143 }
144
125 public override bool Delete(string id) 145 public override bool Delete(string id)
126 { 146 {
127 // NOGO 147 // NOGO
diff --git a/OpenSim/Services/HypergridService/HGFriendsService.cs b/OpenSim/Services/HypergridService/HGFriendsService.cs
index 98423d7..a8bcfb2 100644
--- a/OpenSim/Services/HypergridService/HGFriendsService.cs
+++ b/OpenSim/Services/HypergridService/HGFriendsService.cs
@@ -397,7 +397,7 @@ namespace OpenSim.Services.HypergridService
397 if (region != null) 397 if (region != null)
398 { 398 {
399 m_log.DebugFormat("[HGFRIENDS SERVICE]: Remote Notify to region {0}, user {1} is {2}", region.RegionName, foreignUserID, (online ? "online" : "offline")); 399 m_log.DebugFormat("[HGFRIENDS SERVICE]: Remote Notify to region {0}, user {1} is {2}", region.RegionName, foreignUserID, (online ? "online" : "offline"));
400 m_FriendsSimConnector.StatusNotify(region, foreignUserID, userID, online); 400 m_FriendsSimConnector.StatusNotify(region, foreignUserID, userID.ToString(), online);
401 } 401 }
402 } 402 }
403 } 403 }
diff --git a/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs b/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs
index 6e4b68c..784f136 100644
--- a/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs
+++ b/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs
@@ -56,10 +56,12 @@ namespace OpenSim.Services.HypergridService
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 60
60// private UserAccountCache m_Cache; 61// private UserAccountCache m_Cache;
61 62
62 private ExpiringCache<UUID, List<XInventoryFolder>> m_SuitcaseTrees = new ExpiringCache<UUID, List<XInventoryFolder>>(); 63 private ExpiringCache<UUID, List<XInventoryFolder>> m_SuitcaseTrees = new ExpiringCache<UUID, List<XInventoryFolder>>();
64 private ExpiringCache<UUID, AvatarAppearance> m_Appearances = new ExpiringCache<UUID, AvatarAppearance>();
63 65
64 public HGSuitcaseInventoryService(IConfigSource config, string configName) 66 public HGSuitcaseInventoryService(IConfigSource config, string configName)
65 : base(config, configName) 67 : base(config, configName)
@@ -69,7 +71,7 @@ namespace OpenSim.Services.HypergridService
69 m_ConfigName = configName; 71 m_ConfigName = configName;
70 72
71 if (m_Database == null) 73 if (m_Database == null)
72 m_log.WarnFormat("[XXX]: m_Database is null!"); 74 m_log.ErrorFormat("[HG SUITCASE INVENTORY SERVICE]: m_Database is null!");
73 75
74 // 76 //
75 // Try reading the [InventoryService] section, if it exists 77 // Try reading the [InventoryService] section, if it exists
@@ -77,7 +79,6 @@ namespace OpenSim.Services.HypergridService
77 IConfig invConfig = config.Configs[m_ConfigName]; 79 IConfig invConfig = config.Configs[m_ConfigName];
78 if (invConfig != null) 80 if (invConfig != null)
79 { 81 {
80 // realm = authConfig.GetString("Realm", realm);
81 string userAccountsDll = invConfig.GetString("UserAccountsService", string.Empty); 82 string userAccountsDll = invConfig.GetString("UserAccountsService", string.Empty);
82 if (userAccountsDll == string.Empty) 83 if (userAccountsDll == string.Empty)
83 throw new Exception("Please specify UserAccountsService in HGInventoryService configuration"); 84 throw new Exception("Please specify UserAccountsService in HGInventoryService configuration");
@@ -87,8 +88,14 @@ namespace OpenSim.Services.HypergridService
87 if (m_UserAccountService == null) 88 if (m_UserAccountService == null)
88 throw new Exception(String.Format("Unable to create UserAccountService from {0}", userAccountsDll)); 89 throw new Exception(String.Format("Unable to create UserAccountService from {0}", userAccountsDll));
89 90
90 // legacy configuration [obsolete] 91 string avatarDll = invConfig.GetString("AvatarService", string.Empty);
91 m_HomeURL = invConfig.GetString("ProfileServerURI", string.Empty); 92 if (avatarDll == string.Empty)
93 throw new Exception("Please specify AvatarService in HGInventoryService configuration");
94
95 m_AvatarService = ServerUtils.LoadPlugin<IAvatarService>(avatarDll, args);
96 if (m_AvatarService == null)
97 throw new Exception(String.Format("Unable to create m_AvatarService from {0}", avatarDll));
98
92 // Preferred 99 // Preferred
93 m_HomeURL = invConfig.GetString("HomeURI", m_HomeURL); 100 m_HomeURL = invConfig.GetString("HomeURI", m_HomeURL);
94 101
@@ -294,7 +301,7 @@ namespace OpenSim.Services.HypergridService
294 301
295 public override bool AddFolder(InventoryFolderBase folder) 302 public override bool AddFolder(InventoryFolderBase folder)
296 { 303 {
297 m_log.WarnFormat("[HG SUITCASE INVENTORY SERVICE]: AddFolder {0} {1}", folder.Name, folder.ParentID); 304 //m_log.WarnFormat("[HG SUITCASE INVENTORY SERVICE]: AddFolder {0} {1}", folder.Name, folder.ParentID);
298 // Let's do a bit of sanity checking, more than the base service does 305 // Let's do a bit of sanity checking, more than the base service does
299 // make sure the given folder's parent folder exists under the suitcase tree of this user 306 // make sure the given folder's parent folder exists under the suitcase tree of this user
300 307
@@ -316,7 +323,7 @@ namespace OpenSim.Services.HypergridService
316 323
317 public override bool UpdateFolder(InventoryFolderBase folder) 324 public override bool UpdateFolder(InventoryFolderBase folder)
318 { 325 {
319 m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: Update folder {0}, version {1}", folder.ID, folder.Version); 326 //m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: Update folder {0}, version {1}", folder.ID, folder.Version);
320 if (!IsWithinSuitcaseTree(folder.Owner, folder.ID)) 327 if (!IsWithinSuitcaseTree(folder.Owner, folder.ID))
321 { 328 {
322 m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: folder {0} not within Suitcase tree", folder.Name); 329 m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: folder {0} not within Suitcase tree", folder.Name);
@@ -394,7 +401,7 @@ namespace OpenSim.Services.HypergridService
394 return null; 401 return null;
395 } 402 }
396 403
397 if (!IsWithinSuitcaseTree(it.Owner, it.Folder)) 404 if (!IsWithinSuitcaseTree(it.Owner, it.Folder) && !IsPartOfAppearance(it.Owner, it.ID))
398 { 405 {
399 m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: Item {0} (folder {1}) is not within Suitcase", 406 m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: Item {0} (folder {1}) is not within Suitcase",
400 it.Name, it.Folder); 407 it.Name, it.Folder);
@@ -453,6 +460,15 @@ namespace OpenSim.Services.HypergridService
453 460
454 if (folders != null && folders.Length > 0) 461 if (folders != null && folders.Length > 0)
455 return folders[0]; 462 return folders[0];
463
464 // OK, so the RootFolder type didn't work. Let's look for any type with parent UUID.Zero.
465 folders = m_Database.GetFolders(
466 new string[] { "agentID", "folderName", "parentFolderID" },
467 new string[] { principalID.ToString(), "My Inventory", UUID.Zero.ToString() });
468
469 if (folders != null && folders.Length > 0)
470 return folders[0];
471
456 return null; 472 return null;
457 } 473 }
458 474
@@ -549,6 +565,52 @@ namespace OpenSim.Services.HypergridService
549 else return true; 565 else return true;
550 } 566 }
551 #endregion 567 #endregion
568
569 #region Avatar Appearance
570
571 private AvatarAppearance GetAppearance(UUID principalID)
572 {
573 AvatarAppearance a = null;
574 if (m_Appearances.TryGetValue(principalID, out a))
575 return a;
576
577 a = m_AvatarService.GetAppearance(principalID);
578 m_Appearances.AddOrUpdate(principalID, a, 5 * 60); // 5minutes
579 return a;
580 }
581
582 private bool IsPartOfAppearance(UUID principalID, UUID itemID)
583 {
584 AvatarAppearance a = GetAppearance(principalID);
585
586 if (a == null)
587 return false;
588
589 // Check wearables (body parts and clothes)
590 for (int i = 0; i < a.Wearables.Length; i++)
591 {
592 for (int j = 0; j < a.Wearables[i].Count; j++)
593 {
594 if (a.Wearables[i][j].ItemID == itemID)
595 {
596 //m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: item {0} is a wearable", itemID);
597 return true;
598 }
599 }
600 }
601
602 // Check attachments
603 if (a.GetAttachmentForItem(itemID) != null)
604 {
605 //m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: item {0} is an attachment", itemID);
606 return true;
607 }
608
609 return false;
610 }
611
612 #endregion
613
552 } 614 }
553 615
554} 616}
diff --git a/OpenSim/Services/HypergridService/Properties/AssemblyInfo.cs b/OpenSim/Services/HypergridService/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..49f2176
--- /dev/null
+++ b/OpenSim/Services/HypergridService/Properties/AssemblyInfo.cs
@@ -0,0 +1,33 @@
1using System.Reflection;
2using System.Runtime.CompilerServices;
3using System.Runtime.InteropServices;
4
5// General Information about an assembly is controlled through the following
6// set of attributes. Change these attribute values to modify the information
7// associated with an assembly.
8[assembly: AssemblyTitle("OpenSim.Services.HypergridService")]
9[assembly: AssemblyDescription("")]
10[assembly: AssemblyConfiguration("")]
11[assembly: AssemblyCompany("http://opensimulator.org")]
12[assembly: AssemblyProduct("OpenSim")]
13[assembly: AssemblyCopyright("OpenSimulator developers")]
14[assembly: AssemblyTrademark("")]
15[assembly: AssemblyCulture("")]
16
17// Setting ComVisible to false makes the types in this assembly not visible
18// to COM components. If you need to access a type in this assembly from
19// COM, set the ComVisible attribute to true on that type.
20[assembly: ComVisible(false)]
21
22// The following GUID is for the ID of the typelib if this project is exposed to COM
23[assembly: Guid("8584f3c1-26dd-4d95-86f4-cd8f0110a18f")]
24
25// Version information for an assembly consists of the following four values:
26//
27// Major Version
28// Minor Version
29// Build Number
30// Revision
31//
32[assembly: AssemblyVersion("0.7.5.*")]
33[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/OpenSim/Services/HypergridService/UserAgentService.cs b/OpenSim/Services/HypergridService/UserAgentService.cs
index a49993c..416ad16 100644
--- a/OpenSim/Services/HypergridService/UserAgentService.cs
+++ b/OpenSim/Services/HypergridService/UserAgentService.cs
@@ -77,6 +77,10 @@ namespace OpenSim.Services.HypergridService
77 77
78 protected static bool m_BypassClientVerification; 78 protected static bool m_BypassClientVerification;
79 79
80 private static Dictionary<int, bool> m_ForeignTripsAllowed = new Dictionary<int, bool>();
81 private static Dictionary<int, List<string>> m_TripsAllowedExceptions = new Dictionary<int, List<string>>();
82 private static Dictionary<int, List<string>> m_TripsDisallowedExceptions = new Dictionary<int, List<string>>();
83
80 public UserAgentService(IConfigSource config) : this(config, null) 84 public UserAgentService(IConfigSource config) : this(config, null)
81 { 85 {
82 } 86 }
@@ -121,6 +125,12 @@ namespace OpenSim.Services.HypergridService
121 m_PresenceService = ServerUtils.LoadPlugin<IPresenceService>(presenceService, args); 125 m_PresenceService = ServerUtils.LoadPlugin<IPresenceService>(presenceService, args);
122 m_UserAccountService = ServerUtils.LoadPlugin<IUserAccountService>(userAccountService, args); 126 m_UserAccountService = ServerUtils.LoadPlugin<IUserAccountService>(userAccountService, args);
123 127
128 m_LevelOutsideContacts = serverConfig.GetInt("LevelOutsideContacts", 0);
129
130 LoadTripPermissionsFromConfig(serverConfig, "ForeignTripsAllowed");
131 LoadDomainExceptionsFromConfig(serverConfig, "AllowExcept", m_TripsAllowedExceptions);
132 LoadDomainExceptionsFromConfig(serverConfig, "DisallowExcept", m_TripsDisallowedExceptions);
133
124 m_GridName = serverConfig.GetString("ExternalName", string.Empty); 134 m_GridName = serverConfig.GetString("ExternalName", string.Empty);
125 if (m_GridName == string.Empty) 135 if (m_GridName == string.Empty)
126 { 136 {
@@ -130,10 +140,43 @@ namespace OpenSim.Services.HypergridService
130 if (!m_GridName.EndsWith("/")) 140 if (!m_GridName.EndsWith("/"))
131 m_GridName = m_GridName + "/"; 141 m_GridName = m_GridName + "/";
132 142
133 m_LevelOutsideContacts = serverConfig.GetInt("LevelOutsideContacts", 0);
134 } 143 }
135 } 144 }
136 145
146 protected void LoadTripPermissionsFromConfig(IConfig config, string variable)
147 {
148 foreach (string keyName in config.GetKeys())
149 {
150 if (keyName.StartsWith(variable + "_Level_"))
151 {
152 int level = 0;
153 if (Int32.TryParse(keyName.Replace(variable + "_Level_", ""), out level))
154 m_ForeignTripsAllowed.Add(level, config.GetBoolean(keyName, true));
155 }
156 }
157 }
158
159 protected void LoadDomainExceptionsFromConfig(IConfig config, string variable, Dictionary<int, List<string>> exceptions)
160 {
161 foreach (string keyName in config.GetKeys())
162 {
163 if (keyName.StartsWith(variable + "_Level_"))
164 {
165 int level = 0;
166 if (Int32.TryParse(keyName.Replace(variable + "_Level_", ""), out level) && !exceptions.ContainsKey(level))
167 {
168 exceptions.Add(level, new List<string>());
169 string value = config.GetString(keyName, string.Empty);
170 string[] parts = value.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
171
172 foreach (string s in parts)
173 exceptions[level].Add(s.Trim());
174 }
175 }
176 }
177 }
178
179
137 public GridRegion GetHomeRegion(UUID userID, out Vector3 position, out Vector3 lookAt) 180 public GridRegion GetHomeRegion(UUID userID, out Vector3 position, out Vector3 lookAt)
138 { 181 {
139 position = new Vector3(128, 128, 0); lookAt = Vector3.UnitY; 182 position = new Vector3(128, 128, 0); lookAt = Vector3.UnitY;
@@ -166,13 +209,39 @@ namespace OpenSim.Services.HypergridService
166 m_log.DebugFormat("[USER AGENT SERVICE]: Request to login user {0} {1} (@{2}) to grid {3}", 209 m_log.DebugFormat("[USER AGENT SERVICE]: Request to login user {0} {1} (@{2}) to grid {3}",
167 agentCircuit.firstname, agentCircuit.lastname, ((clientIP == null) ? "stored IP" : clientIP.Address.ToString()), gatekeeper.ServerURI); 210 agentCircuit.firstname, agentCircuit.lastname, ((clientIP == null) ? "stored IP" : clientIP.Address.ToString()), gatekeeper.ServerURI);
168 211
169 if (m_UserAccountService.GetUserAccount(UUID.Zero, agentCircuit.AgentID) == null) 212 string gridName = gatekeeper.ServerURI;
213
214 UserAccount account = m_UserAccountService.GetUserAccount(UUID.Zero, agentCircuit.AgentID);
215 if (account == null)
170 { 216 {
171 m_log.WarnFormat("[USER AGENT SERVICE]: Someone attempted to lauch a foreign user from here {0} {1}", agentCircuit.firstname, agentCircuit.lastname); 217 m_log.WarnFormat("[USER AGENT SERVICE]: Someone attempted to lauch a foreign user from here {0} {1}", agentCircuit.firstname, agentCircuit.lastname);
172 reason = "Forbidden to launch your agents from here"; 218 reason = "Forbidden to launch your agents from here";
173 return false; 219 return false;
174 } 220 }
175 221
222 // Is this user allowed to go there?
223 if (m_GridName != gridName)
224 {
225 if (m_ForeignTripsAllowed.ContainsKey(account.UserLevel))
226 {
227 bool allowed = m_ForeignTripsAllowed[account.UserLevel];
228
229 if (m_ForeignTripsAllowed[account.UserLevel] && IsException(gridName, account.UserLevel, m_TripsAllowedExceptions))
230 allowed = false;
231
232 if (!m_ForeignTripsAllowed[account.UserLevel] && IsException(gridName, account.UserLevel, m_TripsDisallowedExceptions))
233 allowed = true;
234
235 if (!allowed)
236 {
237 reason = "Your world does not allow you to visit the destination";
238 m_log.InfoFormat("[USER AGENT SERVICE]: Agents not permitted to visit {0}. Refusing service.", gridName);
239 return false;
240 }
241 }
242 }
243
244
176 // Take the IP address + port of the gatekeeper (reg) plus the info of finalDestination 245 // Take the IP address + port of the gatekeeper (reg) plus the info of finalDestination
177 GridRegion region = new GridRegion(gatekeeper); 246 GridRegion region = new GridRegion(gatekeeper);
178 region.ServerURI = gatekeeper.ServerURI; 247 region.ServerURI = gatekeeper.ServerURI;
@@ -189,7 +258,6 @@ namespace OpenSim.Services.HypergridService
189 258
190 bool success = false; 259 bool success = false;
191 string myExternalIP = string.Empty; 260 string myExternalIP = string.Empty;
192 string gridName = gatekeeper.ServerURI;
193 261
194 m_log.DebugFormat("[USER AGENT SERVICE]: this grid: {0}, desired grid: {1}", m_GridName, gridName); 262 m_log.DebugFormat("[USER AGENT SERVICE]: this grid: {0}, desired grid: {1}", m_GridName, gridName);
195 263
@@ -434,7 +502,7 @@ namespace OpenSim.Services.HypergridService
434 if (region != null) 502 if (region != null)
435 { 503 {
436 m_log.DebugFormat("[USER AGENT SERVICE]: Remote Notify to region {0}, user {1} is {2}", region.RegionName, foreignUserID, (online ? "online" : "offline")); 504 m_log.DebugFormat("[USER AGENT SERVICE]: Remote Notify to region {0}, user {1} is {2}", region.RegionName, foreignUserID, (online ? "online" : "offline"));
437 m_FriendsSimConnector.StatusNotify(region, foreignUserID, userID, online); 505 m_FriendsSimConnector.StatusNotify(region, foreignUserID, userID.ToString(), online);
438 } 506 }
439 } 507 }
440 } 508 }
@@ -586,6 +654,35 @@ namespace OpenSim.Services.HypergridService
586 else 654 else
587 return UUID.Zero; 655 return UUID.Zero;
588 } 656 }
657
658 #region Misc
659
660 private bool IsException(string dest, int level, Dictionary<int, List<string>> exceptions)
661 {
662 if (!exceptions.ContainsKey(level))
663 return false;
664
665 bool exception = false;
666 if (exceptions[level].Count > 0) // we have exceptions
667 {
668 string destination = dest;
669 if (!destination.EndsWith("/"))
670 destination += "/";
671
672 if (exceptions[level].Find(delegate(string s)
673 {
674 if (!s.EndsWith("/"))
675 s += "/";
676 return s == destination;
677 }) != null)
678 exception = true;
679 }
680
681 return exception;
682 }
683
684 #endregion
685
589 } 686 }
590 687
591 class TravelingAgentInfo 688 class TravelingAgentInfo