diff options
Diffstat (limited to 'OpenSim/Services/HypergridService/UserAgentService.cs')
-rw-r--r-- | OpenSim/Services/HypergridService/UserAgentService.cs | 105 |
1 files changed, 4 insertions, 101 deletions
diff --git a/OpenSim/Services/HypergridService/UserAgentService.cs b/OpenSim/Services/HypergridService/UserAgentService.cs index 416ad16..a49993c 100644 --- a/OpenSim/Services/HypergridService/UserAgentService.cs +++ b/OpenSim/Services/HypergridService/UserAgentService.cs | |||
@@ -77,10 +77,6 @@ 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 | |||
84 | public UserAgentService(IConfigSource config) : this(config, null) | 80 | public UserAgentService(IConfigSource config) : this(config, null) |
85 | { | 81 | { |
86 | } | 82 | } |
@@ -125,12 +121,6 @@ namespace OpenSim.Services.HypergridService | |||
125 | m_PresenceService = ServerUtils.LoadPlugin<IPresenceService>(presenceService, args); | 121 | m_PresenceService = ServerUtils.LoadPlugin<IPresenceService>(presenceService, args); |
126 | m_UserAccountService = ServerUtils.LoadPlugin<IUserAccountService>(userAccountService, args); | 122 | m_UserAccountService = ServerUtils.LoadPlugin<IUserAccountService>(userAccountService, args); |
127 | 123 | ||
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 | |||
134 | m_GridName = serverConfig.GetString("ExternalName", string.Empty); | 124 | m_GridName = serverConfig.GetString("ExternalName", string.Empty); |
135 | if (m_GridName == string.Empty) | 125 | if (m_GridName == string.Empty) |
136 | { | 126 | { |
@@ -140,43 +130,10 @@ namespace OpenSim.Services.HypergridService | |||
140 | if (!m_GridName.EndsWith("/")) | 130 | if (!m_GridName.EndsWith("/")) |
141 | m_GridName = m_GridName + "/"; | 131 | m_GridName = m_GridName + "/"; |
142 | 132 | ||
133 | m_LevelOutsideContacts = serverConfig.GetInt("LevelOutsideContacts", 0); | ||
143 | } | 134 | } |
144 | } | 135 | } |
145 | 136 | ||
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 | |||
180 | public GridRegion GetHomeRegion(UUID userID, out Vector3 position, out Vector3 lookAt) | 137 | public GridRegion GetHomeRegion(UUID userID, out Vector3 position, out Vector3 lookAt) |
181 | { | 138 | { |
182 | position = new Vector3(128, 128, 0); lookAt = Vector3.UnitY; | 139 | position = new Vector3(128, 128, 0); lookAt = Vector3.UnitY; |
@@ -209,39 +166,13 @@ namespace OpenSim.Services.HypergridService | |||
209 | m_log.DebugFormat("[USER AGENT SERVICE]: Request to login user {0} {1} (@{2}) to grid {3}", | 166 | m_log.DebugFormat("[USER AGENT SERVICE]: Request to login user {0} {1} (@{2}) to grid {3}", |
210 | agentCircuit.firstname, agentCircuit.lastname, ((clientIP == null) ? "stored IP" : clientIP.Address.ToString()), gatekeeper.ServerURI); | 167 | agentCircuit.firstname, agentCircuit.lastname, ((clientIP == null) ? "stored IP" : clientIP.Address.ToString()), gatekeeper.ServerURI); |
211 | 168 | ||
212 | string gridName = gatekeeper.ServerURI; | 169 | if (m_UserAccountService.GetUserAccount(UUID.Zero, agentCircuit.AgentID) == null) |
213 | |||
214 | UserAccount account = m_UserAccountService.GetUserAccount(UUID.Zero, agentCircuit.AgentID); | ||
215 | if (account == null) | ||
216 | { | 170 | { |
217 | m_log.WarnFormat("[USER AGENT SERVICE]: Someone attempted to lauch a foreign user from here {0} {1}", agentCircuit.firstname, agentCircuit.lastname); | 171 | m_log.WarnFormat("[USER AGENT SERVICE]: Someone attempted to lauch a foreign user from here {0} {1}", agentCircuit.firstname, agentCircuit.lastname); |
218 | reason = "Forbidden to launch your agents from here"; | 172 | reason = "Forbidden to launch your agents from here"; |
219 | return false; | 173 | return false; |
220 | } | 174 | } |
221 | 175 | ||
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 | |||
245 | // Take the IP address + port of the gatekeeper (reg) plus the info of finalDestination | 176 | // Take the IP address + port of the gatekeeper (reg) plus the info of finalDestination |
246 | GridRegion region = new GridRegion(gatekeeper); | 177 | GridRegion region = new GridRegion(gatekeeper); |
247 | region.ServerURI = gatekeeper.ServerURI; | 178 | region.ServerURI = gatekeeper.ServerURI; |
@@ -258,6 +189,7 @@ namespace OpenSim.Services.HypergridService | |||
258 | 189 | ||
259 | bool success = false; | 190 | bool success = false; |
260 | string myExternalIP = string.Empty; | 191 | string myExternalIP = string.Empty; |
192 | string gridName = gatekeeper.ServerURI; | ||
261 | 193 | ||
262 | m_log.DebugFormat("[USER AGENT SERVICE]: this grid: {0}, desired grid: {1}", m_GridName, gridName); | 194 | m_log.DebugFormat("[USER AGENT SERVICE]: this grid: {0}, desired grid: {1}", m_GridName, gridName); |
263 | 195 | ||
@@ -502,7 +434,7 @@ namespace OpenSim.Services.HypergridService | |||
502 | if (region != null) | 434 | if (region != null) |
503 | { | 435 | { |
504 | m_log.DebugFormat("[USER AGENT SERVICE]: Remote Notify to region {0}, user {1} is {2}", region.RegionName, foreignUserID, (online ? "online" : "offline")); | 436 | m_log.DebugFormat("[USER AGENT SERVICE]: Remote Notify to region {0}, user {1} is {2}", region.RegionName, foreignUserID, (online ? "online" : "offline")); |
505 | m_FriendsSimConnector.StatusNotify(region, foreignUserID, userID.ToString(), online); | 437 | m_FriendsSimConnector.StatusNotify(region, foreignUserID, userID, online); |
506 | } | 438 | } |
507 | } | 439 | } |
508 | } | 440 | } |
@@ -654,35 +586,6 @@ namespace OpenSim.Services.HypergridService | |||
654 | else | 586 | else |
655 | return UUID.Zero; | 587 | return UUID.Zero; |
656 | } | 588 | } |
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 | |||
686 | } | 589 | } |
687 | 590 | ||
688 | class TravelingAgentInfo | 591 | class TravelingAgentInfo |