diff options
Diffstat (limited to 'OpenSim/Services')
17 files changed, 1459 insertions, 116 deletions
diff --git a/OpenSim/Services/AssetService/AssetService.cs b/OpenSim/Services/AssetService/AssetService.cs index 88a905c..ebfd47a 100644 --- a/OpenSim/Services/AssetService/AssetService.cs +++ b/OpenSim/Services/AssetService/AssetService.cs | |||
@@ -155,7 +155,7 @@ namespace OpenSim.Services.AssetService | |||
155 | AssetBase asset = Get(args[2]); | 155 | AssetBase asset = Get(args[2]); |
156 | 156 | ||
157 | if (asset == null || asset.Data.Length == 0) | 157 | if (asset == null || asset.Data.Length == 0) |
158 | { | 158 | { |
159 | MainConsole.Instance.Output("Asset not found"); | 159 | MainConsole.Instance.Output("Asset not found"); |
160 | return; | 160 | return; |
161 | } | 161 | } |
@@ -195,7 +195,7 @@ namespace OpenSim.Services.AssetService | |||
195 | AssetBase asset = Get(args[2]); | 195 | AssetBase asset = Get(args[2]); |
196 | 196 | ||
197 | if (asset == null || asset.Data.Length == 0) | 197 | if (asset == null || asset.Data.Length == 0) |
198 | { | 198 | { |
199 | MainConsole.Instance.Output("Asset not found"); | 199 | MainConsole.Instance.Output("Asset not found"); |
200 | return; | 200 | return; |
201 | } | 201 | } |
diff --git a/OpenSim/Services/AuthenticationService/AuthenticationServiceBase.cs b/OpenSim/Services/AuthenticationService/AuthenticationServiceBase.cs index 8904461..dcf090e 100644 --- a/OpenSim/Services/AuthenticationService/AuthenticationServiceBase.cs +++ b/OpenSim/Services/AuthenticationService/AuthenticationServiceBase.cs | |||
@@ -43,9 +43,9 @@ namespace OpenSim.Services.AuthenticationService | |||
43 | // | 43 | // |
44 | public class AuthenticationServiceBase : ServiceBase | 44 | public class AuthenticationServiceBase : ServiceBase |
45 | { | 45 | { |
46 | private static readonly ILog m_log = | 46 | // private static readonly ILog m_log = |
47 | LogManager.GetLogger( | 47 | // LogManager.GetLogger( |
48 | MethodBase.GetCurrentMethod().DeclaringType); | 48 | // MethodBase.GetCurrentMethod().DeclaringType); |
49 | 49 | ||
50 | protected IAuthenticationData m_Database; | 50 | protected IAuthenticationData m_Database; |
51 | 51 | ||
diff --git a/OpenSim/Services/AuthenticationService/PasswordAuthenticationService.cs b/OpenSim/Services/AuthenticationService/PasswordAuthenticationService.cs index 6c99b66..d65665a 100644 --- a/OpenSim/Services/AuthenticationService/PasswordAuthenticationService.cs +++ b/OpenSim/Services/AuthenticationService/PasswordAuthenticationService.cs | |||
@@ -47,9 +47,9 @@ namespace OpenSim.Services.AuthenticationService | |||
47 | public class PasswordAuthenticationService : | 47 | public class PasswordAuthenticationService : |
48 | AuthenticationServiceBase, IAuthenticationService | 48 | AuthenticationServiceBase, IAuthenticationService |
49 | { | 49 | { |
50 | private static readonly ILog m_log = | 50 | // private static readonly ILog m_log = |
51 | LogManager.GetLogger( | 51 | // LogManager.GetLogger( |
52 | MethodBase.GetCurrentMethod().DeclaringType); | 52 | // MethodBase.GetCurrentMethod().DeclaringType); |
53 | 53 | ||
54 | public PasswordAuthenticationService(IConfigSource config) : | 54 | public PasswordAuthenticationService(IConfigSource config) : |
55 | base(config) | 55 | base(config) |
diff --git a/OpenSim/Services/AuthenticationService/WebkeyAuthenticationService.cs b/OpenSim/Services/AuthenticationService/WebkeyAuthenticationService.cs index 8831c8a..d1a5b0f 100644 --- a/OpenSim/Services/AuthenticationService/WebkeyAuthenticationService.cs +++ b/OpenSim/Services/AuthenticationService/WebkeyAuthenticationService.cs | |||
@@ -43,9 +43,9 @@ namespace OpenSim.Services.AuthenticationService | |||
43 | public class WebkeyAuthenticationService : | 43 | public class WebkeyAuthenticationService : |
44 | AuthenticationServiceBase, IAuthenticationService | 44 | AuthenticationServiceBase, IAuthenticationService |
45 | { | 45 | { |
46 | private static readonly ILog m_log = | 46 | // private static readonly ILog m_log = |
47 | LogManager.GetLogger( | 47 | // LogManager.GetLogger( |
48 | MethodBase.GetCurrentMethod().DeclaringType); | 48 | // MethodBase.GetCurrentMethod().DeclaringType); |
49 | 49 | ||
50 | public WebkeyAuthenticationService(IConfigSource config) : | 50 | public WebkeyAuthenticationService(IConfigSource config) : |
51 | base(config) | 51 | base(config) |
diff --git a/OpenSim/Services/Connectors/Authentication/AuthenticationServiceConnector.cs b/OpenSim/Services/Connectors/Authentication/AuthenticationServiceConnector.cs new file mode 100644 index 0000000..50e817e --- /dev/null +++ b/OpenSim/Services/Connectors/Authentication/AuthenticationServiceConnector.cs | |||
@@ -0,0 +1,150 @@ | |||
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 | |||
28 | using log4net; | ||
29 | using System; | ||
30 | using System.Collections.Generic; | ||
31 | using System.IO; | ||
32 | using System.Reflection; | ||
33 | using Nini.Config; | ||
34 | using OpenSim.Framework; | ||
35 | using OpenSim.Framework.Communications; | ||
36 | using OpenSim.Framework.Servers.HttpServer; | ||
37 | using OpenSim.Services.Interfaces; | ||
38 | using OpenSim.Server.Base; | ||
39 | using OpenMetaverse; | ||
40 | |||
41 | namespace OpenSim.Services.Connectors | ||
42 | { | ||
43 | public class AuthenticationServicesConnector : IAuthenticationService | ||
44 | { | ||
45 | private static readonly ILog m_log = | ||
46 | LogManager.GetLogger( | ||
47 | MethodBase.GetCurrentMethod().DeclaringType); | ||
48 | |||
49 | private string m_ServerURI = String.Empty; | ||
50 | |||
51 | public AuthenticationServicesConnector() | ||
52 | { | ||
53 | } | ||
54 | |||
55 | public AuthenticationServicesConnector(string serverURI) | ||
56 | { | ||
57 | m_ServerURI = serverURI.TrimEnd('/'); | ||
58 | } | ||
59 | |||
60 | public AuthenticationServicesConnector(IConfigSource source) | ||
61 | { | ||
62 | Initialise(source); | ||
63 | } | ||
64 | |||
65 | public virtual void Initialise(IConfigSource source) | ||
66 | { | ||
67 | IConfig assetConfig = source.Configs["AuthenticationService"]; | ||
68 | if (assetConfig == null) | ||
69 | { | ||
70 | m_log.Error("[USER CONNECTOR]: AuthenticationService missing from OpanSim.ini"); | ||
71 | throw new Exception("Authentication connector init error"); | ||
72 | } | ||
73 | |||
74 | string serviceURI = assetConfig.GetString("AuthenticationServerURI", | ||
75 | String.Empty); | ||
76 | |||
77 | if (serviceURI == String.Empty) | ||
78 | { | ||
79 | m_log.Error("[USER CONNECTOR]: No Server URI named in section AuthenticationService"); | ||
80 | throw new Exception("Authentication connector init error"); | ||
81 | } | ||
82 | m_ServerURI = serviceURI; | ||
83 | } | ||
84 | |||
85 | public string Authenticate(UUID principalID, string password, int lifetime) | ||
86 | { | ||
87 | Dictionary<string, string> sendData = new Dictionary<string, string>(); | ||
88 | sendData["LIFETIME"] = lifetime.ToString(); | ||
89 | sendData["PRINCIPAL"] = principalID.ToString(); | ||
90 | sendData["PASSWORD"] = password; | ||
91 | |||
92 | sendData["METHOD"] = "authenticate"; | ||
93 | |||
94 | string reply = SynchronousRestFormsRequester.MakeRequest("POST", | ||
95 | m_ServerURI + "/auth/plain", | ||
96 | ServerUtils.BuildQueryString(sendData)); | ||
97 | |||
98 | Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse( | ||
99 | reply); | ||
100 | |||
101 | if (replyData["Result"].ToString() != "Success") | ||
102 | return String.Empty; | ||
103 | |||
104 | return replyData["Token"].ToString(); | ||
105 | } | ||
106 | |||
107 | public bool Verify(UUID principalID, string token, int lifetime) | ||
108 | { | ||
109 | Dictionary<string, string> sendData = new Dictionary<string, string>(); | ||
110 | sendData["LIFETIME"] = lifetime.ToString(); | ||
111 | sendData["PRINCIPAL"] = principalID.ToString(); | ||
112 | sendData["TOKEN"] = token; | ||
113 | |||
114 | sendData["METHOD"] = "verify"; | ||
115 | |||
116 | string reply = SynchronousRestFormsRequester.MakeRequest("POST", | ||
117 | m_ServerURI + "/auth/plain", | ||
118 | ServerUtils.BuildQueryString(sendData)); | ||
119 | |||
120 | Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse( | ||
121 | reply); | ||
122 | |||
123 | if (replyData["Result"].ToString() != "Success") | ||
124 | return false; | ||
125 | |||
126 | return true; | ||
127 | } | ||
128 | |||
129 | public bool Release(UUID principalID, string token) | ||
130 | { | ||
131 | Dictionary<string, string> sendData = new Dictionary<string, string>(); | ||
132 | sendData["PRINCIPAL"] = principalID.ToString(); | ||
133 | sendData["TOKEN"] = token; | ||
134 | |||
135 | sendData["METHOD"] = "release"; | ||
136 | |||
137 | string reply = SynchronousRestFormsRequester.MakeRequest("POST", | ||
138 | m_ServerURI + "/auth/plain", | ||
139 | ServerUtils.BuildQueryString(sendData)); | ||
140 | |||
141 | Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse( | ||
142 | reply); | ||
143 | |||
144 | if (replyData["Result"].ToString() != "Success") | ||
145 | return false; | ||
146 | |||
147 | return true; | ||
148 | } | ||
149 | } | ||
150 | } | ||
diff --git a/OpenSim/Services/Connectors/Authorization/AuthorizationServiceConnector.cs b/OpenSim/Services/Connectors/Authorization/AuthorizationServiceConnector.cs index 3167352..7926efb 100644 --- a/OpenSim/Services/Connectors/Authorization/AuthorizationServiceConnector.cs +++ b/OpenSim/Services/Connectors/Authorization/AuthorizationServiceConnector.cs | |||
@@ -113,7 +113,7 @@ namespace OpenSim.Services.Connectors | |||
113 | message = response.Message; | 113 | message = response.Message; |
114 | 114 | ||
115 | return response.IsAuthorized; | 115 | return response.IsAuthorized; |
116 | } | 116 | } |
117 | 117 | ||
118 | } | 118 | } |
119 | } | 119 | } |
diff --git a/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs b/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs new file mode 100644 index 0000000..ba46b0d --- /dev/null +++ b/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs | |||
@@ -0,0 +1,449 @@ | |||
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 | |||
28 | using log4net; | ||
29 | using System; | ||
30 | using System.Collections.Generic; | ||
31 | using System.IO; | ||
32 | using System.Reflection; | ||
33 | using Nini.Config; | ||
34 | using OpenSim.Framework; | ||
35 | using OpenSim.Framework.Communications; | ||
36 | using OpenSim.Framework.Servers.HttpServer; | ||
37 | using OpenSim.Services.Interfaces; | ||
38 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | ||
39 | using OpenSim.Server.Base; | ||
40 | using OpenMetaverse; | ||
41 | |||
42 | namespace OpenSim.Services.Connectors | ||
43 | { | ||
44 | public class GridServicesConnector : IGridService | ||
45 | { | ||
46 | private static readonly ILog m_log = | ||
47 | LogManager.GetLogger( | ||
48 | MethodBase.GetCurrentMethod().DeclaringType); | ||
49 | |||
50 | private string m_ServerURI = String.Empty; | ||
51 | |||
52 | public GridServicesConnector() | ||
53 | { | ||
54 | } | ||
55 | |||
56 | public GridServicesConnector(string serverURI) | ||
57 | { | ||
58 | m_ServerURI = serverURI.TrimEnd('/'); | ||
59 | } | ||
60 | |||
61 | public GridServicesConnector(IConfigSource source) | ||
62 | { | ||
63 | Initialise(source); | ||
64 | } | ||
65 | |||
66 | public virtual void Initialise(IConfigSource source) | ||
67 | { | ||
68 | IConfig gridConfig = source.Configs["GridService"]; | ||
69 | if (gridConfig == null) | ||
70 | { | ||
71 | m_log.Error("[GRID CONNECTOR]: GridService missing from OpenSim.ini"); | ||
72 | throw new Exception("Grid connector init error"); | ||
73 | } | ||
74 | |||
75 | string serviceURI = gridConfig.GetString("GridServerURI", | ||
76 | String.Empty); | ||
77 | |||
78 | if (serviceURI == String.Empty) | ||
79 | { | ||
80 | m_log.Error("[GRID CONNECTOR]: No Server URI named in section GridService"); | ||
81 | throw new Exception("Grid connector init error"); | ||
82 | } | ||
83 | m_ServerURI = serviceURI; | ||
84 | } | ||
85 | |||
86 | |||
87 | #region IGridService | ||
88 | |||
89 | public virtual bool RegisterRegion(UUID scopeID, GridRegion regionInfo) | ||
90 | { | ||
91 | Dictionary<string, object> rinfo = regionInfo.ToKeyValuePairs(); | ||
92 | Dictionary<string, string> sendData = new Dictionary<string,string>(); | ||
93 | foreach (KeyValuePair<string, object> kvp in rinfo) | ||
94 | sendData[kvp.Key] = (string)kvp.Value; | ||
95 | |||
96 | sendData["SCOPEID"] = scopeID.ToString(); | ||
97 | sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString(); | ||
98 | sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString(); | ||
99 | sendData["METHOD"] = "register"; | ||
100 | |||
101 | string reqString = ServerUtils.BuildQueryString(sendData); | ||
102 | //m_log.DebugFormat("[GRID CONNECTOR]: queryString = {0}", reqString); | ||
103 | try | ||
104 | { | ||
105 | string reply = SynchronousRestFormsRequester.MakeRequest("POST", | ||
106 | m_ServerURI + "/grid", | ||
107 | reqString); | ||
108 | if (reply != string.Empty) | ||
109 | { | ||
110 | Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); | ||
111 | |||
112 | if ((replyData["Result"] != null) && (replyData["Result"].ToString().ToLower() == "success")) | ||
113 | return true; | ||
114 | } | ||
115 | else | ||
116 | m_log.DebugFormat("[GRID CONNECTOR]: RegisterRegion received null reply"); | ||
117 | } | ||
118 | catch (Exception e) | ||
119 | { | ||
120 | m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message); | ||
121 | } | ||
122 | |||
123 | return false; | ||
124 | } | ||
125 | |||
126 | public virtual bool DeregisterRegion(UUID regionID) | ||
127 | { | ||
128 | Dictionary<string, string> sendData = new Dictionary<string, string>(); | ||
129 | |||
130 | sendData["REGIONID"] = regionID.ToString(); | ||
131 | |||
132 | sendData["METHOD"] = "deregister"; | ||
133 | |||
134 | try | ||
135 | { | ||
136 | string reply = SynchronousRestFormsRequester.MakeRequest("POST", | ||
137 | m_ServerURI + "/grid", | ||
138 | ServerUtils.BuildQueryString(sendData)); | ||
139 | |||
140 | if (reply != string.Empty) | ||
141 | { | ||
142 | Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); | ||
143 | |||
144 | if ((replyData["Result"] != null) && (replyData["Result"].ToString().ToLower() == "success")) | ||
145 | return true; | ||
146 | } | ||
147 | else | ||
148 | m_log.DebugFormat("[GRID CONNECTOR]: DeregisterRegion received null reply"); | ||
149 | } | ||
150 | catch (Exception e) | ||
151 | { | ||
152 | m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message); | ||
153 | } | ||
154 | |||
155 | return false; | ||
156 | } | ||
157 | |||
158 | public virtual List<GridRegion> GetNeighbours(UUID scopeID, UUID regionID) | ||
159 | { | ||
160 | Dictionary<string, string> sendData = new Dictionary<string, string>(); | ||
161 | |||
162 | sendData["SCOPEID"] = scopeID.ToString(); | ||
163 | sendData["REGIONID"] = regionID.ToString(); | ||
164 | |||
165 | sendData["METHOD"] = "get_neighbours"; | ||
166 | |||
167 | List<GridRegion> rinfos = new List<GridRegion>(); | ||
168 | |||
169 | string reqString = ServerUtils.BuildQueryString(sendData); | ||
170 | string reply = string.Empty; | ||
171 | try | ||
172 | { | ||
173 | reply = SynchronousRestFormsRequester.MakeRequest("POST", | ||
174 | m_ServerURI + "/grid", | ||
175 | reqString); | ||
176 | } | ||
177 | catch (Exception e) | ||
178 | { | ||
179 | m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message); | ||
180 | return rinfos; | ||
181 | } | ||
182 | |||
183 | Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); | ||
184 | |||
185 | if (replyData != null) | ||
186 | { | ||
187 | Dictionary<string, object>.ValueCollection rinfosList = replyData.Values; | ||
188 | //m_log.DebugFormat("[GRID CONNECTOR]: get neighbours returned {0} elements", rinfosList.Count); | ||
189 | foreach (object r in rinfosList) | ||
190 | { | ||
191 | if (r is Dictionary<string, object>) | ||
192 | { | ||
193 | GridRegion rinfo = new GridRegion((Dictionary<string, object>)r); | ||
194 | rinfos.Add(rinfo); | ||
195 | } | ||
196 | else | ||
197 | m_log.DebugFormat("[GRID CONNECTOR]: GetNeighbours {0}, {1} received invalid response type {2}", | ||
198 | scopeID, regionID, r.GetType()); | ||
199 | } | ||
200 | } | ||
201 | else | ||
202 | m_log.DebugFormat("[GRID CONNECTOR]: GetNeighbours {0}, {1} received null response", | ||
203 | scopeID, regionID); | ||
204 | |||
205 | return rinfos; | ||
206 | } | ||
207 | |||
208 | public virtual GridRegion GetRegionByUUID(UUID scopeID, UUID regionID) | ||
209 | { | ||
210 | Dictionary<string, string> sendData = new Dictionary<string, string>(); | ||
211 | |||
212 | sendData["SCOPEID"] = scopeID.ToString(); | ||
213 | sendData["REGIONID"] = regionID.ToString(); | ||
214 | |||
215 | sendData["METHOD"] = "get_region_by_uuid"; | ||
216 | |||
217 | string reply = string.Empty; | ||
218 | try | ||
219 | { | ||
220 | reply = SynchronousRestFormsRequester.MakeRequest("POST", | ||
221 | m_ServerURI + "/grid", | ||
222 | ServerUtils.BuildQueryString(sendData)); | ||
223 | } | ||
224 | catch (Exception e) | ||
225 | { | ||
226 | m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message); | ||
227 | return null; | ||
228 | } | ||
229 | |||
230 | GridRegion rinfo = null; | ||
231 | |||
232 | if (reply != string.Empty) | ||
233 | { | ||
234 | Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); | ||
235 | |||
236 | if ((replyData != null) && (replyData["result"] != null)) | ||
237 | { | ||
238 | if (replyData["result"] is Dictionary<string, object>) | ||
239 | rinfo = new GridRegion((Dictionary<string, object>)replyData["result"]); | ||
240 | //else | ||
241 | // m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByUUID {0}, {1} received null response", | ||
242 | // scopeID, regionID); | ||
243 | } | ||
244 | else | ||
245 | m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByUUID {0}, {1} received null response", | ||
246 | scopeID, regionID); | ||
247 | } | ||
248 | else | ||
249 | m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByUUID received null reply"); | ||
250 | |||
251 | return rinfo; | ||
252 | } | ||
253 | |||
254 | public virtual GridRegion GetRegionByPosition(UUID scopeID, int x, int y) | ||
255 | { | ||
256 | Dictionary<string, string> sendData = new Dictionary<string, string>(); | ||
257 | |||
258 | sendData["SCOPEID"] = scopeID.ToString(); | ||
259 | sendData["X"] = x.ToString(); | ||
260 | sendData["Y"] = y.ToString(); | ||
261 | |||
262 | sendData["METHOD"] = "get_region_by_position"; | ||
263 | string reply = string.Empty; | ||
264 | try | ||
265 | { | ||
266 | reply = SynchronousRestFormsRequester.MakeRequest("POST", | ||
267 | m_ServerURI + "/grid", | ||
268 | ServerUtils.BuildQueryString(sendData)); | ||
269 | } | ||
270 | catch (Exception e) | ||
271 | { | ||
272 | m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message); | ||
273 | return null; | ||
274 | } | ||
275 | |||
276 | GridRegion rinfo = null; | ||
277 | if (reply != string.Empty) | ||
278 | { | ||
279 | Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); | ||
280 | |||
281 | if ((replyData != null) && (replyData["result"] != null)) | ||
282 | { | ||
283 | if (replyData["result"] is Dictionary<string, object>) | ||
284 | rinfo = new GridRegion((Dictionary<string, object>)replyData["result"]); | ||
285 | else | ||
286 | m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition {0}, {1}-{2} received invalid response", | ||
287 | scopeID, x, y); | ||
288 | } | ||
289 | else | ||
290 | m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition {0}, {1}-{2} received null response", | ||
291 | scopeID, x, y); | ||
292 | } | ||
293 | else | ||
294 | m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition received null reply"); | ||
295 | |||
296 | return rinfo; | ||
297 | } | ||
298 | |||
299 | public virtual GridRegion GetRegionByName(UUID scopeID, string regionName) | ||
300 | { | ||
301 | Dictionary<string, string> sendData = new Dictionary<string, string>(); | ||
302 | |||
303 | sendData["SCOPEID"] = scopeID.ToString(); | ||
304 | sendData["NAME"] = regionName; | ||
305 | |||
306 | sendData["METHOD"] = "get_region_by_name"; | ||
307 | string reply = string.Empty; | ||
308 | try | ||
309 | { | ||
310 | reply = SynchronousRestFormsRequester.MakeRequest("POST", | ||
311 | m_ServerURI + "/grid", | ||
312 | ServerUtils.BuildQueryString(sendData)); | ||
313 | } | ||
314 | catch (Exception e) | ||
315 | { | ||
316 | m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message); | ||
317 | return null; | ||
318 | } | ||
319 | |||
320 | GridRegion rinfo = null; | ||
321 | if (reply != string.Empty) | ||
322 | { | ||
323 | Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); | ||
324 | |||
325 | if ((replyData != null) && (replyData["result"] != null)) | ||
326 | { | ||
327 | if (replyData["result"] is Dictionary<string, object>) | ||
328 | rinfo = new GridRegion((Dictionary<string, object>)replyData["result"]); | ||
329 | } | ||
330 | else | ||
331 | m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition {0}, {1} received null response", | ||
332 | scopeID, regionName); | ||
333 | } | ||
334 | else | ||
335 | m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByName received null reply"); | ||
336 | |||
337 | return rinfo; | ||
338 | } | ||
339 | |||
340 | public virtual List<GridRegion> GetRegionsByName(UUID scopeID, string name, int maxNumber) | ||
341 | { | ||
342 | Dictionary<string, string> sendData = new Dictionary<string, string>(); | ||
343 | |||
344 | sendData["SCOPEID"] = scopeID.ToString(); | ||
345 | sendData["NAME"] = name; | ||
346 | sendData["MAX"] = maxNumber.ToString(); | ||
347 | |||
348 | sendData["METHOD"] = "get_regions_by_name"; | ||
349 | List<GridRegion> rinfos = new List<GridRegion>(); | ||
350 | string reply = string.Empty; | ||
351 | try | ||
352 | { | ||
353 | reply = SynchronousRestFormsRequester.MakeRequest("POST", | ||
354 | m_ServerURI + "/grid", | ||
355 | ServerUtils.BuildQueryString(sendData)); | ||
356 | } | ||
357 | catch (Exception e) | ||
358 | { | ||
359 | m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message); | ||
360 | return rinfos; | ||
361 | } | ||
362 | |||
363 | if (reply != string.Empty) | ||
364 | { | ||
365 | Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); | ||
366 | |||
367 | if (replyData != null) | ||
368 | { | ||
369 | Dictionary<string, object>.ValueCollection rinfosList = replyData.Values; | ||
370 | foreach (object r in rinfosList) | ||
371 | { | ||
372 | if (r is Dictionary<string, object>) | ||
373 | { | ||
374 | GridRegion rinfo = new GridRegion((Dictionary<string, object>)r); | ||
375 | rinfos.Add(rinfo); | ||
376 | } | ||
377 | else | ||
378 | m_log.DebugFormat("[GRID CONNECTOR]: GetRegionsByName {0}, {1}, {2} received invalid response", | ||
379 | scopeID, name, maxNumber); | ||
380 | } | ||
381 | } | ||
382 | else | ||
383 | m_log.DebugFormat("[GRID CONNECTOR]: GetRegionsByName {0}, {1}, {2} received null response", | ||
384 | scopeID, name, maxNumber); | ||
385 | } | ||
386 | else | ||
387 | m_log.DebugFormat("[GRID CONNECTOR]: GetRegionsByName received null reply"); | ||
388 | |||
389 | return rinfos; | ||
390 | } | ||
391 | |||
392 | public virtual List<GridRegion> GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax) | ||
393 | { | ||
394 | Dictionary<string, string> sendData = new Dictionary<string, string>(); | ||
395 | |||
396 | sendData["SCOPEID"] = scopeID.ToString(); | ||
397 | sendData["XMIN"] = xmin.ToString(); | ||
398 | sendData["XMAX"] = xmax.ToString(); | ||
399 | sendData["YMIN"] = ymin.ToString(); | ||
400 | sendData["YMAX"] = ymax.ToString(); | ||
401 | |||
402 | sendData["METHOD"] = "get_region_range"; | ||
403 | |||
404 | List<GridRegion> rinfos = new List<GridRegion>(); | ||
405 | string reply = string.Empty; | ||
406 | try | ||
407 | { | ||
408 | reply = SynchronousRestFormsRequester.MakeRequest("POST", | ||
409 | m_ServerURI + "/grid", | ||
410 | ServerUtils.BuildQueryString(sendData)); | ||
411 | |||
412 | //m_log.DebugFormat("[GRID CONNECTOR]: reply was {0}", reply); | ||
413 | } | ||
414 | catch (Exception e) | ||
415 | { | ||
416 | m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message); | ||
417 | return rinfos; | ||
418 | } | ||
419 | |||
420 | if (reply != string.Empty) | ||
421 | { | ||
422 | Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); | ||
423 | |||
424 | if (replyData != null) | ||
425 | { | ||
426 | Dictionary<string, object>.ValueCollection rinfosList = replyData.Values; | ||
427 | foreach (object r in rinfosList) | ||
428 | { | ||
429 | if (r is Dictionary<string, object>) | ||
430 | { | ||
431 | GridRegion rinfo = new GridRegion((Dictionary<string, object>)r); | ||
432 | rinfos.Add(rinfo); | ||
433 | } | ||
434 | } | ||
435 | } | ||
436 | else | ||
437 | m_log.DebugFormat("[GRID CONNECTOR]: GetRegionRange {0}, {1}-{2} {3}-{4} received null response", | ||
438 | scopeID, xmin, xmax, ymin, ymax); | ||
439 | } | ||
440 | else | ||
441 | m_log.DebugFormat("[GRID CONNECTOR]: GetRegionRange received null reply"); | ||
442 | |||
443 | return rinfos; | ||
444 | } | ||
445 | |||
446 | #endregion | ||
447 | |||
448 | } | ||
449 | } | ||
diff --git a/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs b/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs new file mode 100644 index 0000000..3d7f112 --- /dev/null +++ b/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs | |||
@@ -0,0 +1,252 @@ | |||
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 | |||
28 | using System; | ||
29 | using System.Collections; | ||
30 | using System.Collections.Generic; | ||
31 | using System.Text; | ||
32 | using System.Drawing; | ||
33 | using System.Net; | ||
34 | using System.Reflection; | ||
35 | using OpenSim.Services.Interfaces; | ||
36 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | ||
37 | |||
38 | using OpenSim.Framework; | ||
39 | |||
40 | using OpenMetaverse; | ||
41 | using OpenMetaverse.Imaging; | ||
42 | using log4net; | ||
43 | using Nwc.XmlRpc; | ||
44 | |||
45 | namespace OpenSim.Services.Connectors.Grid | ||
46 | { | ||
47 | public class HypergridServiceConnector | ||
48 | { | ||
49 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
50 | |||
51 | private IAssetService m_AssetService; | ||
52 | |||
53 | public HypergridServiceConnector(IAssetService assService) | ||
54 | { | ||
55 | m_AssetService = assService; | ||
56 | } | ||
57 | |||
58 | public UUID LinkRegion(GridRegion info, out ulong realHandle) | ||
59 | { | ||
60 | UUID uuid = UUID.Zero; | ||
61 | realHandle = 0; | ||
62 | |||
63 | Hashtable hash = new Hashtable(); | ||
64 | hash["region_name"] = info.RegionName; | ||
65 | |||
66 | IList paramList = new ArrayList(); | ||
67 | paramList.Add(hash); | ||
68 | |||
69 | XmlRpcRequest request = new XmlRpcRequest("link_region", paramList); | ||
70 | string uri = "http://" + info.ExternalEndPoint.Address + ":" + info.HttpPort + "/"; | ||
71 | m_log.Debug("[HGrid]: Linking to " + uri); | ||
72 | XmlRpcResponse response = null; | ||
73 | try | ||
74 | { | ||
75 | response = request.Send(uri, 10000); | ||
76 | } | ||
77 | catch (Exception e) | ||
78 | { | ||
79 | m_log.Debug("[HGrid]: Exception " + e.Message); | ||
80 | return uuid; | ||
81 | } | ||
82 | |||
83 | if (response.IsFault) | ||
84 | { | ||
85 | m_log.ErrorFormat("[HGrid]: remote call returned an error: {0}", response.FaultString); | ||
86 | } | ||
87 | else | ||
88 | { | ||
89 | hash = (Hashtable)response.Value; | ||
90 | //foreach (Object o in hash) | ||
91 | // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value); | ||
92 | try | ||
93 | { | ||
94 | UUID.TryParse((string)hash["uuid"], out uuid); | ||
95 | m_log.Debug(">> HERE, uuid: " + uuid); | ||
96 | info.RegionID = uuid; | ||
97 | if ((string)hash["handle"] != null) | ||
98 | { | ||
99 | realHandle = Convert.ToUInt64((string)hash["handle"]); | ||
100 | m_log.Debug(">> HERE, realHandle: " + realHandle); | ||
101 | } | ||
102 | //if (hash["region_image"] != null) | ||
103 | //{ | ||
104 | // UUID img = UUID.Zero; | ||
105 | // UUID.TryParse((string)hash["region_image"], out img); | ||
106 | // info.RegionSettings.TerrainImageID = img; | ||
107 | //} | ||
108 | if (hash["region_name"] != null) | ||
109 | { | ||
110 | info.RegionName = (string)hash["region_name"]; | ||
111 | //m_log.Debug(">> " + info.RegionName); | ||
112 | } | ||
113 | if (hash["internal_port"] != null) | ||
114 | { | ||
115 | int port = Convert.ToInt32((string)hash["internal_port"]); | ||
116 | info.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), port); | ||
117 | //m_log.Debug(">> " + info.InternalEndPoint.ToString()); | ||
118 | } | ||
119 | |||
120 | } | ||
121 | catch (Exception e) | ||
122 | { | ||
123 | m_log.Error("[HGrid]: Got exception while parsing hyperlink response " + e.StackTrace); | ||
124 | } | ||
125 | } | ||
126 | return uuid; | ||
127 | } | ||
128 | |||
129 | public void GetMapImage(GridRegion info) | ||
130 | { | ||
131 | try | ||
132 | { | ||
133 | string regionimage = "regionImage" + info.RegionID.ToString(); | ||
134 | regionimage = regionimage.Replace("-", ""); | ||
135 | |||
136 | WebClient c = new WebClient(); | ||
137 | string uri = "http://" + info.ExternalHostName + ":" + info.HttpPort + "/index.php?method=" + regionimage; | ||
138 | //m_log.Debug("JPEG: " + uri); | ||
139 | c.DownloadFile(uri, info.RegionID.ToString() + ".jpg"); | ||
140 | Bitmap m = new Bitmap(info.RegionID.ToString() + ".jpg"); | ||
141 | //m_log.Debug("Size: " + m.PhysicalDimension.Height + "-" + m.PhysicalDimension.Width); | ||
142 | byte[] imageData = OpenJPEG.EncodeFromImage(m, true); | ||
143 | AssetBase ass = new AssetBase(UUID.Random(), "region " + info.RegionID.ToString()); | ||
144 | |||
145 | // !!! for now | ||
146 | //info.RegionSettings.TerrainImageID = ass.FullID; | ||
147 | |||
148 | ass.Type = (int)AssetType.Texture; | ||
149 | ass.Temporary = true; | ||
150 | ass.Local = true; | ||
151 | ass.Data = imageData; | ||
152 | |||
153 | m_AssetService.Store(ass); | ||
154 | |||
155 | } | ||
156 | catch // LEGIT: Catching problems caused by OpenJPEG p/invoke | ||
157 | { | ||
158 | m_log.Warn("[HGrid]: Failed getting/storing map image, because it is probably already in the cache"); | ||
159 | } | ||
160 | } | ||
161 | |||
162 | public bool InformRegionOfUser(GridRegion regInfo, AgentCircuitData agentData, GridRegion home, string userServer, string assetServer, string inventoryServer) | ||
163 | { | ||
164 | string capsPath = agentData.CapsPath; | ||
165 | Hashtable loginParams = new Hashtable(); | ||
166 | loginParams["session_id"] = agentData.SessionID.ToString(); | ||
167 | |||
168 | loginParams["firstname"] = agentData.firstname; | ||
169 | loginParams["lastname"] = agentData.lastname; | ||
170 | |||
171 | loginParams["agent_id"] = agentData.AgentID.ToString(); | ||
172 | loginParams["circuit_code"] = agentData.circuitcode.ToString(); | ||
173 | loginParams["startpos_x"] = agentData.startpos.X.ToString(); | ||
174 | loginParams["startpos_y"] = agentData.startpos.Y.ToString(); | ||
175 | loginParams["startpos_z"] = agentData.startpos.Z.ToString(); | ||
176 | loginParams["caps_path"] = capsPath; | ||
177 | |||
178 | if (home != null) | ||
179 | { | ||
180 | loginParams["region_uuid"] = home.RegionID.ToString(); | ||
181 | loginParams["regionhandle"] = home.RegionHandle.ToString(); | ||
182 | loginParams["home_address"] = home.ExternalHostName; | ||
183 | loginParams["home_port"] = home.HttpPort.ToString(); | ||
184 | loginParams["internal_port"] = home.InternalEndPoint.Port.ToString(); | ||
185 | |||
186 | m_log.Debug(" --------- Home -------"); | ||
187 | m_log.Debug(" >> " + loginParams["home_address"] + " <<"); | ||
188 | m_log.Debug(" >> " + loginParams["region_uuid"] + " <<"); | ||
189 | m_log.Debug(" >> " + loginParams["regionhandle"] + " <<"); | ||
190 | m_log.Debug(" >> " + loginParams["home_port"] + " <<"); | ||
191 | m_log.Debug(" --------- ------------ -------"); | ||
192 | } | ||
193 | else | ||
194 | m_log.WarnFormat("[HGrid]: Home region not found for {0} {1}", agentData.firstname, agentData.lastname); | ||
195 | |||
196 | loginParams["userserver_id"] = userServer; | ||
197 | loginParams["assetserver_id"] = assetServer; | ||
198 | loginParams["inventoryserver_id"] = inventoryServer; | ||
199 | |||
200 | |||
201 | ArrayList SendParams = new ArrayList(); | ||
202 | SendParams.Add(loginParams); | ||
203 | |||
204 | // Send | ||
205 | string uri = "http://" + regInfo.ExternalHostName + ":" + regInfo.HttpPort + "/"; | ||
206 | //m_log.Debug("XXX uri: " + uri); | ||
207 | XmlRpcRequest request = new XmlRpcRequest("expect_hg_user", SendParams); | ||
208 | XmlRpcResponse reply; | ||
209 | try | ||
210 | { | ||
211 | reply = request.Send(uri, 6000); | ||
212 | } | ||
213 | catch (Exception e) | ||
214 | { | ||
215 | m_log.Warn("[HGrid]: Failed to notify region about user. Reason: " + e.Message); | ||
216 | return false; | ||
217 | } | ||
218 | |||
219 | if (!reply.IsFault) | ||
220 | { | ||
221 | bool responseSuccess = true; | ||
222 | if (reply.Value != null) | ||
223 | { | ||
224 | Hashtable resp = (Hashtable)reply.Value; | ||
225 | if (resp.ContainsKey("success")) | ||
226 | { | ||
227 | if ((string)resp["success"] == "FALSE") | ||
228 | { | ||
229 | responseSuccess = false; | ||
230 | } | ||
231 | } | ||
232 | } | ||
233 | if (responseSuccess) | ||
234 | { | ||
235 | m_log.Info("[HGrid]: Successfully informed remote region about user " + agentData.AgentID); | ||
236 | return true; | ||
237 | } | ||
238 | else | ||
239 | { | ||
240 | m_log.ErrorFormat("[HGrid]: Region responded that it is not available to receive clients"); | ||
241 | return false; | ||
242 | } | ||
243 | } | ||
244 | else | ||
245 | { | ||
246 | m_log.ErrorFormat("[HGrid]: XmlRpc request to region failed with message {0}, code {1} ", reply.FaultString, reply.FaultCode); | ||
247 | return false; | ||
248 | } | ||
249 | } | ||
250 | |||
251 | } | ||
252 | } | ||
diff --git a/OpenSim/Services/Connectors/Inventory/InventoryServiceConnector.cs b/OpenSim/Services/Connectors/Inventory/InventoryServiceConnector.cs index cef678d..5443891 100644 --- a/OpenSim/Services/Connectors/Inventory/InventoryServiceConnector.cs +++ b/OpenSim/Services/Connectors/Inventory/InventoryServiceConnector.cs | |||
@@ -236,42 +236,8 @@ namespace OpenSim.Services.Connectors | |||
236 | } | 236 | } |
237 | catch (Exception e) | 237 | catch (Exception e) |
238 | { | 238 | { |
239 | // Maybe we're talking to an old inventory server. Try this other thing. | 239 | m_log.ErrorFormat("[INVENTORY CONNECTOR]: GetFolderContent operation failed, {0} {1} (old server?).", |
240 | m_log.ErrorFormat("[INVENTORY CONNECTOR]: GetFolderContent operation failed, {0} {1} (old server?). Trying GetInventory.", | ||
241 | e.Source, e.Message); | 240 | e.Source, e.Message); |
242 | |||
243 | InventoryCollection inventory; | ||
244 | List<InventoryFolderBase> folders = null; | ||
245 | try | ||
246 | { | ||
247 | inventory = SynchronousRestSessionObjectPoster<Guid, InventoryCollection>.BeginPostObject( | ||
248 | "POST", m_ServerURI + "/GetInventory/", new Guid(userID), sessionID.ToString(), userID.ToString()); | ||
249 | if (inventory != null) | ||
250 | folders = inventory.Folders; | ||
251 | } | ||
252 | catch (Exception ex) | ||
253 | { | ||
254 | m_log.ErrorFormat("[INVENTORY CONNECTOR]: GetInventory operation also failed, {0} {1}. Giving up.", | ||
255 | e.Source, ex.Message); | ||
256 | return new InventoryCollection(); | ||
257 | } | ||
258 | |||
259 | if ((folders != null) && (folders.Count > 0)) | ||
260 | { | ||
261 | m_log.DebugFormat("[INVENTORY CONNECTOR]: Received entire inventory ({0} folders) for user {1}", | ||
262 | folders.Count, userID); | ||
263 | |||
264 | folders = folders.FindAll(delegate(InventoryFolderBase f) { return f.ParentID == folderID; }); | ||
265 | List<InventoryItemBase> items = inventory.Items; | ||
266 | if (items != null) | ||
267 | { | ||
268 | items = items.FindAll(delegate(InventoryItemBase i) { return i.Folder == folderID; }); | ||
269 | } | ||
270 | |||
271 | inventory.Items = items; | ||
272 | inventory.Folders = folders; | ||
273 | return inventory; | ||
274 | } | ||
275 | } | 241 | } |
276 | 242 | ||
277 | InventoryCollection nullCollection = new InventoryCollection(); | 243 | InventoryCollection nullCollection = new InventoryCollection(); |
diff --git a/OpenSim/Services/Connectors/Land/LandServiceConnector.cs b/OpenSim/Services/Connectors/Land/LandServiceConnector.cs index 0243f1f..06bc11c 100644 --- a/OpenSim/Services/Connectors/Land/LandServiceConnector.cs +++ b/OpenSim/Services/Connectors/Land/LandServiceConnector.cs | |||
@@ -38,6 +38,7 @@ using OpenSim.Framework.Servers.HttpServer; | |||
38 | using OpenSim.Services.Interfaces; | 38 | using OpenSim.Services.Interfaces; |
39 | using OpenMetaverse; | 39 | using OpenMetaverse; |
40 | using Nwc.XmlRpc; | 40 | using Nwc.XmlRpc; |
41 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | ||
41 | 42 | ||
42 | namespace OpenSim.Services.Connectors | 43 | namespace OpenSim.Services.Connectors |
43 | { | 44 | { |
@@ -47,20 +48,20 @@ namespace OpenSim.Services.Connectors | |||
47 | LogManager.GetLogger( | 48 | LogManager.GetLogger( |
48 | MethodBase.GetCurrentMethod().DeclaringType); | 49 | MethodBase.GetCurrentMethod().DeclaringType); |
49 | 50 | ||
50 | protected IGridServices m_MapService = null; | 51 | protected IGridService m_GridService = null; |
51 | 52 | ||
52 | public LandServicesConnector() | 53 | public LandServicesConnector() |
53 | { | 54 | { |
54 | } | 55 | } |
55 | 56 | ||
56 | public LandServicesConnector(IGridServices gridServices) | 57 | public LandServicesConnector(IGridService gridServices) |
57 | { | 58 | { |
58 | Initialise(gridServices); | 59 | Initialise(gridServices); |
59 | } | 60 | } |
60 | 61 | ||
61 | public virtual void Initialise(IGridServices gridServices) | 62 | public virtual void Initialise(IGridService gridServices) |
62 | { | 63 | { |
63 | m_MapService = gridServices; | 64 | m_GridService = gridServices; |
64 | } | 65 | } |
65 | 66 | ||
66 | public virtual LandData GetLandData(ulong regionHandle, uint x, uint y) | 67 | public virtual LandData GetLandData(ulong regionHandle, uint x, uint y) |
@@ -76,7 +77,9 @@ namespace OpenSim.Services.Connectors | |||
76 | 77 | ||
77 | try | 78 | try |
78 | { | 79 | { |
79 | RegionInfo info = m_MapService.RequestNeighbourInfo(regionHandle); | 80 | uint xpos = 0, ypos = 0; |
81 | Utils.LongToUInts(regionHandle, out xpos, out ypos); | ||
82 | GridRegion info = m_GridService.GetRegionByPosition(UUID.Zero, (int)xpos, (int)ypos); | ||
80 | if (info != null) // just to be sure | 83 | if (info != null) // just to be sure |
81 | { | 84 | { |
82 | XmlRpcRequest request = new XmlRpcRequest("land_data", paramList); | 85 | XmlRpcRequest request = new XmlRpcRequest("land_data", paramList); |
diff --git a/OpenSim/Services/Connectors/Neighbour/NeighbourServiceConnector.cs b/OpenSim/Services/Connectors/Neighbour/NeighbourServiceConnector.cs index 7fff537..145f212 100644 --- a/OpenSim/Services/Connectors/Neighbour/NeighbourServiceConnector.cs +++ b/OpenSim/Services/Connectors/Neighbour/NeighbourServiceConnector.cs | |||
@@ -41,6 +41,8 @@ using OpenSim.Services.Interfaces; | |||
41 | using OpenMetaverse; | 41 | using OpenMetaverse; |
42 | using OpenMetaverse.StructuredData; | 42 | using OpenMetaverse.StructuredData; |
43 | 43 | ||
44 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | ||
45 | |||
44 | namespace OpenSim.Services.Connectors | 46 | namespace OpenSim.Services.Connectors |
45 | { | 47 | { |
46 | public class NeighbourServicesConnector : INeighbourService | 48 | public class NeighbourServicesConnector : INeighbourService |
@@ -49,37 +51,39 @@ namespace OpenSim.Services.Connectors | |||
49 | LogManager.GetLogger( | 51 | LogManager.GetLogger( |
50 | MethodBase.GetCurrentMethod().DeclaringType); | 52 | MethodBase.GetCurrentMethod().DeclaringType); |
51 | 53 | ||
52 | protected IGridServices m_MapService = null; | 54 | protected IGridService m_GridService = null; |
53 | 55 | ||
54 | public NeighbourServicesConnector() | 56 | public NeighbourServicesConnector() |
55 | { | 57 | { |
56 | } | 58 | } |
57 | 59 | ||
58 | public NeighbourServicesConnector(IGridServices gridServices) | 60 | public NeighbourServicesConnector(IGridService gridServices) |
59 | { | 61 | { |
60 | Initialise(gridServices); | 62 | Initialise(gridServices); |
61 | } | 63 | } |
62 | 64 | ||
63 | public virtual void Initialise(IGridServices gridServices) | 65 | public virtual void Initialise(IGridService gridServices) |
64 | { | 66 | { |
65 | m_MapService = gridServices; | 67 | m_GridService = gridServices; |
66 | } | 68 | } |
67 | 69 | ||
68 | public virtual bool HelloNeighbour(ulong regionHandle, RegionInfo thisRegion) | 70 | public virtual GridRegion HelloNeighbour(ulong regionHandle, RegionInfo thisRegion) |
69 | { | 71 | { |
70 | RegionInfo regInfo = m_MapService.RequestNeighbourInfo(regionHandle); | 72 | uint x = 0, y = 0; |
73 | Utils.LongToUInts(regionHandle, out x, out y); | ||
74 | GridRegion regInfo = m_GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y); | ||
71 | if ((regInfo != null) && | 75 | if ((regInfo != null) && |
72 | // Don't remote-call this instance; that's a startup hickup | 76 | // Don't remote-call this instance; that's a startup hickup |
73 | !((regInfo.ExternalHostName == thisRegion.ExternalHostName) && (regInfo.HttpPort == thisRegion.HttpPort))) | 77 | !((regInfo.ExternalHostName == thisRegion.ExternalHostName) && (regInfo.HttpPort == thisRegion.HttpPort))) |
74 | { | 78 | { |
75 | return DoHelloNeighbourCall(regInfo, thisRegion); | 79 | DoHelloNeighbourCall(regInfo, thisRegion); |
76 | } | 80 | } |
77 | //else | 81 | //else |
78 | // m_log.Warn("[REST COMMS]: Region not found " + regionHandle); | 82 | // m_log.Warn("[REST COMMS]: Region not found " + regionHandle); |
79 | return false; | 83 | return regInfo; |
80 | } | 84 | } |
81 | 85 | ||
82 | public bool DoHelloNeighbourCall(RegionInfo region, RegionInfo thisRegion) | 86 | public bool DoHelloNeighbourCall(GridRegion region, RegionInfo thisRegion) |
83 | { | 87 | { |
84 | string uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/region/" + thisRegion.RegionID + "/"; | 88 | string uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/region/" + thisRegion.RegionID + "/"; |
85 | //m_log.Debug(" >>> DoHelloNeighbourCall <<< " + uri); | 89 | //m_log.Debug(" >>> DoHelloNeighbourCall <<< " + uri); |
diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs new file mode 100644 index 0000000..991acf2 --- /dev/null +++ b/OpenSim/Services/GridService/GridService.cs | |||
@@ -0,0 +1,199 @@ | |||
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 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Net; | ||
31 | using System.Reflection; | ||
32 | using Nini.Config; | ||
33 | using log4net; | ||
34 | using OpenSim.Framework; | ||
35 | using OpenSim.Framework.Console; | ||
36 | using OpenSim.Data; | ||
37 | using OpenSim.Services.Interfaces; | ||
38 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | ||
39 | using OpenMetaverse; | ||
40 | |||
41 | namespace OpenSim.Services.GridService | ||
42 | { | ||
43 | public class GridService : GridServiceBase, IGridService | ||
44 | { | ||
45 | private static readonly ILog m_log = | ||
46 | LogManager.GetLogger( | ||
47 | MethodBase.GetCurrentMethod().DeclaringType); | ||
48 | |||
49 | public GridService(IConfigSource config) | ||
50 | : base(config) | ||
51 | { | ||
52 | m_log.DebugFormat("[GRID SERVICE]: Starting..."); | ||
53 | } | ||
54 | |||
55 | #region IGridService | ||
56 | |||
57 | public bool RegisterRegion(UUID scopeID, GridRegion regionInfos) | ||
58 | { | ||
59 | // This needs better sanity testing. What if regionInfo is registering in | ||
60 | // overlapping coords? | ||
61 | RegionData region = m_Database.Get(regionInfos.RegionLocX, regionInfos.RegionLocY, scopeID); | ||
62 | if ((region != null) && (region.RegionID != regionInfos.RegionID)) | ||
63 | { | ||
64 | m_log.WarnFormat("[GRID SERVICE]: Region {0} tried to register in coordinates {1}, {2} which are already in use in scope {3}.", | ||
65 | regionInfos.RegionID, regionInfos.RegionLocX, regionInfos.RegionLocY, scopeID); | ||
66 | return false; | ||
67 | } | ||
68 | if ((region != null) && (region.RegionID == regionInfos.RegionID) && | ||
69 | ((region.posX != regionInfos.RegionLocX) || (region.posY != regionInfos.RegionLocY))) | ||
70 | { | ||
71 | // Region reregistering in other coordinates. Delete the old entry | ||
72 | m_Database.Delete(regionInfos.RegionID); | ||
73 | } | ||
74 | |||
75 | // Everything is ok, let's register | ||
76 | RegionData rdata = RegionInfo2RegionData(regionInfos); | ||
77 | rdata.ScopeID = scopeID; | ||
78 | m_Database.Store(rdata); | ||
79 | return true; | ||
80 | } | ||
81 | |||
82 | public bool DeregisterRegion(UUID regionID) | ||
83 | { | ||
84 | return m_Database.Delete(regionID); | ||
85 | } | ||
86 | |||
87 | public List<GridRegion> GetNeighbours(UUID scopeID, UUID regionID) | ||
88 | { | ||
89 | List<GridRegion> rinfos = new List<GridRegion>(); | ||
90 | RegionData region = m_Database.Get(regionID, scopeID); | ||
91 | if (region != null) | ||
92 | { | ||
93 | // Not really? Maybe? | ||
94 | List<RegionData> rdatas = m_Database.Get(region.posX - (int)Constants.RegionSize, region.posY - (int)Constants.RegionSize, | ||
95 | region.posX + (int)Constants.RegionSize, region.posY + (int)Constants.RegionSize, scopeID); | ||
96 | |||
97 | foreach (RegionData rdata in rdatas) | ||
98 | if (rdata.RegionID != regionID) | ||
99 | rinfos.Add(RegionData2RegionInfo(rdata)); | ||
100 | |||
101 | } | ||
102 | return rinfos; | ||
103 | } | ||
104 | |||
105 | public GridRegion GetRegionByUUID(UUID scopeID, UUID regionID) | ||
106 | { | ||
107 | RegionData rdata = m_Database.Get(regionID, scopeID); | ||
108 | if (rdata != null) | ||
109 | return RegionData2RegionInfo(rdata); | ||
110 | |||
111 | return null; | ||
112 | } | ||
113 | |||
114 | public GridRegion GetRegionByPosition(UUID scopeID, int x, int y) | ||
115 | { | ||
116 | int snapX = (int)(x / Constants.RegionSize) * (int)Constants.RegionSize; | ||
117 | int snapY = (int)(y / Constants.RegionSize) * (int)Constants.RegionSize; | ||
118 | RegionData rdata = m_Database.Get(snapX, snapY, scopeID); | ||
119 | if (rdata != null) | ||
120 | return RegionData2RegionInfo(rdata); | ||
121 | |||
122 | return null; | ||
123 | } | ||
124 | |||
125 | public GridRegion GetRegionByName(UUID scopeID, string regionName) | ||
126 | { | ||
127 | List<RegionData> rdatas = m_Database.Get(regionName + "%", scopeID); | ||
128 | if ((rdatas != null) && (rdatas.Count > 0)) | ||
129 | return RegionData2RegionInfo(rdatas[0]); // get the first | ||
130 | |||
131 | return null; | ||
132 | } | ||
133 | |||
134 | public List<GridRegion> GetRegionsByName(UUID scopeID, string name, int maxNumber) | ||
135 | { | ||
136 | List<RegionData> rdatas = m_Database.Get("%" + name + "%", scopeID); | ||
137 | |||
138 | int count = 0; | ||
139 | List<GridRegion> rinfos = new List<GridRegion>(); | ||
140 | |||
141 | if (rdatas != null) | ||
142 | { | ||
143 | foreach (RegionData rdata in rdatas) | ||
144 | { | ||
145 | if (count++ < maxNumber) | ||
146 | rinfos.Add(RegionData2RegionInfo(rdata)); | ||
147 | } | ||
148 | } | ||
149 | |||
150 | return rinfos; | ||
151 | } | ||
152 | |||
153 | public List<GridRegion> GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax) | ||
154 | { | ||
155 | int xminSnap = (int)(xmin / Constants.RegionSize) * (int)Constants.RegionSize; | ||
156 | int xmaxSnap = (int)(xmax / Constants.RegionSize) * (int)Constants.RegionSize; | ||
157 | int yminSnap = (int)(ymin / Constants.RegionSize) * (int)Constants.RegionSize; | ||
158 | int ymaxSnap = (int)(ymax / Constants.RegionSize) * (int)Constants.RegionSize; | ||
159 | |||
160 | List<RegionData> rdatas = m_Database.Get(xminSnap, yminSnap, xmaxSnap, ymaxSnap, scopeID); | ||
161 | List<GridRegion> rinfos = new List<GridRegion>(); | ||
162 | foreach (RegionData rdata in rdatas) | ||
163 | rinfos.Add(RegionData2RegionInfo(rdata)); | ||
164 | |||
165 | return rinfos; | ||
166 | } | ||
167 | |||
168 | #endregion | ||
169 | |||
170 | #region Data structure conversions | ||
171 | |||
172 | protected RegionData RegionInfo2RegionData(GridRegion rinfo) | ||
173 | { | ||
174 | RegionData rdata = new RegionData(); | ||
175 | rdata.posX = (int)rinfo.RegionLocX; | ||
176 | rdata.posY = (int)rinfo.RegionLocY; | ||
177 | rdata.RegionID = rinfo.RegionID; | ||
178 | rdata.RegionName = rinfo.RegionName; | ||
179 | rdata.Data = rinfo.ToKeyValuePairs(); | ||
180 | rdata.Data["regionHandle"] = Utils.UIntsToLong((uint)rdata.posX, (uint)rdata.posY); | ||
181 | return rdata; | ||
182 | } | ||
183 | |||
184 | protected GridRegion RegionData2RegionInfo(RegionData rdata) | ||
185 | { | ||
186 | GridRegion rinfo = new GridRegion(rdata.Data); | ||
187 | rinfo.RegionLocX = rdata.posX; | ||
188 | rinfo.RegionLocY = rdata.posY; | ||
189 | rinfo.RegionID = rdata.RegionID; | ||
190 | rinfo.RegionName = rdata.RegionName; | ||
191 | rinfo.ScopeID = rdata.ScopeID; | ||
192 | |||
193 | return rinfo; | ||
194 | } | ||
195 | |||
196 | #endregion | ||
197 | |||
198 | } | ||
199 | } | ||
diff --git a/OpenSim/Services/GridService/GridServiceBase.cs b/OpenSim/Services/GridService/GridServiceBase.cs new file mode 100644 index 0000000..444f79b --- /dev/null +++ b/OpenSim/Services/GridService/GridServiceBase.cs | |||
@@ -0,0 +1,84 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Reflection; | ||
30 | using Nini.Config; | ||
31 | using OpenSim.Framework; | ||
32 | using OpenSim.Data; | ||
33 | using OpenSim.Services.Interfaces; | ||
34 | using OpenSim.Services.Base; | ||
35 | |||
36 | namespace OpenSim.Services.GridService | ||
37 | { | ||
38 | public class GridServiceBase : ServiceBase | ||
39 | { | ||
40 | protected IRegionData m_Database = null; | ||
41 | |||
42 | public GridServiceBase(IConfigSource config) | ||
43 | : base(config) | ||
44 | { | ||
45 | string dllName = String.Empty; | ||
46 | string connString = String.Empty; | ||
47 | string realm = "regions"; | ||
48 | |||
49 | // | ||
50 | // Try reading the [DatabaseService] section, if it exists | ||
51 | // | ||
52 | IConfig dbConfig = config.Configs["DatabaseService"]; | ||
53 | if (dbConfig != null) | ||
54 | { | ||
55 | if (dllName == String.Empty) | ||
56 | dllName = dbConfig.GetString("StorageProvider", String.Empty); | ||
57 | if (connString == String.Empty) | ||
58 | connString = dbConfig.GetString("ConnectionString", String.Empty); | ||
59 | } | ||
60 | |||
61 | // | ||
62 | // [GridService] section overrides [DatabaseService], if it exists | ||
63 | // | ||
64 | IConfig gridConfig = config.Configs["GridService"]; | ||
65 | if (gridConfig != null) | ||
66 | { | ||
67 | dllName = gridConfig.GetString("StorageProvider", dllName); | ||
68 | connString = gridConfig.GetString("ConnectionString", connString); | ||
69 | realm = gridConfig.GetString("Realm", realm); | ||
70 | } | ||
71 | |||
72 | // | ||
73 | // We tried, but this doesn't exist. We can't proceed. | ||
74 | // | ||
75 | if (dllName.Equals(String.Empty)) | ||
76 | throw new Exception("No StorageProvider configured"); | ||
77 | |||
78 | m_Database = LoadPlugin<IRegionData>(dllName, new Object[] { connString, realm }); | ||
79 | if (m_Database == null) | ||
80 | throw new Exception("Could not find a storage interface in the given module"); | ||
81 | |||
82 | } | ||
83 | } | ||
84 | } | ||
diff --git a/OpenSim/Services/Interfaces/IGridService.cs b/OpenSim/Services/Interfaces/IGridService.cs index ac4539a..2290530 100644 --- a/OpenSim/Services/Interfaces/IGridService.cs +++ b/OpenSim/Services/Interfaces/IGridService.cs | |||
@@ -25,8 +25,11 @@ | |||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using OpenSim.Framework; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Net; | ||
31 | using System.Net.Sockets; | ||
32 | using OpenSim.Framework; | ||
30 | using OpenMetaverse; | 33 | using OpenMetaverse; |
31 | 34 | ||
32 | namespace OpenSim.Services.Interfaces | 35 | namespace OpenSim.Services.Interfaces |
@@ -39,7 +42,7 @@ namespace OpenSim.Services.Interfaces | |||
39 | /// <param name="regionInfos"> </param> | 42 | /// <param name="regionInfos"> </param> |
40 | /// <returns></returns> | 43 | /// <returns></returns> |
41 | /// <exception cref="System.Exception">Thrown if region registration failed</exception> | 44 | /// <exception cref="System.Exception">Thrown if region registration failed</exception> |
42 | bool RegisterRegion(UUID scopeID, RegionInfo regionInfos); | 45 | bool RegisterRegion(UUID scopeID, GridRegion regionInfos); |
43 | 46 | ||
44 | /// <summary> | 47 | /// <summary> |
45 | /// Deregister a region with the grid service. | 48 | /// Deregister a region with the grid service. |
@@ -47,21 +50,28 @@ namespace OpenSim.Services.Interfaces | |||
47 | /// <param name="regionID"></param> | 50 | /// <param name="regionID"></param> |
48 | /// <returns></returns> | 51 | /// <returns></returns> |
49 | /// <exception cref="System.Exception">Thrown if region deregistration failed</exception> | 52 | /// <exception cref="System.Exception">Thrown if region deregistration failed</exception> |
50 | bool DeregisterRegion(UUID regionID); | 53 | bool DeregisterRegion(UUID regionID); |
51 | 54 | ||
52 | /// <summary> | 55 | /// <summary> |
53 | /// Get information about the regions neighbouring the given co-ordinates. | 56 | /// Get information about the regions neighbouring the given co-ordinates (in meters). |
54 | /// </summary> | 57 | /// </summary> |
55 | /// <param name="x"></param> | 58 | /// <param name="x"></param> |
56 | /// <param name="y"></param> | 59 | /// <param name="y"></param> |
57 | /// <returns></returns> | 60 | /// <returns></returns> |
58 | List<SimpleRegionInfo> GetNeighbours(UUID scopeID, uint x, uint y); | 61 | List<GridRegion> GetNeighbours(UUID scopeID, UUID regionID); |
59 | 62 | ||
60 | SimpleRegionInfo GetRegionByUUID(UUID scopeID, UUID regionID); | 63 | GridRegion GetRegionByUUID(UUID scopeID, UUID regionID); |
64 | |||
65 | /// <summary> | ||
66 | /// Get the region at the given position (in meters) | ||
67 | /// </summary> | ||
68 | /// <param name="scopeID"></param> | ||
69 | /// <param name="x"></param> | ||
70 | /// <param name="y"></param> | ||
71 | /// <returns></returns> | ||
72 | GridRegion GetRegionByPosition(UUID scopeID, int x, int y); | ||
61 | 73 | ||
62 | SimpleRegionInfo GetRegionByPosition(UUID scopeID, int x, int y); | 74 | GridRegion GetRegionByName(UUID scopeID, string regionName); |
63 | |||
64 | SimpleRegionInfo GetRegionByName(UUID scopeID, string regionName); | ||
65 | 75 | ||
66 | /// <summary> | 76 | /// <summary> |
67 | /// Get information about regions starting with the provided name. | 77 | /// Get information about regions starting with the provided name. |
@@ -76,11 +86,266 @@ namespace OpenSim.Services.Interfaces | |||
76 | /// A list of <see cref="RegionInfo"/>s of regions with matching name. If the | 86 | /// A list of <see cref="RegionInfo"/>s of regions with matching name. If the |
77 | /// grid-server couldn't be contacted or returned an error, return null. | 87 | /// grid-server couldn't be contacted or returned an error, return null. |
78 | /// </returns> | 88 | /// </returns> |
79 | List<SimpleRegionInfo> GetRegionsByName(UUID scopeID, string name, int maxNumber); | 89 | List<GridRegion> GetRegionsByName(UUID scopeID, string name, int maxNumber); |
90 | |||
91 | List<GridRegion> GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax); | ||
92 | |||
93 | } | ||
94 | |||
95 | public class GridRegion | ||
96 | { | ||
97 | |||
98 | /// <summary> | ||
99 | /// The port by which http communication occurs with the region | ||
100 | /// </summary> | ||
101 | public uint HttpPort | ||
102 | { | ||
103 | get { return m_httpPort; } | ||
104 | set { m_httpPort = value; } | ||
105 | } | ||
106 | protected uint m_httpPort; | ||
107 | |||
108 | /// <summary> | ||
109 | /// A well-formed URI for the host region server (namely "http://" + ExternalHostName) | ||
110 | /// </summary> | ||
111 | public string ServerURI | ||
112 | { | ||
113 | get { return m_serverURI; } | ||
114 | set { m_serverURI = value; } | ||
115 | } | ||
116 | protected string m_serverURI; | ||
117 | |||
118 | public string RegionName | ||
119 | { | ||
120 | get { return m_regionName; } | ||
121 | set { m_regionName = value; } | ||
122 | } | ||
123 | protected string m_regionName = String.Empty; | ||
124 | |||
125 | protected string m_externalHostName; | ||
126 | |||
127 | protected IPEndPoint m_internalEndPoint; | ||
128 | |||
129 | public int RegionLocX | ||
130 | { | ||
131 | get { return m_regionLocX; } | ||
132 | set { m_regionLocX = value; } | ||
133 | } | ||
134 | protected int m_regionLocX; | ||
135 | |||
136 | public int RegionLocY | ||
137 | { | ||
138 | get { return m_regionLocY; } | ||
139 | set { m_regionLocY = value; } | ||
140 | } | ||
141 | protected int m_regionLocY; | ||
142 | |||
143 | public UUID RegionID = UUID.Zero; | ||
144 | public UUID ScopeID = UUID.Zero; | ||
145 | |||
146 | public UUID TerrainImage = UUID.Zero; | ||
147 | public byte Access; | ||
148 | public int Maturity; | ||
149 | public string RegionSecret; | ||
150 | |||
151 | public GridRegion() | ||
152 | { | ||
153 | } | ||
154 | |||
155 | public GridRegion(int regionLocX, int regionLocY, IPEndPoint internalEndPoint, string externalUri) | ||
156 | { | ||
157 | m_regionLocX = regionLocX; | ||
158 | m_regionLocY = regionLocY; | ||
80 | 159 | ||
160 | m_internalEndPoint = internalEndPoint; | ||
161 | m_externalHostName = externalUri; | ||
162 | } | ||
81 | 163 | ||
82 | // Not sure about these two (diva) | 164 | public GridRegion(int regionLocX, int regionLocY, string externalUri, uint port) |
165 | { | ||
166 | m_regionLocX = regionLocX; | ||
167 | m_regionLocY = regionLocY; | ||
83 | 168 | ||
169 | m_externalHostName = externalUri; | ||
84 | 170 | ||
171 | m_internalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), (int)port); | ||
172 | } | ||
173 | |||
174 | public GridRegion(uint xcell, uint ycell) | ||
175 | { | ||
176 | m_regionLocX = (int)(xcell * Constants.RegionSize); | ||
177 | m_regionLocY = (int)(ycell * Constants.RegionSize); | ||
178 | } | ||
179 | |||
180 | public GridRegion(RegionInfo ConvertFrom) | ||
181 | { | ||
182 | m_regionName = ConvertFrom.RegionName; | ||
183 | m_regionLocX = (int)(ConvertFrom.RegionLocX * Constants.RegionSize); | ||
184 | m_regionLocY = (int)(ConvertFrom.RegionLocY * Constants.RegionSize); | ||
185 | m_internalEndPoint = ConvertFrom.InternalEndPoint; | ||
186 | m_externalHostName = ConvertFrom.ExternalHostName; | ||
187 | m_httpPort = ConvertFrom.HttpPort; | ||
188 | RegionID = ConvertFrom.RegionID; | ||
189 | ServerURI = ConvertFrom.ServerURI; | ||
190 | TerrainImage = ConvertFrom.RegionSettings.TerrainImageID; | ||
191 | Access = ConvertFrom.AccessLevel; | ||
192 | Maturity = ConvertFrom.RegionSettings.Maturity; | ||
193 | RegionSecret = ConvertFrom.regionSecret; | ||
194 | } | ||
195 | |||
196 | public GridRegion(GridRegion ConvertFrom) | ||
197 | { | ||
198 | m_regionName = ConvertFrom.RegionName; | ||
199 | m_regionLocX = ConvertFrom.RegionLocX; | ||
200 | m_regionLocY = ConvertFrom.RegionLocY; | ||
201 | m_internalEndPoint = ConvertFrom.InternalEndPoint; | ||
202 | m_externalHostName = ConvertFrom.ExternalHostName; | ||
203 | m_httpPort = ConvertFrom.HttpPort; | ||
204 | RegionID = ConvertFrom.RegionID; | ||
205 | ServerURI = ConvertFrom.ServerURI; | ||
206 | TerrainImage = ConvertFrom.TerrainImage; | ||
207 | Access = ConvertFrom.Access; | ||
208 | Maturity = ConvertFrom.Maturity; | ||
209 | RegionSecret = ConvertFrom.RegionSecret; | ||
210 | } | ||
211 | |||
212 | /// <value> | ||
213 | /// This accessor can throw all the exceptions that Dns.GetHostAddresses can throw. | ||
214 | /// | ||
215 | /// XXX Isn't this really doing too much to be a simple getter, rather than an explict method? | ||
216 | /// </value> | ||
217 | public IPEndPoint ExternalEndPoint | ||
218 | { | ||
219 | get | ||
220 | { | ||
221 | // Old one defaults to IPv6 | ||
222 | //return new IPEndPoint(Dns.GetHostAddresses(m_externalHostName)[0], m_internalEndPoint.Port); | ||
223 | |||
224 | IPAddress ia = null; | ||
225 | // If it is already an IP, don't resolve it - just return directly | ||
226 | if (IPAddress.TryParse(m_externalHostName, out ia)) | ||
227 | return new IPEndPoint(ia, m_internalEndPoint.Port); | ||
228 | |||
229 | // Reset for next check | ||
230 | ia = null; | ||
231 | try | ||
232 | { | ||
233 | foreach (IPAddress Adr in Dns.GetHostAddresses(m_externalHostName)) | ||
234 | { | ||
235 | if (ia == null) | ||
236 | ia = Adr; | ||
237 | |||
238 | if (Adr.AddressFamily == AddressFamily.InterNetwork) | ||
239 | { | ||
240 | ia = Adr; | ||
241 | break; | ||
242 | } | ||
243 | } | ||
244 | } | ||
245 | catch (SocketException e) | ||
246 | { | ||
247 | throw new Exception( | ||
248 | "Unable to resolve local hostname " + m_externalHostName + " innerException of type '" + | ||
249 | e + "' attached to this exception", e); | ||
250 | } | ||
251 | |||
252 | return new IPEndPoint(ia, m_internalEndPoint.Port); | ||
253 | } | ||
254 | |||
255 | set { m_externalHostName = value.ToString(); } | ||
256 | } | ||
257 | |||
258 | public string ExternalHostName | ||
259 | { | ||
260 | get { return m_externalHostName; } | ||
261 | set { m_externalHostName = value; } | ||
262 | } | ||
263 | |||
264 | public IPEndPoint InternalEndPoint | ||
265 | { | ||
266 | get { return m_internalEndPoint; } | ||
267 | set { m_internalEndPoint = value; } | ||
268 | } | ||
269 | |||
270 | public ulong RegionHandle | ||
271 | { | ||
272 | get { return Util.UIntsToLong((uint)RegionLocX, (uint)RegionLocY); } | ||
273 | } | ||
274 | |||
275 | public int getInternalEndPointPort() | ||
276 | { | ||
277 | return m_internalEndPoint.Port; | ||
278 | } | ||
279 | |||
280 | public Dictionary<string, object> ToKeyValuePairs() | ||
281 | { | ||
282 | Dictionary<string, object> kvp = new Dictionary<string, object>(); | ||
283 | kvp["uuid"] = RegionID.ToString(); | ||
284 | kvp["locX"] = RegionLocX.ToString(); | ||
285 | kvp["locY"] = RegionLocY.ToString(); | ||
286 | kvp["regionName"] = RegionName; | ||
287 | kvp["serverIP"] = ExternalHostName; //ExternalEndPoint.Address.ToString(); | ||
288 | kvp["serverHttpPort"] = HttpPort.ToString(); | ||
289 | kvp["serverURI"] = ServerURI; | ||
290 | kvp["serverPort"] = InternalEndPoint.Port.ToString(); | ||
291 | kvp["regionMapTexture"] = TerrainImage.ToString(); | ||
292 | kvp["access"] = Access.ToString(); | ||
293 | kvp["regionSecret"] = RegionSecret; | ||
294 | // Maturity doesn't seem to exist in the DB | ||
295 | return kvp; | ||
296 | } | ||
297 | |||
298 | public GridRegion(Dictionary<string, object> kvp) | ||
299 | { | ||
300 | if (kvp.ContainsKey("uuid")) | ||
301 | RegionID = new UUID((string)kvp["uuid"]); | ||
302 | |||
303 | if (kvp.ContainsKey("locX")) | ||
304 | RegionLocX = Convert.ToInt32((string)kvp["locX"]); | ||
305 | |||
306 | if (kvp.ContainsKey("locY")) | ||
307 | RegionLocY = Convert.ToInt32((string)kvp["locY"]); | ||
308 | |||
309 | if (kvp.ContainsKey("regionName")) | ||
310 | RegionName = (string)kvp["regionName"]; | ||
311 | |||
312 | if (kvp.ContainsKey("serverIP")) | ||
313 | { | ||
314 | //int port = 0; | ||
315 | //Int32.TryParse((string)kvp["serverPort"], out port); | ||
316 | //IPEndPoint ep = new IPEndPoint(IPAddress.Parse((string)kvp["serverIP"]), port); | ||
317 | ExternalHostName = (string)kvp["serverIP"]; | ||
318 | } | ||
319 | else | ||
320 | ExternalHostName = "127.0.0.1"; | ||
321 | |||
322 | if (kvp.ContainsKey("serverPort")) | ||
323 | { | ||
324 | Int32 port = 0; | ||
325 | Int32.TryParse((string)kvp["serverPort"], out port); | ||
326 | InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), port); | ||
327 | } | ||
328 | |||
329 | if (kvp.ContainsKey("serverHttpPort")) | ||
330 | { | ||
331 | UInt32 port = 0; | ||
332 | UInt32.TryParse((string)kvp["serverHttpPort"], out port); | ||
333 | HttpPort = port; | ||
334 | } | ||
335 | |||
336 | if (kvp.ContainsKey("serverURI")) | ||
337 | ServerURI = (string)kvp["serverURI"]; | ||
338 | |||
339 | if (kvp.ContainsKey("regionMapTexture")) | ||
340 | UUID.TryParse((string)kvp["regionMapTexture"], out TerrainImage); | ||
341 | |||
342 | if (kvp.ContainsKey("access")) | ||
343 | Access = Byte.Parse((string)kvp["access"]); | ||
344 | |||
345 | if (kvp.ContainsKey("regionSecret")) | ||
346 | RegionSecret =(string)kvp["regionSecret"]; | ||
347 | |||
348 | } | ||
85 | } | 349 | } |
350 | |||
86 | } | 351 | } |
diff --git a/OpenSim/Services/Grid/GridService.cs b/OpenSim/Services/Interfaces/IHyperlink.cs index 47710d8..ed3ff23 100644 --- a/OpenSim/Services/Grid/GridService.cs +++ b/OpenSim/Services/Interfaces/IHyperlink.cs | |||
@@ -25,55 +25,25 @@ | |||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System.Collections.Generic; | 28 | using OpenSim.Framework; |
29 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | ||
30 | |||
29 | using OpenMetaverse; | 31 | using OpenMetaverse; |
30 | using OpenSim.Services.Interfaces; | ||
31 | 32 | ||
32 | namespace OpenSim.Services.Interfaces | 33 | namespace OpenSim.Services.Interfaces |
33 | { | 34 | { |
34 | public class GridService : IGridService | 35 | public interface IHyperlinkService |
35 | { | 36 | { |
36 | bool RegisterRegion(UUID scopeID, RegionInfo regionInfos); | 37 | GridRegion TryLinkRegion(IClientAPI client, string regionDescriptor); |
37 | { | 38 | GridRegion GetHyperlinkRegion(ulong handle); |
38 | return false; | 39 | ulong FindRegionHandle(ulong handle); |
39 | } | ||
40 | |||
41 | bool DeregisterRegion(UUID regionID); | ||
42 | { | ||
43 | return false; | ||
44 | } | ||
45 | |||
46 | List<SimpleRegionInfo> RequestNeighbours(UUID scopeID, uint x, uint y) | ||
47 | { | ||
48 | return new List<SimpleRegionInfo>() | ||
49 | } | ||
50 | |||
51 | RegionInfo RequestNeighbourInfo(UUID regionID) | ||
52 | { | ||
53 | return null; | ||
54 | } | ||
55 | |||
56 | RegionInfo RequestClosestRegion(UUID scopeID, string regionName) | ||
57 | { | ||
58 | return null; | ||
59 | } | ||
60 | 40 | ||
61 | List<MapBlockData> RequestNeighbourMapBlocks(UUID scopeID, int minX, | 41 | bool SendUserInformation(GridRegion region, AgentCircuitData aCircuit); |
62 | int minY, int maxX, int maxY) | 42 | void AdjustUserInformation(AgentCircuitData aCircuit); |
63 | { | ||
64 | return new List<MapBlockData>(); | ||
65 | } | ||
66 | 43 | ||
67 | LandData RequestLandData(UUID scopeID, ulong regionHandle, | 44 | bool CheckUserAtEntry(UUID userID, UUID sessionID, out bool comingHome); |
68 | uint x, uint y) | 45 | void AcceptUser(ForeignUserProfileData user, GridRegion home); |
69 | { | ||
70 | return null; | ||
71 | } | ||
72 | 46 | ||
73 | List<RegionInfo> RequestNamedRegions(UUID scopeID, string name, | 47 | bool IsLocalUser(UUID userID); |
74 | int maxNumber) | ||
75 | { | ||
76 | return new List<RegionInfo>(); | ||
77 | } | ||
78 | } | 48 | } |
79 | } | 49 | } |
diff --git a/OpenSim/Services/Interfaces/INeighbourService.cs b/OpenSim/Services/Interfaces/INeighbourService.cs index 3944486..960e13d 100644 --- a/OpenSim/Services/Interfaces/INeighbourService.cs +++ b/OpenSim/Services/Interfaces/INeighbourService.cs | |||
@@ -28,11 +28,12 @@ | |||
28 | using System; | 28 | using System; |
29 | using OpenSim.Framework; | 29 | using OpenSim.Framework; |
30 | using OpenMetaverse; | 30 | using OpenMetaverse; |
31 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | ||
31 | 32 | ||
32 | namespace OpenSim.Services.Interfaces | 33 | namespace OpenSim.Services.Interfaces |
33 | { | 34 | { |
34 | public interface INeighbourService | 35 | public interface INeighbourService |
35 | { | 36 | { |
36 | bool HelloNeighbour(ulong regionHandle, RegionInfo thisRegion); | 37 | GridRegion HelloNeighbour(ulong regionHandle, RegionInfo otherRegion); |
37 | } | 38 | } |
38 | } | 39 | } |
diff --git a/OpenSim/Services/InventoryService/InventoryService.cs b/OpenSim/Services/InventoryService/InventoryService.cs index b98e256..70c55a5 100644 --- a/OpenSim/Services/InventoryService/InventoryService.cs +++ b/OpenSim/Services/InventoryService/InventoryService.cs | |||
@@ -251,7 +251,7 @@ namespace OpenSim.Services.InventoryService | |||
251 | 251 | ||
252 | m_log.DebugFormat("[INVENTORY SERVICE]: Found {0} items and {1} folders in folder {2}", items.Count, folders.Count, folderID); | 252 | m_log.DebugFormat("[INVENTORY SERVICE]: Found {0} items and {1} folders in folder {2}", items.Count, folders.Count, folderID); |
253 | 253 | ||
254 | return invCollection; | 254 | return invCollection; |
255 | } | 255 | } |
256 | 256 | ||
257 | public InventoryFolderBase GetFolderForType(UUID userID, AssetType type) | 257 | public InventoryFolderBase GetFolderForType(UUID userID, AssetType type) |