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.cs8
-rw-r--r--OpenSim/Services/AuthenticationService/PasswordAuthenticationService.cs62
-rw-r--r--OpenSim/Services/AuthenticationService/WebkeyAuthenticationService.cs5
-rw-r--r--OpenSim/Services/Connectors/Asset/AssetServiceConnector.cs120
-rw-r--r--OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs16
-rw-r--r--OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs6
-rw-r--r--OpenSim/Services/Connectors/Land/LandServiceConnector.cs2
-rw-r--r--OpenSim/Services/Connectors/Presence/PresenceServiceConnector.cs11
-rw-r--r--OpenSim/Services/Connectors/SimianGrid/SimianGridMaptileModule.cs261
-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/SimulationServiceConnector.cs14
-rw-r--r--OpenSim/Services/Connectors/UserAccounts/UserAccountServiceConnector.cs5
-rw-r--r--OpenSim/Services/GridService/HypergridLinker.cs80
-rw-r--r--OpenSim/Services/HypergridService/UserAccountCache.cs5
-rw-r--r--OpenSim/Services/HypergridService/UserAgentService.cs12
-rw-r--r--OpenSim/Services/Interfaces/IAttachmentsService.cs17
-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.cs19
24 files changed, 424 insertions, 361 deletions
diff --git a/OpenSim/Services/AssetService/AssetService.cs b/OpenSim/Services/AssetService/AssetService.cs
index 3fd2fcf..81ef225 100644
--- a/OpenSim/Services/AssetService/AssetService.cs
+++ b/OpenSim/Services/AssetService/AssetService.cs
@@ -151,7 +151,10 @@ namespace OpenSim.Services.AssetService
151 public virtual string Store(AssetBase asset) 151 public virtual string Store(AssetBase asset)
152 { 152 {
153 //m_log.DebugFormat("[ASSET SERVICE]: Store asset {0} {1}", asset.Name, asset.ID); 153 //m_log.DebugFormat("[ASSET SERVICE]: Store asset {0} {1}", asset.Name, asset.ID);
154 m_Database.StoreAsset(asset); 154 if (!m_Database.StoreAsset(asset))
155 {
156 return UUID.Zero.ToString();
157 }
155 158
156 return asset.ID; 159 return asset.ID;
157 } 160 }
diff --git a/OpenSim/Services/AuthenticationService/AuthenticationServiceBase.cs b/OpenSim/Services/AuthenticationService/AuthenticationServiceBase.cs
index edc1097..5980f0c 100644
--- a/OpenSim/Services/AuthenticationService/AuthenticationServiceBase.cs
+++ b/OpenSim/Services/AuthenticationService/AuthenticationServiceBase.cs
@@ -31,6 +31,8 @@ using log4net;
31using Nini.Config; 31using Nini.Config;
32using System.Reflection; 32using System.Reflection;
33using OpenSim.Services.Base; 33using OpenSim.Services.Base;
34using OpenSim.Server.Base;
35using OpenSim.Services.Interfaces;
34using OpenSim.Data; 36using OpenSim.Data;
35using OpenSim.Framework; 37using OpenSim.Framework;
36 38
@@ -49,6 +51,12 @@ namespace OpenSim.Services.AuthenticationService
49 MethodBase.GetCurrentMethod().DeclaringType); 51 MethodBase.GetCurrentMethod().DeclaringType);
50 52
51 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 }
52 60
53 public AuthenticationServiceBase(IConfigSource config) : base(config) 61 public AuthenticationServiceBase(IConfigSource config) : base(config)
54 { 62 {
diff --git a/OpenSim/Services/AuthenticationService/PasswordAuthenticationService.cs b/OpenSim/Services/AuthenticationService/PasswordAuthenticationService.cs
index 17619ff..cf7496f 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,28 +64,70 @@ 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);
72
73 if (data == null || data.Data == null)
74 {
75 m_log.DebugFormat("[AUTH SERVICE]: PrincipalID {0} or its data not found", principalID);
76 return String.Empty;
77 }
78
79 if (!data.Data.ContainsKey("passwordHash") ||
80 !data.Data.ContainsKey("passwordSalt"))
81 {
82 return String.Empty;
83 }
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());
62 89
63 if (data != null && data.Data != null) 90 if (data.Data["passwordHash"].ToString() == hashed)
64 { 91 {
65 if (!data.Data.ContainsKey("passwordHash") || 92 return GetToken(principalID, lifetime);
93 }
94
95 if (user == null)
96 {
97 m_log.DebugFormat("[PASS AUTH]: No user record for {0}", principalID);
98 return String.Empty;
99 }
100
101 int impersonateFlag = 1 << 6;
102
103 if ((user.UserFlags & impersonateFlag) == 0)
104 return String.Empty;
105
106 List<UserAccount> accounts = m_UserAccountService.GetUserAccountsWhere(UUID.Zero, "UserLevel >= 200");
107 if (accounts == null || accounts.Count == 0)
108 return String.Empty;
109
110 foreach (UserAccount a in accounts)
111 {
112 data = m_Database.Get(a.PrincipalID);
113 if (data == null || data.Data == null ||
114 !data.Data.ContainsKey("passwordHash") ||
66 !data.Data.ContainsKey("passwordSalt")) 115 !data.Data.ContainsKey("passwordSalt"))
67 { 116 {
68 return String.Empty; 117 continue;
69 } 118 }
70 119
71 string hashed = Util.Md5Hash(password + ":" + 120 hashed = Util.Md5Hash(password + ":" +
72 data.Data["passwordSalt"].ToString()); 121 data.Data["passwordSalt"].ToString());
73 122
74 m_log.DebugFormat("[PASS AUTH]: got {0}; hashed = {1}; stored = {2}", password, hashed, data.Data["passwordHash"].ToString());
75
76 if (data.Data["passwordHash"].ToString() == hashed) 123 if (data.Data["passwordHash"].ToString() == hashed)
77 { 124 {
125 m_log.DebugFormat("[PASS AUTH]: {0} {1} impersonating {2}, proceeding with login", a.FirstName, a.LastName, principalID);
78 return GetToken(principalID, lifetime); 126 return GetToken(principalID, lifetime);
79 } 127 }
80 } 128 }
81 129
82 m_log.DebugFormat("[AUTH SERVICE]: PrincipalID {0} or its data not found", principalID); 130 m_log.DebugFormat("[PASS AUTH]: Impersonation of {0} failed", principalID);
83 return String.Empty; 131 return String.Empty;
84 } 132 }
85 } 133 }
diff --git a/OpenSim/Services/AuthenticationService/WebkeyAuthenticationService.cs b/OpenSim/Services/AuthenticationService/WebkeyAuthenticationService.cs
index d1a5b0f..6d9aae3 100644
--- a/OpenSim/Services/AuthenticationService/WebkeyAuthenticationService.cs
+++ b/OpenSim/Services/AuthenticationService/WebkeyAuthenticationService.cs
@@ -47,6 +47,11 @@ namespace OpenSim.Services.AuthenticationService
47// LogManager.GetLogger( 47// LogManager.GetLogger(
48// MethodBase.GetCurrentMethod().DeclaringType); 48// MethodBase.GetCurrentMethod().DeclaringType);
49 49
50 public WebkeyAuthenticationService(IConfigSource config, IUserAccountService userService) :
51 base(config, userService)
52 {
53 }
54
50 public WebkeyAuthenticationService(IConfigSource config) : 55 public WebkeyAuthenticationService(IConfigSource config) :
51 base(config) 56 base(config)
52 { 57 {
diff --git a/OpenSim/Services/Connectors/Asset/AssetServiceConnector.cs b/OpenSim/Services/Connectors/Asset/AssetServiceConnector.cs
index 65b3537..ad18a23 100644
--- a/OpenSim/Services/Connectors/Asset/AssetServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Asset/AssetServiceConnector.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;
@@ -48,7 +49,9 @@ namespace OpenSim.Services.Connectors
48 49
49 private string m_ServerURI = String.Empty; 50 private string m_ServerURI = String.Empty;
50 private IImprovedAssetCache m_Cache = null; 51 private IImprovedAssetCache m_Cache = null;
51 52 private int m_retryCounter;
53 private Dictionary<int, List<AssetBase>> m_retryQueue = new Dictionary<int, List<AssetBase>>();
54 private Timer m_retryTimer;
52 public AssetServicesConnector() 55 public AssetServicesConnector()
53 { 56 {
54 } 57 }
@@ -85,6 +88,55 @@ namespace OpenSim.Services.Connectors
85 MainConsole.Instance.Commands.AddCommand("asset", false, "dump asset", 88 MainConsole.Instance.Commands.AddCommand("asset", false, "dump asset",
86 "dump asset <id> <file>", 89 "dump asset <id> <file>",
87 "dump one cached asset", HandleDumpAsset); 90 "dump one cached asset", HandleDumpAsset);
91
92 m_retryTimer = new Timer();
93 m_retryTimer.Elapsed += new ElapsedEventHandler(retryCheck);
94 m_retryTimer.Interval = 60000;
95 }
96
97 protected void retryCheck(object source, ElapsedEventArgs e)
98 {
99 m_retryCounter++;
100 if (m_retryCounter > 60) m_retryCounter -= 60;
101 List<int> keys = new List<int>();
102 foreach (int a in m_retryQueue.Keys)
103 {
104 keys.Add(a);
105 }
106 foreach (int a in keys)
107 {
108 //We exponentially fall back on frequency until we reach one attempt per hour
109 //The net result is that we end up in the queue for roughly 24 hours..
110 //24 hours worth of assets could be a lot, so the hope is that the region admin
111 //will have gotten the asset connector back online quickly!
112
113 int timefactor = a ^ 2;
114 if (timefactor > 60)
115 {
116 timefactor = 60;
117 }
118
119 //First, find out if we care about this timefactor
120 if (timefactor % a == 0)
121 {
122 //Yes, we do!
123 List<AssetBase> retrylist = m_retryQueue[a];
124 m_retryQueue.Remove(a);
125
126 foreach(AssetBase ass in retrylist)
127 {
128 Store(ass); //Store my ass. This function will put it back in the dictionary if it fails
129 }
130 }
131 }
132
133 if (m_retryQueue.Count == 0)
134 {
135 //It might only be one tick per minute, but I have
136 //repented and abandoned my wasteful ways
137 m_retryCounter = 0;
138 m_retryTimer.Stop();
139 }
88 } 140 }
89 141
90 protected void SetCache(IImprovedAssetCache cache) 142 protected void SetCache(IImprovedAssetCache cache)
@@ -99,8 +151,8 @@ namespace OpenSim.Services.Connectors
99 AssetBase asset = null; 151 AssetBase asset = null;
100 if (m_Cache != null) 152 if (m_Cache != null)
101 asset = m_Cache.Get(id); 153 asset = m_Cache.Get(id);
102 154
103 if (asset == null) 155 if (asset == null || asset.Data == null || asset.Data.Length == 0)
104 { 156 {
105 asset = SynchronousRestObjectRequester. 157 asset = SynchronousRestObjectRequester.
106 MakeRequest<int, AssetBase>("GET", uri, 0); 158 MakeRequest<int, AssetBase>("GET", uri, 0);
@@ -177,7 +229,7 @@ namespace OpenSim.Services.Connectors
177 if (m_Cache != null) 229 if (m_Cache != null)
178 asset = m_Cache.Get(id); 230 asset = m_Cache.Get(id);
179 231
180 if (asset == null) 232 if (asset == null || asset.Data == null || asset.Data.Length == 0)
181 { 233 {
182 bool result = false; 234 bool result = false;
183 235
@@ -204,11 +256,10 @@ namespace OpenSim.Services.Connectors
204 256
205 public string Store(AssetBase asset) 257 public string Store(AssetBase asset)
206 { 258 {
259 if (m_Cache != null)
260 m_Cache.Cache(asset);
207 if (asset.Temporary || asset.Local) 261 if (asset.Temporary || asset.Local)
208 { 262 {
209 if (m_Cache != null)
210 m_Cache.Cache(asset);
211
212 return asset.ID; 263 return asset.ID;
213 } 264 }
214 265
@@ -218,24 +269,57 @@ namespace OpenSim.Services.Connectors
218 try 269 try
219 { 270 {
220 newID = SynchronousRestObjectRequester. 271 newID = SynchronousRestObjectRequester.
221 MakeRequest<AssetBase, string>("POST", uri, asset); 272 MakeRequest<AssetBase, string>("POST", uri, asset, 25);
273 if (newID == null || newID == "")
274 {
275 newID = UUID.Zero.ToString();
276 }
222 } 277 }
223 catch (Exception e) 278 catch (Exception e)
224 { 279 {
225 m_log.WarnFormat("[ASSET CONNECTOR]: Unable to send asset {0} to asset server. Reason: {1}", asset.ID, e.Message); 280 newID = UUID.Zero.ToString();
226 } 281 }
227 282
228 if (newID != String.Empty) 283 if (newID == UUID.Zero.ToString())
229 { 284 {
230 // Placing this here, so that this work with old asset servers that don't send any reply back 285 //The asset upload failed, put it in a queue for later
231 // SynchronousRestObjectRequester returns somethins that is not an empty string 286 asset.UploadAttempts++;
232 if (newID != null) 287 if (asset.UploadAttempts > 30)
233 asset.ID = newID; 288 {
234 289 //By this stage we've been in the queue for a good few hours;
235 if (m_Cache != null) 290 //We're going to drop the asset.
236 m_Cache.Cache(asset); 291 m_log.ErrorFormat("[Assets] Dropping asset {0} - Upload has been in the queue for too long.", asset.ID.ToString());
292 }
293 else
294 {
295 if (!m_retryQueue.ContainsKey(asset.UploadAttempts))
296 {
297 m_retryQueue.Add(asset.UploadAttempts, new List<AssetBase>());
298 }
299 List<AssetBase> m_queue = m_retryQueue[asset.UploadAttempts];
300 m_queue.Add(asset);
301 m_log.WarnFormat("[Assets] Upload failed: {0} - Requeuing asset for another run.", asset.ID.ToString());
302 m_retryTimer.Start();
303 }
304 }
305 else
306 {
307 if (asset.UploadAttempts > 0)
308 {
309 m_log.InfoFormat("[Assets] Upload of {0} succeeded after {1} failed attempts", asset.ID.ToString(), asset.UploadAttempts.ToString());
310 }
311 if (newID != String.Empty)
312 {
313 // Placing this here, so that this work with old asset servers that don't send any reply back
314 // SynchronousRestObjectRequester returns somethins that is not an empty string
315 if (newID != null)
316 asset.ID = newID;
317
318 if (m_Cache != null)
319 m_Cache.Cache(asset);
320 }
237 } 321 }
238 return newID; 322 return asset.ID;
239 } 323 }
240 324
241 public bool UpdateContent(string id, byte[] data) 325 public bool UpdateContent(string id, byte[] data)
diff --git a/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs
index 8ab323a..1aa3282 100644
--- a/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs
@@ -158,17 +158,10 @@ 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 c.DownloadFile(imageURL, filename);
164 if (!File.Exists(filename))
165 {
166 m_log.DebugFormat("[GATEKEEPER SERVICE CONNECTOR]: downloading...");
167 c.DownloadFile(imageURL, filename);
168 }
169 else
170 m_log.DebugFormat("[GATEKEEPER SERVICE CONNECTOR]: using cached image");
171
172 bitmap = new Bitmap(filename); 165 bitmap = new Bitmap(filename);
173 //m_log.Debug("Size: " + m.PhysicalDimension.Height + "-" + m.PhysicalDimension.Width); 166 //m_log.Debug("Size: " + m.PhysicalDimension.Height + "-" + m.PhysicalDimension.Width);
174 byte[] imageData = OpenJPEG.EncodeFromImage(bitmap, true); 167 byte[] imageData = OpenJPEG.EncodeFromImage(bitmap, true);
@@ -179,11 +172,10 @@ namespace OpenSim.Services.Connectors.Hypergrid
179 172
180 ass.Data = imageData; 173 ass.Data = imageData;
181 174
182 mapTile = ass.FullID;
183
184 // finally
185 m_AssetService.Store(ass); 175 m_AssetService.Store(ass);
186 176
177 // finally
178 mapTile = ass.FullID;
187 } 179 }
188 catch // LEGIT: Catching problems caused by OpenJPEG p/invoke 180 catch // LEGIT: Catching problems caused by OpenJPEG p/invoke
189 { 181 {
diff --git a/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs
index c40a347..7ddcfa6 100644
--- a/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs
@@ -60,9 +60,7 @@ namespace OpenSim.Services.Connectors.Hypergrid
60 { 60 {
61 Uri m_Uri = new Uri(m_ServerURL); 61 Uri m_Uri = new Uri(m_ServerURL);
62 IPAddress ip = Util.GetHostFromDNS(m_Uri.Host); 62 IPAddress ip = Util.GetHostFromDNS(m_Uri.Host);
63 m_ServerURL = m_ServerURL.Replace(m_Uri.Host, ip.ToString()); 63 m_ServerURL = m_ServerURL.Replace(m_Uri.Host, ip.ToString()); ;
64 if (!m_ServerURL.EndsWith("/"))
65 m_ServerURL += "/";
66 } 64 }
67 catch (Exception e) 65 catch (Exception e)
68 { 66 {
@@ -89,8 +87,6 @@ namespace OpenSim.Services.Connectors.Hypergrid
89 throw new Exception("UserAgent connector init error"); 87 throw new Exception("UserAgent connector init error");
90 } 88 }
91 m_ServerURL = serviceURI; 89 m_ServerURL = serviceURI;
92 if (!m_ServerURL.EndsWith("/"))
93 m_ServerURL += "/";
94 90
95 m_log.DebugFormat("[USER AGENT CONNECTOR]: UserAgentServiceConnector started for {0}", m_ServerURL); 91 m_log.DebugFormat("[USER AGENT CONNECTOR]: UserAgentServiceConnector started for {0}", m_ServerURL);
96 } 92 }
diff --git a/OpenSim/Services/Connectors/Land/LandServiceConnector.cs b/OpenSim/Services/Connectors/Land/LandServiceConnector.cs
index 252f7a1..ba39c99 100644
--- a/OpenSim/Services/Connectors/Land/LandServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Land/LandServiceConnector.cs
@@ -131,4 +131,4 @@ namespace OpenSim.Services.Connectors
131 return landData; 131 return landData;
132 } 132 }
133 } 133 }
134} \ No newline at end of file 134}
diff --git a/OpenSim/Services/Connectors/Presence/PresenceServiceConnector.cs b/OpenSim/Services/Connectors/Presence/PresenceServiceConnector.cs
index 41ebeaf..f1c99ce 100644
--- a/OpenSim/Services/Connectors/Presence/PresenceServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Presence/PresenceServiceConnector.cs
@@ -300,6 +300,17 @@ namespace OpenSim.Services.Connectors
300 { 300 {
301 pinfo = new PresenceInfo((Dictionary<string, object>)replyData["result"]); 301 pinfo = new PresenceInfo((Dictionary<string, object>)replyData["result"]);
302 } 302 }
303 else
304 {
305 if (replyData["result"].ToString() == "null")
306 return null;
307
308 m_log.DebugFormat("[PRESENCE CONNECTOR]: Invalid reply (result not dictionary) received from presence server when querying for sessionID {0}", sessionID.ToString());
309 }
310 }
311 else
312 {
313 m_log.DebugFormat("[PRESENCE CONNECTOR]: Invalid reply received from presence server when querying for sessionID {0}", sessionID.ToString());
303 } 314 }
304 315
305 return pinfo; 316 return pinfo;
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianGridMaptileModule.cs b/OpenSim/Services/Connectors/SimianGrid/SimianGridMaptileModule.cs
deleted file mode 100644
index dd8fe2b..0000000
--- a/OpenSim/Services/Connectors/SimianGrid/SimianGridMaptileModule.cs
+++ /dev/null
@@ -1,261 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.Reflection;
31using System.Net;
32using System.IO;
33using System.Timers;
34using System.Drawing;
35using System.Drawing.Imaging;
36
37using log4net;
38using Mono.Addins;
39using Nini.Config;
40using OpenSim.Framework;
41using OpenSim.Region.Framework.Interfaces;
42using OpenSim.Region.Framework.Scenes;
43using OpenMetaverse;
44using OpenMetaverse.StructuredData;
45
46namespace OpenSim.Region.OptionalModules.Simian
47{
48 /// <summary>
49 /// </summary>
50 /// <remarks>
51 /// </remarks>
52
53 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "SimianGridMaptile")]
54 public class SimianGridMaptile : ISharedRegionModule
55 {
56 private static readonly ILog m_log =
57 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
58
59 private bool m_enabled = false;
60 private string m_serverUrl = String.Empty;
61 private Dictionary<UUID, Scene> m_scenes = new Dictionary<UUID, Scene>();
62
63 private int m_refreshtime = 0;
64 private int m_lastrefresh = 0;
65 private System.Timers.Timer m_refreshTimer = new System.Timers.Timer();
66
67 #region ISharedRegionModule
68
69 public Type ReplaceableInterface { get { return null; } }
70 public string Name { get { return "SimianGridMaptile"; } }
71 public void RegionLoaded(Scene scene) { }
72 public void Close() { }
73
74 ///<summary>
75 ///
76 ///</summary>
77 public void Initialise(IConfigSource source)
78 {
79 IConfig config = source.Configs["SimianGridMaptiles"];
80 if (config == null)
81 return;
82
83 if (! config.GetBoolean("Enabled", false))
84 return;
85
86 m_serverUrl = config.GetString("MaptileURL");
87 if (String.IsNullOrEmpty(m_serverUrl))
88 return;
89
90 m_refreshtime = Convert.ToInt32(config.GetString("RefreshTime"));
91 if (m_refreshtime <= 0)
92 return;
93
94 m_log.InfoFormat("[SIMIAN MAPTILE] enabled with refresh timeout {0} and URL {1}",
95 m_refreshtime,m_serverUrl);
96
97 m_enabled = true;
98 }
99
100 ///<summary>
101 ///
102 ///</summary>
103 public void PostInitialise()
104 {
105 if (m_enabled)
106 {
107 m_refreshTimer.Enabled = true;
108 m_refreshTimer.AutoReset = true;
109 m_refreshTimer.Interval = 5 * 60 * 1000; // every 5 minutes
110 m_refreshTimer.Elapsed += new ElapsedEventHandler(HandleMaptileRefresh);
111 }
112 }
113
114
115 ///<summary>
116 ///
117 ///</summary>
118 public void AddRegion(Scene scene)
119 {
120 if (! m_enabled)
121 return;
122
123 // Every shared region module has to maintain an indepedent list of
124 // currently running regions
125 lock (m_scenes)
126 m_scenes[scene.RegionInfo.RegionID] = scene;
127 }
128
129 ///<summary>
130 ///
131 ///</summary>
132 public void RemoveRegion(Scene scene)
133 {
134 if (! m_enabled)
135 return;
136
137 lock (m_scenes)
138 m_scenes.Remove(scene.RegionInfo.RegionID);
139 }
140
141 #endregion ISharedRegionModule
142
143 ///<summary>
144 ///
145 ///</summary>
146 private void HandleMaptileRefresh(object sender, EventArgs ea)
147 {
148 // this approach is a bit convoluted becase we want to wait for the
149 // first upload to happen on startup but after all the objects are
150 // loaded and initialized
151 if (m_lastrefresh > 0 && Util.EnvironmentTickCountSubtract(m_lastrefresh) < m_refreshtime)
152 return;
153
154 m_log.DebugFormat("[SIMIAN MAPTILE] map refresh fired");
155 lock (m_scenes)
156 {
157 foreach (IScene scene in m_scenes.Values)
158 {
159 try
160 {
161 UploadMapTile(scene);
162 }
163 catch (Exception ex)
164 {
165 m_log.WarnFormat("[SIMIAN MAPTILE] something bad happened {0}",ex.Message);
166 }
167 }
168 }
169
170 m_lastrefresh = Util.EnvironmentTickCount();
171 }
172
173 ///<summary>
174 ///
175 ///</summary>
176 private void UploadMapTile(IScene scene)
177 {
178 m_log.DebugFormat("[SIMIAN MAPTILE]: upload maptile for {0}",scene.RegionInfo.RegionName);
179
180 // Create a PNG map tile and upload it to the AddMapTile API
181 byte[] pngData = Utils.EmptyBytes;
182 IMapImageGenerator tileGenerator = scene.RequestModuleInterface<IMapImageGenerator>();
183 if (tileGenerator == null)
184 {
185 m_log.Warn("[SIMIAN MAPTILE]: Cannot upload PNG map tile without an ImageGenerator");
186 return;
187 }
188
189 using (Image mapTile = tileGenerator.CreateMapTile())
190 {
191 using (MemoryStream stream = new MemoryStream())
192 {
193 mapTile.Save(stream, ImageFormat.Png);
194 pngData = stream.ToArray();
195 }
196 }
197
198 List<MultipartForm.Element> postParameters = new List<MultipartForm.Element>()
199 {
200 new MultipartForm.Parameter("X", scene.RegionInfo.RegionLocX.ToString()),
201 new MultipartForm.Parameter("Y", scene.RegionInfo.RegionLocY.ToString()),
202 new MultipartForm.File("Tile", "tile.png", "image/png", pngData)
203 };
204
205 string errorMessage = null;
206 int tickstart = Util.EnvironmentTickCount();
207
208 // Make the remote storage request
209 try
210 {
211 HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(m_serverUrl);
212 request.Timeout = 20000;
213 request.ReadWriteTimeout = 5000;
214
215 using (HttpWebResponse response = MultipartForm.Post(request, postParameters))
216 {
217 using (Stream responseStream = response.GetResponseStream())
218 {
219 string responseStr = responseStream.GetStreamString();
220 OSD responseOSD = OSDParser.Deserialize(responseStr);
221 if (responseOSD.Type == OSDType.Map)
222 {
223 OSDMap responseMap = (OSDMap)responseOSD;
224 if (responseMap["Success"].AsBoolean())
225 return;
226
227 errorMessage = "Upload failed: " + responseMap["Message"].AsString();
228 }
229 else
230 {
231 errorMessage = "Response format was invalid:\n" + responseStr;
232 }
233 }
234 }
235 }
236 catch (WebException we)
237 {
238 errorMessage = we.Message;
239 if (we.Status == WebExceptionStatus.ProtocolError)
240 {
241 HttpWebResponse webResponse = (HttpWebResponse)we.Response;
242 errorMessage = String.Format("[{0}] {1}",
243 webResponse.StatusCode,webResponse.StatusDescription);
244 }
245 }
246 catch (Exception ex)
247 {
248 errorMessage = ex.Message;
249 }
250 finally
251 {
252 // This just dumps a warning for any operation that takes more than 100 ms
253 int tickdiff = Util.EnvironmentTickCountSubtract(tickstart);
254 m_log.DebugFormat("[SIMIAN MAPTILE]: map tile uploaded in {0}ms",tickdiff);
255 }
256
257 m_log.WarnFormat("[SIMIAN MAPTILE]: Failed to store {0} byte tile for {1}: {2}",
258 pngData.Length, scene.RegionInfo.RegionName, errorMessage);
259 }
260 }
261} \ No newline at end of file
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs
index 918544f..feea196 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) },
@@ -371,6 +382,83 @@ namespace OpenSim.Services.Connectors.SimianGrid
371 382
372 #endregion IGridService 383 #endregion IGridService
373 384
385 private void UploadMapTile(IScene scene)
386 {
387 string errorMessage = null;
388
389 // Create a PNG map tile and upload it to the AddMapTile API
390 byte[] pngData = Utils.EmptyBytes;
391 IMapImageGenerator tileGenerator = scene.RequestModuleInterface<IMapImageGenerator>();
392 if (tileGenerator == null)
393 {
394 m_log.Warn("[SIMIAN GRID CONNECTOR]: Cannot upload PNG map tile without an IMapImageGenerator");
395 return;
396 }
397
398 using (Image mapTile = tileGenerator.CreateMapTile())
399 {
400 using (MemoryStream stream = new MemoryStream())
401 {
402 mapTile.Save(stream, ImageFormat.Png);
403 pngData = stream.ToArray();
404 }
405 }
406
407 List<MultipartForm.Element> postParameters = new List<MultipartForm.Element>()
408 {
409 new MultipartForm.Parameter("X", scene.RegionInfo.RegionLocX.ToString()),
410 new MultipartForm.Parameter("Y", scene.RegionInfo.RegionLocY.ToString()),
411 new MultipartForm.File("Tile", "tile.png", "image/png", pngData)
412 };
413
414 // Make the remote storage request
415 try
416 {
417 HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(m_ServerURI);
418
419 HttpWebResponse response = MultipartForm.Post(request, postParameters);
420 using (Stream responseStream = response.GetResponseStream())
421 {
422 string responseStr = null;
423
424 try
425 {
426 responseStr = responseStream.GetStreamString();
427 OSD responseOSD = OSDParser.Deserialize(responseStr);
428 if (responseOSD.Type == OSDType.Map)
429 {
430 OSDMap responseMap = (OSDMap)responseOSD;
431 if (responseMap["Success"].AsBoolean())
432 m_log.Info("[SIMIAN GRID CONNECTOR]: Uploaded " + pngData.Length + " byte PNG map tile to AddMapTile");
433 else
434 errorMessage = "Upload failed: " + responseMap["Message"].AsString();
435 }
436 else
437 {
438 errorMessage = "Response format was invalid:\n" + responseStr;
439 }
440 }
441 catch (Exception ex)
442 {
443 if (!String.IsNullOrEmpty(responseStr))
444 errorMessage = "Failed to parse the response:\n" + responseStr;
445 else
446 errorMessage = "Failed to retrieve the response: " + ex.Message;
447 }
448 }
449 }
450 catch (WebException ex)
451 {
452 errorMessage = ex.Message;
453 }
454
455 if (!String.IsNullOrEmpty(errorMessage))
456 {
457 m_log.WarnFormat("[SIMIAN GRID CONNECTOR]: Failed to store {0} byte PNG map tile for {1}: {2}",
458 pngData.Length, scene.RegionInfo.RegionName, errorMessage.Replace('\n', ' '));
459 }
460 }
461
374 private GridRegion GetNearestRegion(Vector3d position, bool onlyEnabled) 462 private GridRegion GetNearestRegion(Vector3d position, bool onlyEnabled)
375 { 463 {
376 NameValueCollection requestArgs = new NameValueCollection 464 NameValueCollection requestArgs = new NameValueCollection
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianUserAccountServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianUserAccountServiceConnector.cs
index 91e2976..801b424 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/SimulationServiceConnector.cs b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs
index 143c296..039d9e5 100644
--- a/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs
@@ -247,9 +247,7 @@ namespace OpenSim.Services.Connectors.Simulation
247 return true; 247 return true;
248 } 248 }
249 249
250 /// <summary> 250 private bool CloseAgent(GridRegion destination, UUID id, bool ChildOnly)
251 /// </summary>
252 public bool CloseAgent(GridRegion destination, UUID id)
253 { 251 {
254 // m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: CloseAgent start"); 252 // m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: CloseAgent start");
255 253
@@ -267,6 +265,16 @@ namespace OpenSim.Services.Connectors.Simulation
267 return true; 265 return true;
268 } 266 }
269 267
268 public bool CloseChildAgent(GridRegion destination, UUID id)
269 {
270 return CloseAgent(destination, id, true);
271 }
272
273 public bool CloseAgent(GridRegion destination, UUID id)
274 {
275 return CloseAgent(destination, id, false);
276 }
277
270 #endregion Agents 278 #endregion Agents
271 279
272 #region Objects 280 #region Objects
diff --git a/OpenSim/Services/Connectors/UserAccounts/UserAccountServiceConnector.cs b/OpenSim/Services/Connectors/UserAccounts/UserAccountServiceConnector.cs
index 2a5df83..205a4aa 100644
--- a/OpenSim/Services/Connectors/UserAccounts/UserAccountServiceConnector.cs
+++ b/OpenSim/Services/Connectors/UserAccounts/UserAccountServiceConnector.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/GridService/HypergridLinker.cs b/OpenSim/Services/GridService/HypergridLinker.cs
index 588c1dd..c02c813 100644
--- a/OpenSim/Services/GridService/HypergridLinker.cs
+++ b/OpenSim/Services/GridService/HypergridLinker.cs
@@ -162,7 +162,6 @@ namespace OpenSim.Services.GridService
162 162
163 #region Link Region 163 #region Link Region
164 164
165 // from map search
166 public GridRegion LinkRegion(UUID scopeID, string regionDescriptor) 165 public GridRegion LinkRegion(UUID scopeID, string regionDescriptor)
167 { 166 {
168 string reason = string.Empty; 167 string reason = string.Empty;
@@ -172,7 +171,7 @@ namespace OpenSim.Services.GridService
172 171
173 private static Random random = new Random(); 172 private static Random random = new Random();
174 173
175 // From the command line link-region (obsolete) and the map 174 // From the command line link-region
176 public GridRegion TryLinkRegionToCoords(UUID scopeID, string mapName, int xloc, int yloc, out string reason) 175 public GridRegion TryLinkRegionToCoords(UUID scopeID, string mapName, int xloc, int yloc, out string reason)
177 { 176 {
178 return TryLinkRegionToCoords(scopeID, mapName, xloc, yloc, UUID.Zero, out reason); 177 return TryLinkRegionToCoords(scopeID, mapName, xloc, yloc, UUID.Zero, out reason);
@@ -181,48 +180,45 @@ namespace OpenSim.Services.GridService
181 public GridRegion TryLinkRegionToCoords(UUID scopeID, string mapName, int xloc, int yloc, UUID ownerID, out string reason) 180 public GridRegion TryLinkRegionToCoords(UUID scopeID, string mapName, int xloc, int yloc, UUID ownerID, out string reason)
182 { 181 {
183 reason = string.Empty; 182 reason = string.Empty;
184 GridRegion regInfo = null; 183 string host = "127.0.0.1";
185 184 string portstr;
186 if (!mapName.StartsWith("http")) 185 string regionName = "";
186 uint port = 0;
187 string[] parts = mapName.Split(new char[] { ':' });
188 if (parts.Length >= 1)
187 { 189 {
188 string host = "127.0.0.1"; 190 host = parts[0];
189 string portstr;
190 string regionName = "";
191 uint port = 0;
192 string[] parts = mapName.Split(new char[] { ':' });
193 if (parts.Length >= 1)
194 {
195 host = parts[0];
196 }
197 if (parts.Length >= 2)
198 {
199 portstr = parts[1];
200 //m_log.Debug("-- port = " + portstr);
201 if (!UInt32.TryParse(portstr, out port))
202 regionName = parts[1];
203 }
204 // always take the last one
205 if (parts.Length >= 3)
206 {
207 regionName = parts[2];
208 }
209
210
211 bool success = TryCreateLink(scopeID, xloc, yloc, regionName, port, host, ownerID, out regInfo, out reason);
212 if (success)
213 {
214 regInfo.RegionName = mapName;
215 return regInfo;
216 }
217 } 191 }
218 else 192 if (parts.Length >= 2)
219 { 193 {
220 string[] parts = mapName.Split(new char[] {' '}); 194 portstr = parts[1];
221 string regionName = String.Empty; 195 //m_log.Debug("-- port = " + portstr);
222 if (parts.Length > 1) 196 if (!UInt32.TryParse(portstr, out port))
223 regionName = parts[1]; 197 regionName = parts[1];
224 if (TryCreateLink(scopeID, xloc, yloc, regionName, 0, null, parts[0], ownerID, out regInfo, out reason)) 198 }
225 return regInfo; 199 // always take the last one
200 if (parts.Length >= 3)
201 {
202 regionName = parts[2];
203 }
204
205 //// Sanity check.
206 //try
207 //{
208 // Util.GetHostFromDNS(host);
209 //}
210 //catch
211 //{
212 // reason = "Malformed hostname";
213 // return null;
214 //}
215
216 GridRegion regInfo;
217 bool success = TryCreateLink(scopeID, xloc, yloc, regionName, port, host, ownerID, out regInfo, out reason);
218 if (success)
219 {
220 regInfo.RegionName = mapName;
221 return regInfo;
226 } 222 }
227 223
228 return null; 224 return null;
@@ -235,7 +231,7 @@ namespace OpenSim.Services.GridService
235 231
236 public bool TryCreateLink(UUID scopeID, int xloc, int yloc, string remoteRegionName, uint externalPort, string externalHostName, string serverURI, UUID ownerID, out GridRegion regInfo, out string reason) 232 public bool TryCreateLink(UUID scopeID, int xloc, int yloc, string remoteRegionName, uint externalPort, string externalHostName, string serverURI, UUID ownerID, out GridRegion regInfo, out string reason)
237 { 233 {
238 m_log.DebugFormat("[HYPERGRID LINKER]: Link to {0} {1}, in {2}-{3}", 234 m_log.DebugFormat("[HYPERGRID LINKER]: Link to {0}:{1}, in {2}-{3}",
239 ((serverURI == null) ? (externalHostName + ":" + externalPort) : serverURI), 235 ((serverURI == null) ? (externalHostName + ":" + externalPort) : serverURI),
240 remoteRegionName, xloc / Constants.RegionSize, yloc / Constants.RegionSize); 236 remoteRegionName, xloc / Constants.RegionSize, yloc / Constants.RegionSize);
241 237
@@ -328,7 +324,7 @@ namespace OpenSim.Services.GridService
328 regInfo.TerrainImage = m_GatekeeperConnector.GetMapImage(regionID, imageURL, m_MapTileDirectory); 324 regInfo.TerrainImage = m_GatekeeperConnector.GetMapImage(regionID, imageURL, m_MapTileDirectory);
329 325
330 AddHyperlinkRegion(regInfo, handle); 326 AddHyperlinkRegion(regInfo, handle);
331 m_log.InfoFormat("[HYPERGRID LINKER]: Successfully linked to region {0} with image {1}", regInfo.RegionName, regInfo.TerrainImage); 327 m_log.Info("[HYPERGRID LINKER]: Successfully linked to region_uuid " + regInfo.RegionID);
332 return true; 328 return true;
333 } 329 }
334 330
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 3ead180..12dda48 100644
--- a/OpenSim/Services/HypergridService/UserAgentService.cs
+++ b/OpenSim/Services/HypergridService/UserAgentService.cs
@@ -155,7 +155,7 @@ namespace OpenSim.Services.HypergridService
155 string myExternalIP = string.Empty; 155 string myExternalIP = string.Empty;
156 string gridName = gatekeeper.ServerURI; 156 string gridName = gatekeeper.ServerURI;
157 157
158 m_log.DebugFormat("[USER AGENT SERVICE]: this grid: {0}, desired grid: {1}", m_GridName, gridName); 158 m_log.DebugFormat("[USER AGENT SERVICE]: m_grid - {0}, gn - {1}", m_GridName, gridName);
159 159
160 if (m_GridName == gridName) 160 if (m_GridName == gridName)
161 success = m_GatekeeperService.LoginAgent(agentCircuit, finalDestination, out reason); 161 success = m_GatekeeperService.LoginAgent(agentCircuit, finalDestination, out reason);
@@ -266,13 +266,11 @@ namespace OpenSim.Services.HypergridService
266 266
267 if (m_TravelingAgents.ContainsKey(sessionID)) 267 if (m_TravelingAgents.ContainsKey(sessionID))
268 { 268 {
269 bool result = m_TravelingAgents[sessionID].ClientIPAddress == reportedIP || 269 m_log.DebugFormat("[USER AGENT SERVICE]: Comparing with login IP {0} and MyIP {1}",
270 m_TravelingAgents[sessionID].MyIpAddress == reportedIP; // NATed 270 m_TravelingAgents[sessionID].ClientIPAddress, m_TravelingAgents[sessionID].MyIpAddress);
271
272 m_log.DebugFormat("[USER AGENT SERVICE]: Comparing {0} with login IP {1} and MyIP {1}; result is {3}",
273 reportedIP, m_TravelingAgents[sessionID].ClientIPAddress, m_TravelingAgents[sessionID].MyIpAddress, result);
274 271
275 return result; 272 return m_TravelingAgents[sessionID].ClientIPAddress == reportedIP ||
273 m_TravelingAgents[sessionID].MyIpAddress == reportedIP; // NATed
276 } 274 }
277 275
278 return false; 276 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/IGridService.cs b/OpenSim/Services/Interfaces/IGridService.cs
index a34f0be..f569fc8 100644
--- a/OpenSim/Services/Interfaces/IGridService.cs
+++ b/OpenSim/Services/Interfaces/IGridService.cs
@@ -300,9 +300,13 @@ namespace OpenSim.Services.Interfaces
300 } 300 }
301 catch (SocketException e) 301 catch (SocketException e)
302 { 302 {
303 throw new Exception( 303 /*throw new Exception(
304 "Unable to resolve local hostname " + m_externalHostName + " innerException of type '" + 304 "Unable to resolve local hostname " + m_externalHostName + " innerException of type '" +
305 e + "' attached to this exception", e); 305 e + "' attached to this exception", e);*/
306 // Don't throw a fatal exception here, instead, return Null and handle it in the caller.
307 // Reason is, on systems such as OSgrid it has occured that known hostnames stop
308 // resolving and thus make surrounding regions crash out with this exception.
309 return null;
306 } 310 }
307 311
308 return new IPEndPoint(ia, m_internalEndPoint.Port); 312 return new IPEndPoint(ia, m_internalEndPoint.Port);
@@ -360,6 +364,12 @@ namespace OpenSim.Services.Interfaces
360 if (kvp.ContainsKey("regionName")) 364 if (kvp.ContainsKey("regionName"))
361 RegionName = (string)kvp["regionName"]; 365 RegionName = (string)kvp["regionName"];
362 366
367 if (kvp.ContainsKey("access"))
368 {
369 byte access = Convert.ToByte((string)kvp["access"]);
370 Maturity = (int)Util.ConvertAccessLevelToMaturity(access);
371 }
372
363 if (kvp.ContainsKey("serverIP")) 373 if (kvp.ContainsKey("serverIP"))
364 { 374 {
365 //int port = 0; 375 //int port = 0;
diff --git a/OpenSim/Services/Interfaces/ISimulationService.cs b/OpenSim/Services/Interfaces/ISimulationService.cs
index 12e8982..1f8474c 100644
--- a/OpenSim/Services/Interfaces/ISimulationService.cs
+++ b/OpenSim/Services/Interfaces/ISimulationService.cs
@@ -73,6 +73,14 @@ namespace OpenSim.Services.Interfaces
73 bool ReleaseAgent(UUID originRegion, UUID id, string uri); 73 bool ReleaseAgent(UUID originRegion, UUID id, string uri);
74 74
75 /// <summary> 75 /// <summary>
76 /// Close child agent.
77 /// </summary>
78 /// <param name="regionHandle"></param>
79 /// <param name="id"></param>
80 /// <returns></returns>
81 bool CloseChildAgent(GridRegion destination, UUID id);
82
83 /// <summary>
76 /// Close agent. 84 /// Close agent.
77 /// </summary> 85 /// </summary>
78 /// <param name="regionHandle"></param> 86 /// <param name="regionHandle"></param>
diff --git a/OpenSim/Services/Interfaces/IUserAccountService.cs b/OpenSim/Services/Interfaces/IUserAccountService.cs
index 9c992e0..a91aa0f 100644
--- a/OpenSim/Services/Interfaces/IUserAccountService.cs
+++ b/OpenSim/Services/Interfaces/IUserAccountService.cs
@@ -63,6 +63,7 @@ namespace OpenSim.Services.Interfaces
63 public int UserLevel; 63 public int UserLevel;
64 public int UserFlags; 64 public int UserFlags;
65 public string UserTitle; 65 public string UserTitle;
66 public string UserCountry;
66 67
67 public Dictionary<string, object> ServiceURLs; 68 public Dictionary<string, object> ServiceURLs;
68 69
@@ -91,6 +92,8 @@ namespace OpenSim.Services.Interfaces
91 UserFlags = Convert.ToInt32(kvp["UserFlags"].ToString()); 92 UserFlags = Convert.ToInt32(kvp["UserFlags"].ToString());
92 if (kvp.ContainsKey("UserTitle")) 93 if (kvp.ContainsKey("UserTitle"))
93 UserTitle = kvp["UserTitle"].ToString(); 94 UserTitle = kvp["UserTitle"].ToString();
95 if (kvp.ContainsKey("UserCountry"))
96 UserCountry = kvp["UserCountry"].ToString();
94 97
95 if (kvp.ContainsKey("Created")) 98 if (kvp.ContainsKey("Created"))
96 Created = Convert.ToInt32(kvp["Created"].ToString()); 99 Created = Convert.ToInt32(kvp["Created"].ToString());
@@ -124,6 +127,7 @@ namespace OpenSim.Services.Interfaces
124 result["UserLevel"] = UserLevel.ToString(); 127 result["UserLevel"] = UserLevel.ToString();
125 result["UserFlags"] = UserFlags.ToString(); 128 result["UserFlags"] = UserFlags.ToString();
126 result["UserTitle"] = UserTitle; 129 result["UserTitle"] = UserTitle;
130 result["UserCountry"] = UserCountry;
127 131
128 string str = string.Empty; 132 string str = string.Empty;
129 foreach (KeyValuePair<string, object> kvp in ServiceURLs) 133 foreach (KeyValuePair<string, object> kvp in ServiceURLs)
@@ -150,6 +154,7 @@ namespace OpenSim.Services.Interfaces
150 /// <param name="query"></param> 154 /// <param name="query"></param>
151 /// <returns></returns> 155 /// <returns></returns>
152 List<UserAccount> GetUserAccounts(UUID scopeID, string query); 156 List<UserAccount> GetUserAccounts(UUID scopeID, string query);
157 List<UserAccount> GetUserAccountsWhere(UUID scopeID, string where);
153 158
154 /// <summary> 159 /// <summary>
155 /// Store the data given, wich replaces the stored data, therefore must be complete. 160 /// 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 ebd6f7c..2ffcaf7 100644
--- a/OpenSim/Services/LLLoginService/LLLoginResponse.cs
+++ b/OpenSim/Services/LLLoginService/LLLoginResponse.cs
@@ -56,6 +56,7 @@ namespace OpenSim.Services.LLLoginService
56 public static LLFailedLoginResponse InventoryProblem; 56 public static LLFailedLoginResponse InventoryProblem;
57 public static LLFailedLoginResponse DeadRegionProblem; 57 public static LLFailedLoginResponse DeadRegionProblem;
58 public static LLFailedLoginResponse LoginBlockedProblem; 58 public static LLFailedLoginResponse LoginBlockedProblem;
59 public static LLFailedLoginResponse UnverifiedAccountProblem;
59 public static LLFailedLoginResponse AlreadyLoggedInProblem; 60 public static LLFailedLoginResponse AlreadyLoggedInProblem;
60 public static LLFailedLoginResponse InternalError; 61 public static LLFailedLoginResponse InternalError;
61 62
@@ -76,6 +77,10 @@ namespace OpenSim.Services.LLLoginService
76 LoginBlockedProblem = new LLFailedLoginResponse("presence", 77 LoginBlockedProblem = new LLFailedLoginResponse("presence",
77 "Logins are currently restricted. Please try again later.", 78 "Logins are currently restricted. Please try again later.",
78 "false"); 79 "false");
80 UnverifiedAccountProblem = new LLFailedLoginResponse("presence",
81 "Your account has not yet been verified. Please check " +
82 "your email and click the provided link.",
83 "false");
79 AlreadyLoggedInProblem = new LLFailedLoginResponse("presence", 84 AlreadyLoggedInProblem = new LLFailedLoginResponse("presence",
80 "You appear to be already logged in. " + 85 "You appear to be already logged in. " +
81 "If this is not the case please wait for your session to timeout. " + 86 "If this is not the case please wait for your session to timeout. " +
@@ -325,6 +330,7 @@ namespace OpenSim.Services.LLLoginService
325 private void FillOutRegionData(GridRegion destination) 330 private void FillOutRegionData(GridRegion destination)
326 { 331 {
327 IPEndPoint endPoint = destination.ExternalEndPoint; 332 IPEndPoint endPoint = destination.ExternalEndPoint;
333 if (endPoint == null) return;
328 SimAddress = endPoint.Address.ToString(); 334 SimAddress = endPoint.Address.ToString();
329 SimPort = (uint)endPoint.Port; 335 SimPort = (uint)endPoint.Port;
330 RegionX = (uint)destination.RegionLocX; 336 RegionX = (uint)destination.RegionLocX;
diff --git a/OpenSim/Services/LLLoginService/LLLoginService.cs b/OpenSim/Services/LLLoginService/LLLoginService.cs
index d364aa4..c6e6768 100644
--- a/OpenSim/Services/LLLoginService/LLLoginService.cs
+++ b/OpenSim/Services/LLLoginService/LLLoginService.cs
@@ -113,7 +113,8 @@ namespace OpenSim.Services.LLLoginService
113 Object[] args = new Object[] { config }; 113 Object[] args = new Object[] { config };
114 m_UserAccountService = ServerUtils.LoadPlugin<IUserAccountService>(accountService, args); 114 m_UserAccountService = ServerUtils.LoadPlugin<IUserAccountService>(accountService, args);
115 m_GridUserService = ServerUtils.LoadPlugin<IGridUserService>(gridUserService, args); 115 m_GridUserService = ServerUtils.LoadPlugin<IGridUserService>(gridUserService, args);
116 m_AuthenticationService = ServerUtils.LoadPlugin<IAuthenticationService>(authService, args); 116 Object[] authArgs = new Object[] { config, m_UserAccountService };
117 m_AuthenticationService = ServerUtils.LoadPlugin<IAuthenticationService>(authService, authArgs);
117 m_InventoryService = ServerUtils.LoadPlugin<IInventoryService>(invService, args); 118 m_InventoryService = ServerUtils.LoadPlugin<IInventoryService>(invService, args);
118 119
119 if (gridService != string.Empty) 120 if (gridService != string.Empty)
@@ -229,6 +230,12 @@ namespace OpenSim.Services.LLLoginService
229 return LLFailedLoginResponse.UserProblem; 230 return LLFailedLoginResponse.UserProblem;
230 } 231 }
231 232
233 if (account.UserLevel < 0)
234 {
235 m_log.InfoFormat("[LLOGIN SERVICE]: Login failed, reason: Unverified account");
236 return LLFailedLoginResponse.UnverifiedAccountProblem;
237 }
238
232 if (account.UserLevel < m_MinLoginLevel) 239 if (account.UserLevel < m_MinLoginLevel)
233 { 240 {
234 m_log.InfoFormat("[LLOGIN SERVICE]: Login failed, reason: login is blocked for user level {0}", account.UserLevel); 241 m_log.InfoFormat("[LLOGIN SERVICE]: Login failed, reason: login is blocked for user level {0}", account.UserLevel);
diff --git a/OpenSim/Services/UserAccountService/UserAccountService.cs b/OpenSim/Services/UserAccountService/UserAccountService.cs
index f376cf8..cbd6f35 100644
--- a/OpenSim/Services/UserAccountService/UserAccountService.cs
+++ b/OpenSim/Services/UserAccountService/UserAccountService.cs
@@ -148,6 +148,10 @@ namespace OpenSim.Services.UserAccountService
148 Int32.TryParse(d.Data["UserLevel"], out u.UserLevel); 148 Int32.TryParse(d.Data["UserLevel"], out u.UserLevel);
149 if (d.Data.ContainsKey("UserFlags") && d.Data["UserFlags"] != null) 149 if (d.Data.ContainsKey("UserFlags") && d.Data["UserFlags"] != null)
150 Int32.TryParse(d.Data["UserFlags"], out u.UserFlags); 150 Int32.TryParse(d.Data["UserFlags"], out u.UserFlags);
151 if (d.Data.ContainsKey("UserCountry") && d.Data["UserCountry"] != null)
152 u.UserCountry = d.Data["UserCountry"].ToString();
153 else
154 u.UserTitle = string.Empty;
151 155
152 if (d.Data.ContainsKey("ServiceURLs") && d.Data["ServiceURLs"] != null) 156 if (d.Data.ContainsKey("ServiceURLs") && d.Data["ServiceURLs"] != null)
153 { 157 {
@@ -282,6 +286,21 @@ namespace OpenSim.Services.UserAccountService
282 return ret; 286 return ret;
283 } 287 }
284 288
289 public List<UserAccount> GetUserAccountsWhere(UUID scopeID, string where)
290 {
291 UserAccountData[] d = m_Database.GetUsersWhere(scopeID, where);
292
293 if (d == null)
294 return new List<UserAccount>();
295
296 List<UserAccount> ret = new List<UserAccount>();
297
298 foreach (UserAccountData data in d)
299 ret.Add(MakeUserAccount(data));
300
301 return ret;
302 }
303
285 #endregion 304 #endregion
286 305
287 #region Console commands 306 #region Console commands