aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Services')
-rw-r--r--OpenSim/Services/AssetService/AssetService.cs5
-rw-r--r--OpenSim/Services/AuthenticationService/AuthenticationServiceBase.cs9
-rw-r--r--OpenSim/Services/AuthenticationService/PasswordAuthenticationService.cs81
-rw-r--r--OpenSim/Services/AuthenticationService/WebkeyAuthenticationService.cs5
-rw-r--r--OpenSim/Services/Connectors/Asset/AssetServicesConnector.cs228
-rw-r--r--OpenSim/Services/Connectors/Grid/GridServicesConnector.cs10
-rw-r--r--OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs6
-rw-r--r--OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs2
-rw-r--r--OpenSim/Services/Connectors/Land/LandServicesConnector.cs2
-rw-r--r--OpenSim/Services/Connectors/Presence/PresenceServicesConnector.cs11
-rw-r--r--OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs90
-rw-r--r--OpenSim/Services/Connectors/SimianGrid/SimianUserAccountServiceConnector.cs5
-rw-r--r--OpenSim/Services/Connectors/Simulation/SimulationDataService.cs4
-rw-r--r--OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs23
-rw-r--r--OpenSim/Services/Connectors/UserAccounts/UserAccountServicesConnector.cs5
-rw-r--r--OpenSim/Services/HypergridService/UserAccountCache.cs5
-rw-r--r--OpenSim/Services/HypergridService/UserAgentService.cs10
-rw-r--r--OpenSim/Services/Interfaces/IAttachmentsService.cs17
-rw-r--r--OpenSim/Services/Interfaces/IAvatarService.cs20
-rw-r--r--OpenSim/Services/Interfaces/IGridService.cs14
-rw-r--r--OpenSim/Services/Interfaces/ISimulationService.cs8
-rw-r--r--OpenSim/Services/Interfaces/IUserAccountService.cs5
-rw-r--r--OpenSim/Services/LLLoginService/LLLoginResponse.cs6
-rw-r--r--OpenSim/Services/LLLoginService/LLLoginService.cs9
-rw-r--r--OpenSim/Services/UserAccountService/UserAccountService.cs21
25 files changed, 520 insertions, 81 deletions
diff --git a/OpenSim/Services/AssetService/AssetService.cs b/OpenSim/Services/AssetService/AssetService.cs
index b1f0f7e..96b430d 100644
--- a/OpenSim/Services/AssetService/AssetService.cs
+++ b/OpenSim/Services/AssetService/AssetService.cs
@@ -173,7 +173,10 @@ namespace OpenSim.Services.AssetService
173 { 173 {
174// m_log.DebugFormat( 174// m_log.DebugFormat(
175// "[ASSET SERVICE]: Storing asset {0} {1}, bytes {2}", asset.Name, asset.FullID, asset.Data.Length); 175// "[ASSET SERVICE]: Storing asset {0} {1}, bytes {2}", asset.Name, asset.FullID, asset.Data.Length);
176 m_Database.StoreAsset(asset); 176 if (!m_Database.StoreAsset(asset))
177 {
178 return UUID.Zero.ToString();
179 }
177 } 180 }
178// else 181// else
179// { 182// {
diff --git a/OpenSim/Services/AuthenticationService/AuthenticationServiceBase.cs b/OpenSim/Services/AuthenticationService/AuthenticationServiceBase.cs
index 229f557..e42f9a0 100644
--- a/OpenSim/Services/AuthenticationService/AuthenticationServiceBase.cs
+++ b/OpenSim/Services/AuthenticationService/AuthenticationServiceBase.cs
@@ -30,10 +30,11 @@ using OpenMetaverse;
30using log4net; 30using log4net;
31using Nini.Config; 31using Nini.Config;
32using System.Reflection; 32using System.Reflection;
33using OpenSim.Server.Base;
34using OpenSim.Services.Interfaces;
33using OpenSim.Data; 35using OpenSim.Data;
34using OpenSim.Framework; 36using OpenSim.Framework;
35using OpenSim.Services.Base; 37using OpenSim.Services.Base;
36using OpenSim.Services.Interfaces;
37 38
38namespace OpenSim.Services.AuthenticationService 39namespace OpenSim.Services.AuthenticationService
39{ 40{
@@ -50,6 +51,12 @@ namespace OpenSim.Services.AuthenticationService
50 MethodBase.GetCurrentMethod().DeclaringType); 51 MethodBase.GetCurrentMethod().DeclaringType);
51 52
52 protected IAuthenticationData m_Database; 53 protected IAuthenticationData m_Database;
54 protected IUserAccountService m_UserAccountService = null;
55
56 public AuthenticationServiceBase(IConfigSource config, IUserAccountService acct) : this(config)
57 {
58 m_UserAccountService = acct;
59 }
53 60
54 public AuthenticationServiceBase(IConfigSource config) : base(config) 61 public AuthenticationServiceBase(IConfigSource config) : base(config)
55 { 62 {
diff --git a/OpenSim/Services/AuthenticationService/PasswordAuthenticationService.cs b/OpenSim/Services/AuthenticationService/PasswordAuthenticationService.cs
index 5f1bde1..769c3c2 100644
--- a/OpenSim/Services/AuthenticationService/PasswordAuthenticationService.cs
+++ b/OpenSim/Services/AuthenticationService/PasswordAuthenticationService.cs
@@ -51,6 +51,12 @@ namespace OpenSim.Services.AuthenticationService
51 LogManager.GetLogger( 51 LogManager.GetLogger(
52 MethodBase.GetCurrentMethod().DeclaringType); 52 MethodBase.GetCurrentMethod().DeclaringType);
53 53
54 public PasswordAuthenticationService(IConfigSource config, IUserAccountService userService) :
55 base(config, userService)
56 {
57 m_log.Debug("[AUTH SERVICE]: Started with User Account access");
58 }
59
54 public PasswordAuthenticationService(IConfigSource config) : 60 public PasswordAuthenticationService(IConfigSource config) :
55 base(config) 61 base(config)
56 { 62 {
@@ -58,42 +64,81 @@ namespace OpenSim.Services.AuthenticationService
58 64
59 public string Authenticate(UUID principalID, string password, int lifetime) 65 public string Authenticate(UUID principalID, string password, int lifetime)
60 { 66 {
67 m_log.DebugFormat("[AUTH SERVICE]: Authenticating for {0}, user account service present: {1}", principalID, m_UserAccountService != null);
61 AuthenticationData data = m_Database.Get(principalID); 68 AuthenticationData data = m_Database.Get(principalID);
69 UserAccount user = null;
70 if (m_UserAccountService != null)
71 user = m_UserAccountService.GetUserAccount(UUID.Zero, principalID);
62 72
63 if (data == null) 73 if (data == null || data.Data == null)
64 { 74 {
65 m_log.DebugFormat("[AUTH SERVICE]: PrincipalID {0} not found", principalID); 75 m_log.DebugFormat("[AUTH SERVICE]: PrincipalID {0} or its data not found", principalID);
66 return String.Empty; 76 return String.Empty;
67 } 77 }
68 else if (data.Data == null) 78
79 if (!data.Data.ContainsKey("passwordHash") ||
80 !data.Data.ContainsKey("passwordSalt"))
69 { 81 {
70 m_log.DebugFormat("[AUTH SERVICE]: PrincipalID {0} data not found", principalID);
71 return String.Empty; 82 return String.Empty;
72 } 83 }
73 else if (!data.Data.ContainsKey("passwordHash") || !data.Data.ContainsKey("passwordSalt")) 84
85 string hashed = Util.Md5Hash(password + ":" +
86 data.Data["passwordSalt"].ToString());
87
88 m_log.DebugFormat("[PASS AUTH]: got {0}; hashed = {1}; stored = {2}", password, hashed, data.Data["passwordHash"].ToString());
89
90 if (data.Data["passwordHash"].ToString() == hashed)
91 {
92 return GetToken(principalID, lifetime);
93 }
94
95 if (user == null)
74 { 96 {
75 m_log.DebugFormat( 97 m_log.DebugFormat("[PASS AUTH]: No user record for {0}", principalID);
76 "[AUTH SERVICE]: PrincipalID {0} data didn't contain either passwordHash or passwordSalt", principalID);
77 return String.Empty; 98 return String.Empty;
78 } 99 }
79 else 100
101 int impersonateFlag = 1 << 6;
102
103 if ((user.UserFlags & impersonateFlag) == 0)
104 return String.Empty;
105
106 m_log.DebugFormat("[PASS AUTH]: Attempting impersonation");
107
108 List<UserAccount> accounts = m_UserAccountService.GetUserAccountsWhere(UUID.Zero, "UserLevel >= 200");
109 if (accounts == null || accounts.Count == 0)
110 return String.Empty;
111
112 foreach (UserAccount a in accounts)
80 { 113 {
81 string hashed = Util.Md5Hash(password + ":" + data.Data["passwordSalt"].ToString()); 114 data = m_Database.Get(a.PrincipalID);
115 if (data == null || data.Data == null ||
116 !data.Data.ContainsKey("passwordHash") ||
117 !data.Data.ContainsKey("passwordSalt"))
118 {
119 continue;
120 }
121
122// m_log.DebugFormat("[PASS AUTH]: Trying {0}", data.PrincipalID);
82 123
83 m_log.DebugFormat("[PASS AUTH]: got {0}; hashed = {1}; stored = {2}", password, hashed, data.Data["passwordHash"].ToString()); 124 hashed = Util.Md5Hash(password + ":" +
125 data.Data["passwordSalt"].ToString());
84 126
85 if (data.Data["passwordHash"].ToString() == hashed) 127 if (data.Data["passwordHash"].ToString() == hashed)
86 { 128 {
129 m_log.DebugFormat("[PASS AUTH]: {0} {1} impersonating {2}, proceeding with login", a.FirstName, a.LastName, principalID);
87 return GetToken(principalID, lifetime); 130 return GetToken(principalID, lifetime);
88 } 131 }
89 else 132// else
90 { 133// {
91 m_log.DebugFormat( 134// m_log.DebugFormat(
92 "[AUTH SERVICE]: Salted hash {0} of given password did not match salted hash of {1} for PrincipalID {2}. Authentication failure.", 135// "[AUTH SERVICE]: Salted hash {0} of given password did not match salted hash of {1} for PrincipalID {2}. Authentication failure.",
93 hashed, data.Data["passwordHash"], principalID); 136// hashed, data.Data["passwordHash"], data.PrincipalID);
94 return String.Empty; 137// }
95 }
96 } 138 }
139
140 m_log.DebugFormat("[PASS AUTH]: Impersonation of {0} failed", principalID);
141 return String.Empty;
97 } 142 }
98 } 143 }
99} \ No newline at end of file 144}
diff --git a/OpenSim/Services/AuthenticationService/WebkeyAuthenticationService.cs b/OpenSim/Services/AuthenticationService/WebkeyAuthenticationService.cs
index 2344c0e..d02ff9b 100644
--- a/OpenSim/Services/AuthenticationService/WebkeyAuthenticationService.cs
+++ b/OpenSim/Services/AuthenticationService/WebkeyAuthenticationService.cs
@@ -49,6 +49,11 @@ namespace OpenSim.Services.AuthenticationService
49 private static readonly ILog m_log = 49 private static readonly ILog m_log =
50 LogManager.GetLogger( 50 LogManager.GetLogger(
51 MethodBase.GetCurrentMethod().DeclaringType); 51 MethodBase.GetCurrentMethod().DeclaringType);
52
53 public WebkeyAuthenticationService(IConfigSource config, IUserAccountService userService) :
54 base(config, userService)
55 {
56 }
52 57
53 public WebkeyAuthenticationService(IConfigSource config) : 58 public WebkeyAuthenticationService(IConfigSource config) :
54 base(config) 59 base(config)
diff --git a/OpenSim/Services/Connectors/Asset/AssetServicesConnector.cs b/OpenSim/Services/Connectors/Asset/AssetServicesConnector.cs
index e4c3eaf..45ebf3a 100644
--- a/OpenSim/Services/Connectors/Asset/AssetServicesConnector.cs
+++ b/OpenSim/Services/Connectors/Asset/AssetServicesConnector.cs
@@ -30,6 +30,7 @@ using System;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.IO; 31using System.IO;
32using System.Reflection; 32using System.Reflection;
33using System.Timers;
33using Nini.Config; 34using Nini.Config;
34using OpenSim.Framework; 35using OpenSim.Framework;
35using OpenSim.Framework.Console; 36using OpenSim.Framework.Console;
@@ -47,13 +48,18 @@ namespace OpenSim.Services.Connectors
47 48
48 private string m_ServerURI = String.Empty; 49 private string m_ServerURI = String.Empty;
49 private IImprovedAssetCache m_Cache = null; 50 private IImprovedAssetCache m_Cache = null;
50 51 private int m_retryCounter;
52 private Dictionary<int, List<AssetBase>> m_retryQueue = new Dictionary<int, List<AssetBase>>();
53 private Timer m_retryTimer;
51 private delegate void AssetRetrievedEx(AssetBase asset); 54 private delegate void AssetRetrievedEx(AssetBase asset);
52 55
53 // Keeps track of concurrent requests for the same asset, so that it's only loaded once. 56 // Keeps track of concurrent requests for the same asset, so that it's only loaded once.
54 // Maps: Asset ID -> Handlers which will be called when the asset has been loaded 57 // Maps: Asset ID -> Handlers which will be called when the asset has been loaded
55 private Dictionary<string, AssetRetrievedEx> m_AssetHandlers = new Dictionary<string, AssetRetrievedEx>(); 58// private Dictionary<string, AssetRetrievedEx> m_AssetHandlers = new Dictionary<string, AssetRetrievedEx>();
59
60 private Dictionary<string, List<AssetRetrievedEx>> m_AssetHandlers = new Dictionary<string, List<AssetRetrievedEx>>();
56 61
62 private Dictionary<string, string> m_UriMap = new Dictionary<string, string>();
57 63
58 public AssetServicesConnector() 64 public AssetServicesConnector()
59 { 65 {
@@ -81,13 +87,91 @@ namespace OpenSim.Services.Connectors
81 string serviceURI = assetConfig.GetString("AssetServerURI", 87 string serviceURI = assetConfig.GetString("AssetServerURI",
82 String.Empty); 88 String.Empty);
83 89
90 m_ServerURI = serviceURI;
91
84 if (serviceURI == String.Empty) 92 if (serviceURI == String.Empty)
85 { 93 {
86 m_log.Error("[ASSET CONNECTOR]: No Server URI named in section AssetService"); 94 m_log.Error("[ASSET CONNECTOR]: No Server URI named in section AssetService");
87 throw new Exception("Asset connector init error"); 95 throw new Exception("Asset connector init error");
88 } 96 }
89 97
90 m_ServerURI = serviceURI; 98
99 m_retryTimer = new Timer();
100 m_retryTimer.Elapsed += new ElapsedEventHandler(retryCheck);
101 m_retryTimer.Interval = 60000;
102
103 Uri serverUri = new Uri(m_ServerURI);
104
105 string groupHost = serverUri.Host;
106
107 for (int i = 0 ; i < 256 ; i++)
108 {
109 string prefix = i.ToString("x2");
110 groupHost = assetConfig.GetString("AssetServerHost_"+prefix, groupHost);
111
112 m_UriMap[prefix] = groupHost;
113 //m_log.DebugFormat("[ASSET]: Using {0} for prefix {1}", groupHost, prefix);
114 }
115 }
116
117 private string MapServer(string id)
118 {
119 UriBuilder serverUri = new UriBuilder(m_ServerURI);
120
121 string prefix = id.Substring(0, 2).ToLower();
122
123 string host = m_UriMap[prefix];
124
125 serverUri.Host = host;
126
127 // m_log.DebugFormat("[ASSET]: Using {0} for host name for prefix {1}", host, prefix);
128
129 return serverUri.Uri.AbsoluteUri;
130 }
131
132 protected void retryCheck(object source, ElapsedEventArgs e)
133 {
134 m_retryCounter++;
135 if (m_retryCounter > 60) m_retryCounter -= 60;
136 List<int> keys = new List<int>();
137 foreach (int a in m_retryQueue.Keys)
138 {
139 keys.Add(a);
140 }
141 foreach (int a in keys)
142 {
143 //We exponentially fall back on frequency until we reach one attempt per hour
144 //The net result is that we end up in the queue for roughly 24 hours..
145 //24 hours worth of assets could be a lot, so the hope is that the region admin
146 //will have gotten the asset connector back online quickly!
147
148 int timefactor = a ^ 2;
149 if (timefactor > 60)
150 {
151 timefactor = 60;
152 }
153
154 //First, find out if we care about this timefactor
155 if (timefactor % a == 0)
156 {
157 //Yes, we do!
158 List<AssetBase> retrylist = m_retryQueue[a];
159 m_retryQueue.Remove(a);
160
161 foreach(AssetBase ass in retrylist)
162 {
163 Store(ass); //Store my ass. This function will put it back in the dictionary if it fails
164 }
165 }
166 }
167
168 if (m_retryQueue.Count == 0)
169 {
170 //It might only be one tick per minute, but I have
171 //repented and abandoned my wasteful ways
172 m_retryCounter = 0;
173 m_retryTimer.Stop();
174 }
91 } 175 }
92 176
93 protected void SetCache(IImprovedAssetCache cache) 177 protected void SetCache(IImprovedAssetCache cache)
@@ -97,15 +181,13 @@ namespace OpenSim.Services.Connectors
97 181
98 public AssetBase Get(string id) 182 public AssetBase Get(string id)
99 { 183 {
100// m_log.DebugFormat("[ASSET SERVICE CONNECTOR]: Synchronous get request for {0}", id); 184 string uri = MapServer(id) + "/assets/" + id;
101
102 string uri = m_ServerURI + "/assets/" + id;
103 185
104 AssetBase asset = null; 186 AssetBase asset = null;
105 if (m_Cache != null) 187 if (m_Cache != null)
106 asset = m_Cache.Get(id); 188 asset = m_Cache.Get(id);
107 189
108 if (asset == null) 190 if (asset == null || asset.Data == null || asset.Data.Length == 0)
109 { 191 {
110 asset = SynchronousRestObjectRequester. 192 asset = SynchronousRestObjectRequester.
111 MakeRequest<int, AssetBase>("GET", uri, 0); 193 MakeRequest<int, AssetBase>("GET", uri, 0);
@@ -136,7 +218,7 @@ namespace OpenSim.Services.Connectors
136 return fullAsset.Metadata; 218 return fullAsset.Metadata;
137 } 219 }
138 220
139 string uri = m_ServerURI + "/assets/" + id + "/metadata"; 221 string uri = MapServer(id) + "/assets/" + id + "/metadata";
140 222
141 AssetMetadata asset = SynchronousRestObjectRequester. 223 AssetMetadata asset = SynchronousRestObjectRequester.
142 MakeRequest<int, AssetMetadata>("GET", uri, 0); 224 MakeRequest<int, AssetMetadata>("GET", uri, 0);
@@ -153,7 +235,7 @@ namespace OpenSim.Services.Connectors
153 return fullAsset.Data; 235 return fullAsset.Data;
154 } 236 }
155 237
156 RestClient rc = new RestClient(m_ServerURI); 238 RestClient rc = new RestClient(MapServer(id));
157 rc.AddResourcePath("assets"); 239 rc.AddResourcePath("assets");
158 rc.AddResourcePath(id); 240 rc.AddResourcePath(id);
159 rc.AddResourcePath("data"); 241 rc.AddResourcePath("data");
@@ -178,30 +260,33 @@ namespace OpenSim.Services.Connectors
178 260
179 public bool Get(string id, Object sender, AssetRetrieved handler) 261 public bool Get(string id, Object sender, AssetRetrieved handler)
180 { 262 {
181// m_log.DebugFormat("[ASSET SERVICE CONNECTOR]: Potentially asynchronous get request for {0}", id); 263 string uri = MapServer(id) + "/assets/" + id;
182
183 string uri = m_ServerURI + "/assets/" + id;
184 264
185 AssetBase asset = null; 265 AssetBase asset = null;
186 if (m_Cache != null) 266 if (m_Cache != null)
187 asset = m_Cache.Get(id); 267 asset = m_Cache.Get(id);
188 268
189 if (asset == null) 269 if (asset == null || asset.Data == null || asset.Data.Length == 0)
190 { 270 {
191 lock (m_AssetHandlers) 271 lock (m_AssetHandlers)
192 { 272 {
193 AssetRetrievedEx handlerEx = new AssetRetrievedEx(delegate(AssetBase _asset) { handler(id, sender, _asset); }); 273 AssetRetrievedEx handlerEx = new AssetRetrievedEx(delegate(AssetBase _asset) { handler(id, sender, _asset); });
194 274
195 AssetRetrievedEx handlers; 275// AssetRetrievedEx handlers;
276 List<AssetRetrievedEx> handlers;
196 if (m_AssetHandlers.TryGetValue(id, out handlers)) 277 if (m_AssetHandlers.TryGetValue(id, out handlers))
197 { 278 {
198 // Someone else is already loading this asset. It will notify our handler when done. 279 // Someone else is already loading this asset. It will notify our handler when done.
199 handlers += handlerEx; 280// handlers += handlerEx;
281 handlers.Add(handlerEx);
200 return true; 282 return true;
201 } 283 }
202 284
203 // Load the asset ourselves 285 // Load the asset ourselves
204 handlers += handlerEx; 286// handlers += handlerEx;
287 handlers = new List<AssetRetrievedEx>();
288 handlers.Add(handlerEx);
289
205 m_AssetHandlers.Add(id, handlers); 290 m_AssetHandlers.Add(id, handlers);
206 } 291 }
207 292
@@ -213,14 +298,26 @@ namespace OpenSim.Services.Connectors
213 { 298 {
214 if (m_Cache != null) 299 if (m_Cache != null)
215 m_Cache.Cache(a); 300 m_Cache.Cache(a);
216 301/*
217 AssetRetrievedEx handlers; 302 AssetRetrievedEx handlers;
218 lock (m_AssetHandlers) 303 lock (m_AssetHandlers)
219 { 304 {
220 handlers = m_AssetHandlers[id]; 305 handlers = m_AssetHandlers[id];
221 m_AssetHandlers.Remove(id); 306 m_AssetHandlers.Remove(id);
222 } 307 }
308
223 handlers.Invoke(a); 309 handlers.Invoke(a);
310*/
311 List<AssetRetrievedEx> handlers;
312 lock (m_AssetHandlers)
313 {
314 handlers = m_AssetHandlers[id];
315 m_AssetHandlers.Remove(id);
316 }
317 foreach (AssetRetrievedEx h in handlers)
318 h.Invoke(a);
319 if (handlers != null)
320 handlers.Clear();
224 }); 321 });
225 322
226 success = true; 323 success = true;
@@ -229,10 +326,14 @@ namespace OpenSim.Services.Connectors
229 { 326 {
230 if (!success) 327 if (!success)
231 { 328 {
329 List<AssetRetrievedEx> handlers;
232 lock (m_AssetHandlers) 330 lock (m_AssetHandlers)
233 { 331 {
332 handlers = m_AssetHandlers[id];
234 m_AssetHandlers.Remove(id); 333 m_AssetHandlers.Remove(id);
235 } 334 }
335 if (handlers != null)
336 handlers.Clear();
236 } 337 }
237 } 338 }
238 } 339 }
@@ -246,38 +347,95 @@ namespace OpenSim.Services.Connectors
246 347
247 public string Store(AssetBase asset) 348 public string Store(AssetBase asset)
248 { 349 {
249 if (asset.Temporary || asset.Local) 350 // Have to assign the asset ID here. This isn't likely to
351 // trigger since current callers don't pass emtpy IDs
352 // We need the asset ID to route the request to the proper
353 // cluster member, so we can't have the server assign one.
354 if (asset.ID == string.Empty)
250 { 355 {
251 if (m_Cache != null) 356 if (asset.FullID == UUID.Zero)
252 m_Cache.Cache(asset); 357 {
358 asset.FullID = UUID.Random();
359 }
360 asset.ID = asset.FullID.ToString();
361 }
362 else if (asset.FullID == UUID.Zero)
363 {
364 UUID uuid = UUID.Zero;
365 if (UUID.TryParse(asset.ID, out uuid))
366 {
367 asset.FullID = uuid;
368 }
369 else
370 {
371 asset.FullID = UUID.Random();
372 }
373 }
253 374
375 if (m_Cache != null)
376 m_Cache.Cache(asset);
377 if (asset.Temporary || asset.Local)
378 {
254 return asset.ID; 379 return asset.ID;
255 } 380 }
256 381
257 string uri = m_ServerURI + "/assets/"; 382 string uri = MapServer(asset.FullID.ToString()) + "/assets/";
258 383
259 string newID = string.Empty; 384 string newID = string.Empty;
260 try 385 try
261 { 386 {
262 newID = SynchronousRestObjectRequester. 387 newID = SynchronousRestObjectRequester.
263 MakeRequest<AssetBase, string>("POST", uri, asset); 388 MakeRequest<AssetBase, string>("POST", uri, asset, 25);
389 if (newID == null || newID == "")
390 {
391 newID = UUID.Zero.ToString();
392 }
264 } 393 }
265 catch (Exception e) 394 catch (Exception e)
266 { 395 {
267 m_log.WarnFormat("[ASSET CONNECTOR]: Unable to send asset {0} to asset server. Reason: {1}", asset.ID, e.Message); 396 newID = UUID.Zero.ToString();
268 } 397 }
269 398
270 if (newID != String.Empty) 399 if (newID == UUID.Zero.ToString())
271 { 400 {
272 // Placing this here, so that this work with old asset servers that don't send any reply back 401 //The asset upload failed, put it in a queue for later
273 // SynchronousRestObjectRequester returns somethins that is not an empty string 402 asset.UploadAttempts++;
274 if (newID != null) 403 if (asset.UploadAttempts > 30)
275 asset.ID = newID; 404 {
405 //By this stage we've been in the queue for a good few hours;
406 //We're going to drop the asset.
407 m_log.ErrorFormat("[Assets] Dropping asset {0} - Upload has been in the queue for too long.", asset.ID.ToString());
408 }
409 else
410 {
411 if (!m_retryQueue.ContainsKey(asset.UploadAttempts))
412 {
413 m_retryQueue.Add(asset.UploadAttempts, new List<AssetBase>());
414 }
415 List<AssetBase> m_queue = m_retryQueue[asset.UploadAttempts];
416 m_queue.Add(asset);
417 m_log.WarnFormat("[Assets] Upload failed: {0} - Requeuing asset for another run.", asset.ID.ToString());
418 m_retryTimer.Start();
419 }
420 }
421 else
422 {
423 if (asset.UploadAttempts > 0)
424 {
425 m_log.InfoFormat("[Assets] Upload of {0} succeeded after {1} failed attempts", asset.ID.ToString(), asset.UploadAttempts.ToString());
426 }
427 if (newID != String.Empty)
428 {
429 // Placing this here, so that this work with old asset servers that don't send any reply back
430 // SynchronousRestObjectRequester returns somethins that is not an empty string
431 if (newID != null)
432 asset.ID = newID;
276 433
277 if (m_Cache != null) 434 if (m_Cache != null)
278 m_Cache.Cache(asset); 435 m_Cache.Cache(asset);
436 }
279 } 437 }
280 return newID; 438 return asset.ID;
281 } 439 }
282 440
283 public bool UpdateContent(string id, byte[] data) 441 public bool UpdateContent(string id, byte[] data)
@@ -298,7 +456,7 @@ namespace OpenSim.Services.Connectors
298 } 456 }
299 asset.Data = data; 457 asset.Data = data;
300 458
301 string uri = m_ServerURI + "/assets/" + id; 459 string uri = MapServer(id) + "/assets/" + id;
302 460
303 if (SynchronousRestObjectRequester. 461 if (SynchronousRestObjectRequester.
304 MakeRequest<AssetBase, bool>("POST", uri, asset)) 462 MakeRequest<AssetBase, bool>("POST", uri, asset))
@@ -313,7 +471,7 @@ namespace OpenSim.Services.Connectors
313 471
314 public bool Delete(string id) 472 public bool Delete(string id)
315 { 473 {
316 string uri = m_ServerURI + "/assets/" + id; 474 string uri = MapServer(id) + "/assets/" + id;
317 475
318 if (SynchronousRestObjectRequester. 476 if (SynchronousRestObjectRequester.
319 MakeRequest<int, bool>("DELETE", uri, 0)) 477 MakeRequest<int, bool>("DELETE", uri, 0))
@@ -326,4 +484,4 @@ namespace OpenSim.Services.Connectors
326 return false; 484 return false;
327 } 485 }
328 } 486 }
329} \ No newline at end of file 487}
diff --git a/OpenSim/Services/Connectors/Grid/GridServicesConnector.cs b/OpenSim/Services/Connectors/Grid/GridServicesConnector.cs
index 34ed0d7..f982cc1 100644
--- a/OpenSim/Services/Connectors/Grid/GridServicesConnector.cs
+++ b/OpenSim/Services/Connectors/Grid/GridServicesConnector.cs
@@ -48,6 +48,9 @@ namespace OpenSim.Services.Connectors
48 48
49 private string m_ServerURI = String.Empty; 49 private string m_ServerURI = String.Empty;
50 50
51 private ExpiringCache<ulong, GridRegion> m_regionCache =
52 new ExpiringCache<ulong, GridRegion>();
53
51 public GridServicesConnector() 54 public GridServicesConnector()
52 { 55 {
53 } 56 }
@@ -272,6 +275,11 @@ namespace OpenSim.Services.Connectors
272 275
273 public GridRegion GetRegionByPosition(UUID scopeID, int x, int y) 276 public GridRegion GetRegionByPosition(UUID scopeID, int x, int y)
274 { 277 {
278 ulong regionHandle = Util.UIntsToLong((uint)x, (uint)y);
279
280 if (m_regionCache.Contains(regionHandle))
281 return (GridRegion)m_regionCache[regionHandle];
282
275 Dictionary<string, object> sendData = new Dictionary<string, object>(); 283 Dictionary<string, object> sendData = new Dictionary<string, object>();
276 284
277 sendData["SCOPEID"] = scopeID.ToString(); 285 sendData["SCOPEID"] = scopeID.ToString();
@@ -313,6 +321,8 @@ namespace OpenSim.Services.Connectors
313 else 321 else
314 m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition received null reply"); 322 m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition received null reply");
315 323
324 m_regionCache.Add(regionHandle, rinfo, TimeSpan.FromSeconds(600));
325
316 return rinfo; 326 return rinfo;
317 } 327 }
318 328
diff --git a/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs
index 19dffc3..4cd933c 100644
--- a/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs
@@ -158,6 +158,7 @@ namespace OpenSim.Services.Connectors.Hypergrid
158 try 158 try
159 { 159 {
160 WebClient c = new WebClient(); 160 WebClient c = new WebClient();
161 //m_log.Debug("JPEG: " + imageURL);
161 string name = regionID.ToString(); 162 string name = regionID.ToString();
162 filename = Path.Combine(storagePath, name + ".jpg"); 163 filename = Path.Combine(storagePath, name + ".jpg");
163 m_log.DebugFormat("[GATEKEEPER SERVICE CONNECTOR]: Map image at {0}, cached at {1}", imageURL, filename); 164 m_log.DebugFormat("[GATEKEEPER SERVICE CONNECTOR]: Map image at {0}, cached at {1}", imageURL, filename);
@@ -186,11 +187,10 @@ namespace OpenSim.Services.Connectors.Hypergrid
186 187
187 ass.Data = imageData; 188 ass.Data = imageData;
188 189
189 mapTile = ass.FullID;
190
191 // finally
192 m_AssetService.Store(ass); 190 m_AssetService.Store(ass);
193 191
192 // finally
193 mapTile = ass.FullID;
194 } 194 }
195 catch // LEGIT: Catching problems caused by OpenJPEG p/invoke 195 catch // LEGIT: Catching problems caused by OpenJPEG p/invoke
196 { 196 {
diff --git a/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs
index 2f263ae..c542c29 100644
--- a/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs
@@ -98,8 +98,6 @@ namespace OpenSim.Services.Connectors.Hypergrid
98 throw new Exception("UserAgent connector init error"); 98 throw new Exception("UserAgent connector init error");
99 } 99 }
100 m_ServerURL = serviceURI; 100 m_ServerURL = serviceURI;
101 if (!m_ServerURL.EndsWith("/"))
102 m_ServerURL += "/";
103 101
104 m_log.DebugFormat("[USER AGENT CONNECTOR]: UserAgentServiceConnector started for {0}", m_ServerURL); 102 m_log.DebugFormat("[USER AGENT CONNECTOR]: UserAgentServiceConnector started for {0}", m_ServerURL);
105 } 103 }
diff --git a/OpenSim/Services/Connectors/Land/LandServicesConnector.cs b/OpenSim/Services/Connectors/Land/LandServicesConnector.cs
index 30a73a4..833e22a 100644
--- a/OpenSim/Services/Connectors/Land/LandServicesConnector.cs
+++ b/OpenSim/Services/Connectors/Land/LandServicesConnector.cs
@@ -130,4 +130,4 @@ namespace OpenSim.Services.Connectors
130 return landData; 130 return landData;
131 } 131 }
132 } 132 }
133} \ No newline at end of file 133}
diff --git a/OpenSim/Services/Connectors/Presence/PresenceServicesConnector.cs b/OpenSim/Services/Connectors/Presence/PresenceServicesConnector.cs
index f7d8c53..378aab6 100644
--- a/OpenSim/Services/Connectors/Presence/PresenceServicesConnector.cs
+++ b/OpenSim/Services/Connectors/Presence/PresenceServicesConnector.cs
@@ -304,6 +304,17 @@ namespace OpenSim.Services.Connectors
304 { 304 {
305 pinfo = new PresenceInfo((Dictionary<string, object>)replyData["result"]); 305 pinfo = new PresenceInfo((Dictionary<string, object>)replyData["result"]);
306 } 306 }
307 else
308 {
309 if (replyData["result"].ToString() == "null")
310 return null;
311
312 m_log.DebugFormat("[PRESENCE CONNECTOR]: Invalid reply (result not dictionary) received from presence server when querying for sessionID {0}", sessionID.ToString());
313 }
314 }
315 else
316 {
317 m_log.DebugFormat("[PRESENCE CONNECTOR]: Invalid reply received from presence server when querying for sessionID {0}", sessionID.ToString());
307 } 318 }
308 319
309 return pinfo; 320 return pinfo;
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs
index 67a65ff..0e4d794 100644
--- a/OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs
+++ b/OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs
@@ -28,6 +28,8 @@
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Collections.Specialized; 30using System.Collections.Specialized;
31using System.Drawing;
32using System.Drawing.Imaging;
31using System.IO; 33using System.IO;
32using System.Net; 34using System.Net;
33using System.Reflection; 35using System.Reflection;
@@ -100,6 +102,15 @@ namespace OpenSim.Services.Connectors.SimianGrid
100 102
101 public string RegisterRegion(UUID scopeID, GridRegion regionInfo) 103 public string RegisterRegion(UUID scopeID, GridRegion regionInfo)
102 { 104 {
105 IPEndPoint ext = regionInfo.ExternalEndPoint;
106 if (ext == null) return "Region registration for " + regionInfo.RegionName + " failed: Could not resolve EndPoint";
107 // Generate and upload our map tile in PNG format to the SimianGrid AddMapTile service
108// Scene scene;
109// if (m_scenes.TryGetValue(regionInfo.RegionID, out scene))
110// UploadMapTile(scene);
111// else
112// m_log.Warn("Registering region " + regionInfo.RegionName + " (" + regionInfo.RegionID + ") that we are not tracking");
113
103 Vector3d minPosition = new Vector3d(regionInfo.RegionLocX, regionInfo.RegionLocY, 0.0); 114 Vector3d minPosition = new Vector3d(regionInfo.RegionLocX, regionInfo.RegionLocY, 0.0);
104 Vector3d maxPosition = minPosition + new Vector3d(Constants.RegionSize, Constants.RegionSize, 4096.0); 115 Vector3d maxPosition = minPosition + new Vector3d(Constants.RegionSize, Constants.RegionSize, 4096.0);
105 116
@@ -108,7 +119,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
108 { "ServerURI", OSD.FromString(regionInfo.ServerURI) }, 119 { "ServerURI", OSD.FromString(regionInfo.ServerURI) },
109 { "InternalAddress", OSD.FromString(regionInfo.InternalEndPoint.Address.ToString()) }, 120 { "InternalAddress", OSD.FromString(regionInfo.InternalEndPoint.Address.ToString()) },
110 { "InternalPort", OSD.FromInteger(regionInfo.InternalEndPoint.Port) }, 121 { "InternalPort", OSD.FromInteger(regionInfo.InternalEndPoint.Port) },
111 { "ExternalAddress", OSD.FromString(regionInfo.ExternalEndPoint.Address.ToString()) }, 122 { "ExternalAddress", OSD.FromString(ext.Address.ToString()) },
112 { "ExternalPort", OSD.FromInteger(regionInfo.ExternalEndPoint.Port) }, 123 { "ExternalPort", OSD.FromInteger(regionInfo.ExternalEndPoint.Port) },
113 { "MapTexture", OSD.FromUUID(regionInfo.TerrainImage) }, 124 { "MapTexture", OSD.FromUUID(regionInfo.TerrainImage) },
114 { "Access", OSD.FromInteger(regionInfo.Access) }, 125 { "Access", OSD.FromInteger(regionInfo.Access) },
@@ -399,6 +410,83 @@ namespace OpenSim.Services.Connectors.SimianGrid
399 410
400 #endregion IGridService 411 #endregion IGridService
401 412
413 private void UploadMapTile(IScene scene)
414 {
415 string errorMessage = null;
416
417 // Create a PNG map tile and upload it to the AddMapTile API
418 byte[] pngData = Utils.EmptyBytes;
419 IMapImageGenerator tileGenerator = scene.RequestModuleInterface<IMapImageGenerator>();
420 if (tileGenerator == null)
421 {
422 m_log.Warn("[SIMIAN GRID CONNECTOR]: Cannot upload PNG map tile without an IMapImageGenerator");
423 return;
424 }
425
426 using (Image mapTile = tileGenerator.CreateMapTile())
427 {
428 using (MemoryStream stream = new MemoryStream())
429 {
430 mapTile.Save(stream, ImageFormat.Png);
431 pngData = stream.ToArray();
432 }
433 }
434
435 List<MultipartForm.Element> postParameters = new List<MultipartForm.Element>()
436 {
437 new MultipartForm.Parameter("X", scene.RegionInfo.RegionLocX.ToString()),
438 new MultipartForm.Parameter("Y", scene.RegionInfo.RegionLocY.ToString()),
439 new MultipartForm.File("Tile", "tile.png", "image/png", pngData)
440 };
441
442 // Make the remote storage request
443 try
444 {
445 HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(m_ServerURI);
446
447 HttpWebResponse response = MultipartForm.Post(request, postParameters);
448 using (Stream responseStream = response.GetResponseStream())
449 {
450 string responseStr = null;
451
452 try
453 {
454 responseStr = responseStream.GetStreamString();
455 OSD responseOSD = OSDParser.Deserialize(responseStr);
456 if (responseOSD.Type == OSDType.Map)
457 {
458 OSDMap responseMap = (OSDMap)responseOSD;
459 if (responseMap["Success"].AsBoolean())
460 m_log.Info("[SIMIAN GRID CONNECTOR]: Uploaded " + pngData.Length + " byte PNG map tile to AddMapTile");
461 else
462 errorMessage = "Upload failed: " + responseMap["Message"].AsString();
463 }
464 else
465 {
466 errorMessage = "Response format was invalid:\n" + responseStr;
467 }
468 }
469 catch (Exception ex)
470 {
471 if (!String.IsNullOrEmpty(responseStr))
472 errorMessage = "Failed to parse the response:\n" + responseStr;
473 else
474 errorMessage = "Failed to retrieve the response: " + ex.Message;
475 }
476 }
477 }
478 catch (WebException ex)
479 {
480 errorMessage = ex.Message;
481 }
482
483 if (!String.IsNullOrEmpty(errorMessage))
484 {
485 m_log.WarnFormat("[SIMIAN GRID CONNECTOR]: Failed to store {0} byte PNG map tile for {1}: {2}",
486 pngData.Length, scene.RegionInfo.RegionName, errorMessage.Replace('\n', ' '));
487 }
488 }
489
402 private GridRegion GetNearestRegion(Vector3d position, bool onlyEnabled) 490 private GridRegion GetNearestRegion(Vector3d position, bool onlyEnabled)
403 { 491 {
404 NameValueCollection requestArgs = new NameValueCollection 492 NameValueCollection requestArgs = new NameValueCollection
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianUserAccountServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianUserAccountServiceConnector.cs
index 4350749..f38ebe8 100644
--- a/OpenSim/Services/Connectors/SimianGrid/SimianUserAccountServiceConnector.cs
+++ b/OpenSim/Services/Connectors/SimianGrid/SimianUserAccountServiceConnector.cs
@@ -191,6 +191,11 @@ namespace OpenSim.Services.Connectors.SimianGrid
191 return accounts; 191 return accounts;
192 } 192 }
193 193
194 public List<UserAccount> GetUserAccountsWhere(UUID scopeID, string query)
195 {
196 return null;
197 }
198
194 public bool StoreUserAccount(UserAccount data) 199 public bool StoreUserAccount(UserAccount data)
195 { 200 {
196// m_log.InfoFormat("[SIMIAN ACCOUNT CONNECTOR]: Storing user account for " + data.Name); 201// m_log.InfoFormat("[SIMIAN ACCOUNT CONNECTOR]: Storing user account for " + data.Name);
diff --git a/OpenSim/Services/Connectors/Simulation/SimulationDataService.cs b/OpenSim/Services/Connectors/Simulation/SimulationDataService.cs
index c9cbbfa..6db830b 100644
--- a/OpenSim/Services/Connectors/Simulation/SimulationDataService.cs
+++ b/OpenSim/Services/Connectors/Simulation/SimulationDataService.cs
@@ -164,5 +164,9 @@ namespace OpenSim.Services.Connectors
164 m_database.RemoveRegionEnvironmentSettings(regionUUID); 164 m_database.RemoveRegionEnvironmentSettings(regionUUID);
165 } 165 }
166 166
167 public UUID[] GetObjectIDs(UUID regionID)
168 {
169 return m_database.GetObjectIDs(regionID);
170 }
167 } 171 }
168} 172}
diff --git a/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs
index 95c4f87..cd93386 100644
--- a/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs
@@ -359,6 +359,10 @@ namespace OpenSim.Services.Connectors.Simulation
359 return false; 359 return false;
360 } 360 }
361 361
362 OSDMap resp = (OSDMap)result["_Result"];
363 success = resp["success"].AsBoolean();
364 reason = resp["reason"].AsString();
365
362 return success; 366 return success;
363 } 367 }
364 catch (Exception e) 368 catch (Exception e)
@@ -387,9 +391,7 @@ namespace OpenSim.Services.Connectors.Simulation
387 return true; 391 return true;
388 } 392 }
389 393
390 /// <summary> 394 private bool CloseAgent(GridRegion destination, UUID id, bool ChildOnly)
391 /// </summary>
392 public bool CloseAgent(GridRegion destination, UUID id)
393 { 395 {
394// m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: CloseAgent start"); 396// m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: CloseAgent start");
395 397
@@ -407,6 +409,16 @@ namespace OpenSim.Services.Connectors.Simulation
407 return true; 409 return true;
408 } 410 }
409 411
412 public bool CloseChildAgent(GridRegion destination, UUID id)
413 {
414 return CloseAgent(destination, id, true);
415 }
416
417 public bool CloseAgent(GridRegion destination, UUID id)
418 {
419 return CloseAgent(destination, id, false);
420 }
421
410 #endregion Agents 422 #endregion Agents
411 423
412 #region Objects 424 #region Objects
@@ -444,11 +456,14 @@ namespace OpenSim.Services.Connectors.Simulation
444 args["destination_name"] = OSD.FromString(destination.RegionName); 456 args["destination_name"] = OSD.FromString(destination.RegionName);
445 args["destination_uuid"] = OSD.FromString(destination.RegionID.ToString()); 457 args["destination_uuid"] = OSD.FromString(destination.RegionID.ToString());
446 458
447 WebUtil.PostToService(uri, args, 40000); 459 OSDMap response = WebUtil.PostToService(uri, args, 40000);
460 if (response["Success"] == "False")
461 return false;
448 } 462 }
449 catch (Exception e) 463 catch (Exception e)
450 { 464 {
451 m_log.WarnFormat("[REMOTE SIMULATION CONNECTOR] CreateObject failed with exception; {0}",e.ToString()); 465 m_log.WarnFormat("[REMOTE SIMULATION CONNECTOR] CreateObject failed with exception; {0}",e.ToString());
466 return false;
452 } 467 }
453 468
454 return true; 469 return true;
diff --git a/OpenSim/Services/Connectors/UserAccounts/UserAccountServicesConnector.cs b/OpenSim/Services/Connectors/UserAccounts/UserAccountServicesConnector.cs
index 6d5ce28..5731e2f 100644
--- a/OpenSim/Services/Connectors/UserAccounts/UserAccountServicesConnector.cs
+++ b/OpenSim/Services/Connectors/UserAccounts/UserAccountServicesConnector.cs
@@ -187,6 +187,11 @@ namespace OpenSim.Services.Connectors
187 return accounts; 187 return accounts;
188 } 188 }
189 189
190 public List<UserAccount> GetUserAccountsWhere(UUID scopeID, string where)
191 {
192 return null; // Not implemented for regions
193 }
194
190 public virtual bool StoreUserAccount(UserAccount data) 195 public virtual bool StoreUserAccount(UserAccount data)
191 { 196 {
192 Dictionary<string, object> sendData = new Dictionary<string, object>(); 197 Dictionary<string, object> sendData = new Dictionary<string, object>();
diff --git a/OpenSim/Services/HypergridService/UserAccountCache.cs b/OpenSim/Services/HypergridService/UserAccountCache.cs
index 65f9dd5..e0a3e61 100644
--- a/OpenSim/Services/HypergridService/UserAccountCache.cs
+++ b/OpenSim/Services/HypergridService/UserAccountCache.cs
@@ -90,6 +90,11 @@ namespace OpenSim.Services.HypergridService
90 return null; 90 return null;
91 } 91 }
92 92
93 public List<UserAccount> GetUserAccountsWhere(UUID scopeID, string query)
94 {
95 return null;
96 }
97
93 public List<UserAccount> GetUserAccounts(UUID scopeID, string query) 98 public List<UserAccount> GetUserAccounts(UUID scopeID, string query)
94 { 99 {
95 return null; 100 return null;
diff --git a/OpenSim/Services/HypergridService/UserAgentService.cs b/OpenSim/Services/HypergridService/UserAgentService.cs
index 49c7f89..a49993c 100644
--- a/OpenSim/Services/HypergridService/UserAgentService.cs
+++ b/OpenSim/Services/HypergridService/UserAgentService.cs
@@ -313,13 +313,11 @@ namespace OpenSim.Services.HypergridService
313 313
314 if (m_TravelingAgents.ContainsKey(sessionID)) 314 if (m_TravelingAgents.ContainsKey(sessionID))
315 { 315 {
316 bool result = m_TravelingAgents[sessionID].ClientIPAddress == reportedIP || 316 m_log.DebugFormat("[USER AGENT SERVICE]: Comparing with login IP {0} and MyIP {1}",
317 m_TravelingAgents[sessionID].MyIpAddress == reportedIP; // NATed 317 m_TravelingAgents[sessionID].ClientIPAddress, m_TravelingAgents[sessionID].MyIpAddress);
318
319 m_log.DebugFormat("[USER AGENT SERVICE]: Comparing {0} with login IP {1} and MyIP {1}; result is {3}",
320 reportedIP, m_TravelingAgents[sessionID].ClientIPAddress, m_TravelingAgents[sessionID].MyIpAddress, result);
321 318
322 return result; 319 return m_TravelingAgents[sessionID].ClientIPAddress == reportedIP ||
320 m_TravelingAgents[sessionID].MyIpAddress == reportedIP; // NATed
323 } 321 }
324 322
325 return false; 323 return false;
diff --git a/OpenSim/Services/Interfaces/IAttachmentsService.cs b/OpenSim/Services/Interfaces/IAttachmentsService.cs
new file mode 100644
index 0000000..bdde369
--- /dev/null
+++ b/OpenSim/Services/Interfaces/IAttachmentsService.cs
@@ -0,0 +1,17 @@
1////////////////////////////////////////////////////////////////
2//
3// (c) 2009, 2010 Careminster Limited and Melanie Thielker
4//
5// All rights reserved
6//
7using System;
8using Nini.Config;
9
10namespace OpenSim.Services.Interfaces
11{
12 public interface IAttachmentsService
13 {
14 string Get(string id);
15 void Store(string id, string data);
16 }
17}
diff --git a/OpenSim/Services/Interfaces/IAvatarService.cs b/OpenSim/Services/Interfaces/IAvatarService.cs
index cda7113..8412c35 100644
--- a/OpenSim/Services/Interfaces/IAvatarService.cs
+++ b/OpenSim/Services/Interfaces/IAvatarService.cs
@@ -162,10 +162,16 @@ namespace OpenSim.Services.Interfaces
162 } 162 }
163 163
164 // Visual Params 164 // Visual Params
165 string[] vps = new string[AvatarAppearance.VISUALPARAM_COUNT]; 165 // string[] vps = new string[AvatarAppearance.VISUALPARAM_COUNT];
166 // byte[] binary = appearance.VisualParams;
167
168 // for (int i = 0 ; i < AvatarAppearance.VISUALPARAM_COUNT ; i++)
169
170
166 byte[] binary = appearance.VisualParams; 171 byte[] binary = appearance.VisualParams;
172 string[] vps = new string[binary.Length];
167 173
168 for (int i = 0 ; i < AvatarAppearance.VISUALPARAM_COUNT ; i++) 174 for (int i = 0; i < binary.Length; i++)
169 { 175 {
170 vps[i] = binary[i].ToString(); 176 vps[i] = binary[i].ToString();
171 } 177 }
@@ -265,10 +271,14 @@ namespace OpenSim.Services.Interfaces
265 if (Data.ContainsKey("VisualParams")) 271 if (Data.ContainsKey("VisualParams"))
266 { 272 {
267 string[] vps = Data["VisualParams"].Split(new char[] {','}); 273 string[] vps = Data["VisualParams"].Split(new char[] {','});
268 byte[] binary = new byte[AvatarAppearance.VISUALPARAM_COUNT]; 274 // byte[] binary = new byte[AvatarAppearance.VISUALPARAM_COUNT];
275
276 // for (int i = 0 ; i < vps.Length && i < binary.Length ; i++)
277 byte[] binary = new byte[vps.Length];
278
279 for (int i = 0; i < vps.Length; i++)
269 280
270 for (int i = 0 ; i < vps.Length && i < binary.Length ; i++) 281 binary[i] = (byte)Convert.ToInt32(vps[i]);
271 binary[i] = (byte)Convert.ToInt32(vps[i]);
272 282
273 appearance.VisualParams = binary; 283 appearance.VisualParams = binary;
274 } 284 }
diff --git a/OpenSim/Services/Interfaces/IGridService.cs b/OpenSim/Services/Interfaces/IGridService.cs
index d809996..cdcb961 100644
--- a/OpenSim/Services/Interfaces/IGridService.cs
+++ b/OpenSim/Services/Interfaces/IGridService.cs
@@ -324,9 +324,13 @@ namespace OpenSim.Services.Interfaces
324 } 324 }
325 catch (SocketException e) 325 catch (SocketException e)
326 { 326 {
327 throw new Exception( 327 /*throw new Exception(
328 "Unable to resolve local hostname " + m_externalHostName + " innerException of type '" + 328 "Unable to resolve local hostname " + m_externalHostName + " innerException of type '" +
329 e + "' attached to this exception", e); 329 e + "' attached to this exception", e);*/
330 // Don't throw a fatal exception here, instead, return Null and handle it in the caller.
331 // Reason is, on systems such as OSgrid it has occured that known hostnames stop
332 // resolving and thus make surrounding regions crash out with this exception.
333 return null;
330 } 334 }
331 335
332 return new IPEndPoint(ia, m_internalEndPoint.Port); 336 return new IPEndPoint(ia, m_internalEndPoint.Port);
@@ -385,6 +389,12 @@ namespace OpenSim.Services.Interfaces
385 if (kvp.ContainsKey("regionName")) 389 if (kvp.ContainsKey("regionName"))
386 RegionName = (string)kvp["regionName"]; 390 RegionName = (string)kvp["regionName"];
387 391
392 if (kvp.ContainsKey("access"))
393 {
394 byte access = Convert.ToByte((string)kvp["access"]);
395 Maturity = (int)Util.ConvertAccessLevelToMaturity(access);
396 }
397
388 if (kvp.ContainsKey("serverIP")) 398 if (kvp.ContainsKey("serverIP"))
389 { 399 {
390 //int port = 0; 400 //int port = 0;
diff --git a/OpenSim/Services/Interfaces/ISimulationService.cs b/OpenSim/Services/Interfaces/ISimulationService.cs
index b10a85c..a963b8e 100644
--- a/OpenSim/Services/Interfaces/ISimulationService.cs
+++ b/OpenSim/Services/Interfaces/ISimulationService.cs
@@ -90,6 +90,14 @@ namespace OpenSim.Services.Interfaces
90 bool ReleaseAgent(UUID originRegion, UUID id, string uri); 90 bool ReleaseAgent(UUID originRegion, UUID id, string uri);
91 91
92 /// <summary> 92 /// <summary>
93 /// Close child agent.
94 /// </summary>
95 /// <param name="regionHandle"></param>
96 /// <param name="id"></param>
97 /// <returns></returns>
98 bool CloseChildAgent(GridRegion destination, UUID id);
99
100 /// <summary>
93 /// Close agent. 101 /// Close agent.
94 /// </summary> 102 /// </summary>
95 /// <param name="regionHandle"></param> 103 /// <param name="regionHandle"></param>
diff --git a/OpenSim/Services/Interfaces/IUserAccountService.cs b/OpenSim/Services/Interfaces/IUserAccountService.cs
index 1b85980..6d5d2a0 100644
--- a/OpenSim/Services/Interfaces/IUserAccountService.cs
+++ b/OpenSim/Services/Interfaces/IUserAccountService.cs
@@ -91,6 +91,7 @@ namespace OpenSim.Services.Interfaces
91 public int UserLevel; 91 public int UserLevel;
92 public int UserFlags; 92 public int UserFlags;
93 public string UserTitle; 93 public string UserTitle;
94 public string UserCountry;
94 public Boolean LocalToGrid = true; 95 public Boolean LocalToGrid = true;
95 96
96 public Dictionary<string, object> ServiceURLs; 97 public Dictionary<string, object> ServiceURLs;
@@ -120,6 +121,8 @@ namespace OpenSim.Services.Interfaces
120 UserFlags = Convert.ToInt32(kvp["UserFlags"].ToString()); 121 UserFlags = Convert.ToInt32(kvp["UserFlags"].ToString());
121 if (kvp.ContainsKey("UserTitle")) 122 if (kvp.ContainsKey("UserTitle"))
122 UserTitle = kvp["UserTitle"].ToString(); 123 UserTitle = kvp["UserTitle"].ToString();
124 if (kvp.ContainsKey("UserCountry"))
125 UserCountry = kvp["UserCountry"].ToString();
123 if (kvp.ContainsKey("LocalToGrid")) 126 if (kvp.ContainsKey("LocalToGrid"))
124 Boolean.TryParse(kvp["LocalToGrid"].ToString(), out LocalToGrid); 127 Boolean.TryParse(kvp["LocalToGrid"].ToString(), out LocalToGrid);
125 128
@@ -155,6 +158,7 @@ namespace OpenSim.Services.Interfaces
155 result["UserLevel"] = UserLevel.ToString(); 158 result["UserLevel"] = UserLevel.ToString();
156 result["UserFlags"] = UserFlags.ToString(); 159 result["UserFlags"] = UserFlags.ToString();
157 result["UserTitle"] = UserTitle; 160 result["UserTitle"] = UserTitle;
161 result["UserCountry"] = UserCountry;
158 result["LocalToGrid"] = LocalToGrid.ToString(); 162 result["LocalToGrid"] = LocalToGrid.ToString();
159 163
160 string str = string.Empty; 164 string str = string.Empty;
@@ -182,6 +186,7 @@ namespace OpenSim.Services.Interfaces
182 /// <param name="query"></param> 186 /// <param name="query"></param>
183 /// <returns></returns> 187 /// <returns></returns>
184 List<UserAccount> GetUserAccounts(UUID scopeID, string query); 188 List<UserAccount> GetUserAccounts(UUID scopeID, string query);
189 List<UserAccount> GetUserAccountsWhere(UUID scopeID, string where);
185 190
186 /// <summary> 191 /// <summary>
187 /// Store the data given, wich replaces the stored data, therefore must be complete. 192 /// Store the data given, wich replaces the stored data, therefore must be complete.
diff --git a/OpenSim/Services/LLLoginService/LLLoginResponse.cs b/OpenSim/Services/LLLoginService/LLLoginResponse.cs
index 9ec744f..a4b3cbd 100644
--- a/OpenSim/Services/LLLoginService/LLLoginResponse.cs
+++ b/OpenSim/Services/LLLoginService/LLLoginResponse.cs
@@ -55,6 +55,7 @@ namespace OpenSim.Services.LLLoginService
55 public static LLFailedLoginResponse InventoryProblem; 55 public static LLFailedLoginResponse InventoryProblem;
56 public static LLFailedLoginResponse DeadRegionProblem; 56 public static LLFailedLoginResponse DeadRegionProblem;
57 public static LLFailedLoginResponse LoginBlockedProblem; 57 public static LLFailedLoginResponse LoginBlockedProblem;
58 public static LLFailedLoginResponse UnverifiedAccountProblem;
58 public static LLFailedLoginResponse AlreadyLoggedInProblem; 59 public static LLFailedLoginResponse AlreadyLoggedInProblem;
59 public static LLFailedLoginResponse InternalError; 60 public static LLFailedLoginResponse InternalError;
60 61
@@ -75,6 +76,10 @@ namespace OpenSim.Services.LLLoginService
75 LoginBlockedProblem = new LLFailedLoginResponse("presence", 76 LoginBlockedProblem = new LLFailedLoginResponse("presence",
76 "Logins are currently restricted. Please try again later.", 77 "Logins are currently restricted. Please try again later.",
77 "false"); 78 "false");
79 UnverifiedAccountProblem = new LLFailedLoginResponse("presence",
80 "Your account has not yet been verified. Please check " +
81 "your email and click the provided link.",
82 "false");
78 AlreadyLoggedInProblem = new LLFailedLoginResponse("presence", 83 AlreadyLoggedInProblem = new LLFailedLoginResponse("presence",
79 "You appear to be already logged in. " + 84 "You appear to be already logged in. " +
80 "If this is not the case please wait for your session to timeout. " + 85 "If this is not the case please wait for your session to timeout. " +
@@ -375,6 +380,7 @@ namespace OpenSim.Services.LLLoginService
375 private void FillOutRegionData(GridRegion destination) 380 private void FillOutRegionData(GridRegion destination)
376 { 381 {
377 IPEndPoint endPoint = destination.ExternalEndPoint; 382 IPEndPoint endPoint = destination.ExternalEndPoint;
383 if (endPoint == null) return;
378 SimAddress = endPoint.Address.ToString(); 384 SimAddress = endPoint.Address.ToString();
379 SimPort = (uint)endPoint.Port; 385 SimPort = (uint)endPoint.Port;
380 RegionX = (uint)destination.RegionLocX; 386 RegionX = (uint)destination.RegionLocX;
diff --git a/OpenSim/Services/LLLoginService/LLLoginService.cs b/OpenSim/Services/LLLoginService/LLLoginService.cs
index 495dc52..ed887d9 100644
--- a/OpenSim/Services/LLLoginService/LLLoginService.cs
+++ b/OpenSim/Services/LLLoginService/LLLoginService.cs
@@ -140,7 +140,8 @@ namespace OpenSim.Services.LLLoginService
140 Object[] args = new Object[] { config }; 140 Object[] args = new Object[] { config };
141 m_UserAccountService = ServerUtils.LoadPlugin<IUserAccountService>(accountService, args); 141 m_UserAccountService = ServerUtils.LoadPlugin<IUserAccountService>(accountService, args);
142 m_GridUserService = ServerUtils.LoadPlugin<IGridUserService>(gridUserService, args); 142 m_GridUserService = ServerUtils.LoadPlugin<IGridUserService>(gridUserService, args);
143 m_AuthenticationService = ServerUtils.LoadPlugin<IAuthenticationService>(authService, args); 143 Object[] authArgs = new Object[] { config, m_UserAccountService };
144 m_AuthenticationService = ServerUtils.LoadPlugin<IAuthenticationService>(authService, authArgs);
144 m_InventoryService = ServerUtils.LoadPlugin<IInventoryService>(invService, args); 145 m_InventoryService = ServerUtils.LoadPlugin<IInventoryService>(invService, args);
145 146
146 if (gridService != string.Empty) 147 if (gridService != string.Empty)
@@ -289,6 +290,12 @@ namespace OpenSim.Services.LLLoginService
289 return LLFailedLoginResponse.UserProblem; 290 return LLFailedLoginResponse.UserProblem;
290 } 291 }
291 292
293 if (account.UserLevel < 0)
294 {
295 m_log.InfoFormat("[LLOGIN SERVICE]: Login failed, reason: Unverified account");
296 return LLFailedLoginResponse.UnverifiedAccountProblem;
297 }
298
292 if (account.UserLevel < m_MinLoginLevel) 299 if (account.UserLevel < m_MinLoginLevel)
293 { 300 {
294 m_log.InfoFormat( 301 m_log.InfoFormat(
diff --git a/OpenSim/Services/UserAccountService/UserAccountService.cs b/OpenSim/Services/UserAccountService/UserAccountService.cs
index a281b3b..95c2935 100644
--- a/OpenSim/Services/UserAccountService/UserAccountService.cs
+++ b/OpenSim/Services/UserAccountService/UserAccountService.cs
@@ -170,6 +170,10 @@ namespace OpenSim.Services.UserAccountService
170 Int32.TryParse(d.Data["UserLevel"], out u.UserLevel); 170 Int32.TryParse(d.Data["UserLevel"], out u.UserLevel);
171 if (d.Data.ContainsKey("UserFlags") && d.Data["UserFlags"] != null) 171 if (d.Data.ContainsKey("UserFlags") && d.Data["UserFlags"] != null)
172 Int32.TryParse(d.Data["UserFlags"], out u.UserFlags); 172 Int32.TryParse(d.Data["UserFlags"], out u.UserFlags);
173 if (d.Data.ContainsKey("UserCountry") && d.Data["UserCountry"] != null)
174 u.UserCountry = d.Data["UserCountry"].ToString();
175 else
176 u.UserTitle = string.Empty;
173 177
174 if (d.Data.ContainsKey("ServiceURLs") && d.Data["ServiceURLs"] != null) 178 if (d.Data.ContainsKey("ServiceURLs") && d.Data["ServiceURLs"] != null)
175 { 179 {
@@ -291,7 +295,22 @@ namespace OpenSim.Services.UserAccountService
291 295
292 public List<UserAccount> GetUserAccounts(UUID scopeID, string query) 296 public List<UserAccount> GetUserAccounts(UUID scopeID, string query)
293 { 297 {
294 UserAccountData[] d = m_Database.GetUsers(scopeID, query); 298 UserAccountData[] d = m_Database.GetUsers(scopeID, query.Trim());
299
300 if (d == null)
301 return new List<UserAccount>();
302
303 List<UserAccount> ret = new List<UserAccount>();
304
305 foreach (UserAccountData data in d)
306 ret.Add(MakeUserAccount(data));
307
308 return ret;
309 }
310
311 public List<UserAccount> GetUserAccountsWhere(UUID scopeID, string where)
312 {
313 UserAccountData[] d = m_Database.GetUsersWhere(scopeID, where);
295 314
296 if (d == null) 315 if (d == null)
297 return new List<UserAccount>(); 316 return new List<UserAccount>();