diff options
author | Diva Canto | 2010-01-10 20:29:09 -0800 |
---|---|---|
committer | Diva Canto | 2010-01-10 20:29:09 -0800 |
commit | dc4bbf6065ad4cb914c9d44f2e6496a2e3d99814 (patch) | |
tree | f4cf3aa9f25ca879b87e14941ca4c19197e7c942 /OpenSim/Region | |
parent | All grid servers deleted, including user server. They served us well. (diff) | |
download | opensim-SC-dc4bbf6065ad4cb914c9d44f2e6496a2e3d99814.zip opensim-SC-dc4bbf6065ad4cb914c9d44f2e6496a2e3d99814.tar.gz opensim-SC-dc4bbf6065ad4cb914c9d44f2e6496a2e3d99814.tar.bz2 opensim-SC-dc4bbf6065ad4cb914c9d44f2e6496a2e3d99814.tar.xz |
All Framework.Communications.Clients and Framework.Communications.Services deleted, including old LoginService.
Diffstat (limited to 'OpenSim/Region')
9 files changed, 4 insertions, 1219 deletions
diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs index a834786..d745fdc 100644 --- a/OpenSim/Region/Application/OpenSimBase.cs +++ b/OpenSim/Region/Application/OpenSimBase.cs | |||
@@ -36,7 +36,6 @@ using Nini.Config; | |||
36 | using OpenMetaverse; | 36 | using OpenMetaverse; |
37 | using OpenSim.Framework; | 37 | using OpenSim.Framework; |
38 | using OpenSim.Framework.Communications; | 38 | using OpenSim.Framework.Communications; |
39 | using OpenSim.Framework.Communications.Services; | ||
40 | using OpenSim.Framework.Communications.Cache; | 39 | using OpenSim.Framework.Communications.Cache; |
41 | using OpenSim.Framework.Console; | 40 | using OpenSim.Framework.Console; |
42 | using OpenSim.Framework.Servers; | 41 | using OpenSim.Framework.Servers; |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/LocalInterregionComms.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/LocalInterregionComms.cs deleted file mode 100644 index d68c683..0000000 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/LocalInterregionComms.cs +++ /dev/null | |||
@@ -1,319 +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 | using System; | ||
28 | using System.Collections.Generic; | ||
29 | using System.Reflection; | ||
30 | using log4net; | ||
31 | using Nini.Config; | ||
32 | using OpenMetaverse; | ||
33 | using OpenSim.Framework; | ||
34 | using OpenSim.Region.Framework.Interfaces; | ||
35 | using OpenSim.Region.Framework.Scenes; | ||
36 | |||
37 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion | ||
38 | { | ||
39 | public class LocalInterregionComms : ISharedRegionModule, IInterregionCommsOut, IInterregionCommsIn | ||
40 | { | ||
41 | private bool m_enabled = false; | ||
42 | |||
43 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
44 | private List<Scene> m_sceneList = new List<Scene>(); | ||
45 | |||
46 | #region Events | ||
47 | public event ChildAgentUpdateReceived OnChildAgentUpdate; | ||
48 | |||
49 | #endregion /* Events */ | ||
50 | |||
51 | #region IRegionModule | ||
52 | |||
53 | public void Initialise(IConfigSource config) | ||
54 | { | ||
55 | if (m_sceneList.Count == 0) | ||
56 | { | ||
57 | IConfig startupConfig = config.Configs["Communications"]; | ||
58 | |||
59 | if ((startupConfig != null) && (startupConfig.GetString("InterregionComms", "RESTComms") == "LocalComms")) | ||
60 | { | ||
61 | m_log.Debug("[LOCAL COMMS]: Enabling InterregionComms LocalComms module"); | ||
62 | m_enabled = true; | ||
63 | } | ||
64 | } | ||
65 | } | ||
66 | |||
67 | public void PostInitialise() | ||
68 | { | ||
69 | } | ||
70 | |||
71 | public void AddRegion(Scene scene) | ||
72 | { | ||
73 | } | ||
74 | |||
75 | public void RemoveRegion(Scene scene) | ||
76 | { | ||
77 | if (m_enabled) | ||
78 | { | ||
79 | RemoveScene(scene); | ||
80 | } | ||
81 | } | ||
82 | |||
83 | public void RegionLoaded(Scene scene) | ||
84 | { | ||
85 | if (m_enabled) | ||
86 | { | ||
87 | Init(scene); | ||
88 | } | ||
89 | } | ||
90 | |||
91 | public void Close() | ||
92 | { | ||
93 | } | ||
94 | |||
95 | public Type ReplaceableInterface | ||
96 | { | ||
97 | get { return null; } | ||
98 | } | ||
99 | |||
100 | public string Name | ||
101 | { | ||
102 | get { return "LocalInterregionCommsModule"; } | ||
103 | } | ||
104 | |||
105 | /// <summary> | ||
106 | /// Can be called from other modules. | ||
107 | /// </summary> | ||
108 | /// <param name="scene"></param> | ||
109 | public void RemoveScene(Scene scene) | ||
110 | { | ||
111 | lock (m_sceneList) | ||
112 | { | ||
113 | if (m_sceneList.Contains(scene)) | ||
114 | { | ||
115 | m_sceneList.Remove(scene); | ||
116 | } | ||
117 | } | ||
118 | } | ||
119 | |||
120 | /// <summary> | ||
121 | /// Can be called from other modules. | ||
122 | /// </summary> | ||
123 | /// <param name="scene"></param> | ||
124 | public void Init(Scene scene) | ||
125 | { | ||
126 | if (!m_sceneList.Contains(scene)) | ||
127 | { | ||
128 | lock (m_sceneList) | ||
129 | { | ||
130 | m_sceneList.Add(scene); | ||
131 | if (m_enabled) | ||
132 | scene.RegisterModuleInterface<IInterregionCommsOut>(this); | ||
133 | scene.RegisterModuleInterface<IInterregionCommsIn>(this); | ||
134 | } | ||
135 | |||
136 | } | ||
137 | } | ||
138 | |||
139 | #endregion /* IRegionModule */ | ||
140 | |||
141 | #region IInterregionComms | ||
142 | |||
143 | /** | ||
144 | * Agent-related communications | ||
145 | */ | ||
146 | |||
147 | public bool SendCreateChildAgent(ulong regionHandle, AgentCircuitData aCircuit, uint teleportFlags, out string reason) | ||
148 | { | ||
149 | |||
150 | foreach (Scene s in m_sceneList) | ||
151 | { | ||
152 | if (s.RegionInfo.RegionHandle == regionHandle) | ||
153 | { | ||
154 | // m_log.DebugFormat("[LOCAL COMMS]: Found region {0} to send SendCreateChildAgent", regionHandle); | ||
155 | return s.NewUserConnection(aCircuit, teleportFlags, out reason); | ||
156 | } | ||
157 | } | ||
158 | |||
159 | // m_log.DebugFormat("[LOCAL COMMS]: Did not find region {0} for SendCreateChildAgent", regionHandle); | ||
160 | uint x = 0, y = 0; | ||
161 | Utils.LongToUInts(regionHandle, out x, out y); | ||
162 | reason = "Did not find region " + x + "-" + y; | ||
163 | return false; | ||
164 | } | ||
165 | |||
166 | public bool SendChildAgentUpdate(ulong regionHandle, AgentData cAgentData) | ||
167 | { | ||
168 | foreach (Scene s in m_sceneList) | ||
169 | { | ||
170 | if (s.RegionInfo.RegionHandle == regionHandle) | ||
171 | { | ||
172 | //m_log.DebugFormat( | ||
173 | // "[LOCAL COMMS]: Found region {0} {1} to send ChildAgentUpdate", | ||
174 | // s.RegionInfo.RegionName, regionHandle); | ||
175 | |||
176 | s.IncomingChildAgentDataUpdate(cAgentData); | ||
177 | return true; | ||
178 | } | ||
179 | } | ||
180 | |||
181 | // m_log.DebugFormat("[LOCAL COMMS]: Did not find region {0} for ChildAgentUpdate", regionHandle); | ||
182 | return false; | ||
183 | } | ||
184 | |||
185 | public bool SendChildAgentUpdate(ulong regionHandle, AgentPosition cAgentData) | ||
186 | { | ||
187 | foreach (Scene s in m_sceneList) | ||
188 | { | ||
189 | if (s.RegionInfo.RegionHandle == regionHandle) | ||
190 | { | ||
191 | //m_log.Debug("[LOCAL COMMS]: Found region to send ChildAgentUpdate"); | ||
192 | s.IncomingChildAgentDataUpdate(cAgentData); | ||
193 | return true; | ||
194 | } | ||
195 | } | ||
196 | //m_log.Debug("[LOCAL COMMS]: region not found for ChildAgentUpdate"); | ||
197 | return false; | ||
198 | } | ||
199 | |||
200 | public bool SendRetrieveRootAgent(ulong regionHandle, UUID id, out IAgentData agent) | ||
201 | { | ||
202 | agent = null; | ||
203 | foreach (Scene s in m_sceneList) | ||
204 | { | ||
205 | if (s.RegionInfo.RegionHandle == regionHandle) | ||
206 | { | ||
207 | //m_log.Debug("[LOCAL COMMS]: Found region to send ChildAgentUpdate"); | ||
208 | return s.IncomingRetrieveRootAgent(id, out agent); | ||
209 | } | ||
210 | } | ||
211 | //m_log.Debug("[LOCAL COMMS]: region not found for ChildAgentUpdate"); | ||
212 | return false; | ||
213 | } | ||
214 | |||
215 | public bool SendReleaseAgent(ulong regionHandle, UUID id, string uri) | ||
216 | { | ||
217 | //uint x, y; | ||
218 | //Utils.LongToUInts(regionHandle, out x, out y); | ||
219 | //x = x / Constants.RegionSize; | ||
220 | //y = y / Constants.RegionSize; | ||
221 | //m_log.Debug("\n >>> Local SendReleaseAgent " + x + "-" + y); | ||
222 | foreach (Scene s in m_sceneList) | ||
223 | { | ||
224 | if (s.RegionInfo.RegionHandle == regionHandle) | ||
225 | { | ||
226 | //m_log.Debug("[LOCAL COMMS]: Found region to SendReleaseAgent"); | ||
227 | return s.IncomingReleaseAgent(id); | ||
228 | } | ||
229 | } | ||
230 | //m_log.Debug("[LOCAL COMMS]: region not found in SendReleaseAgent"); | ||
231 | return false; | ||
232 | } | ||
233 | |||
234 | public bool SendCloseAgent(ulong regionHandle, UUID id) | ||
235 | { | ||
236 | //uint x, y; | ||
237 | //Utils.LongToUInts(regionHandle, out x, out y); | ||
238 | //x = x / Constants.RegionSize; | ||
239 | //y = y / Constants.RegionSize; | ||
240 | //m_log.Debug("\n >>> Local SendCloseAgent " + x + "-" + y); | ||
241 | foreach (Scene s in m_sceneList) | ||
242 | { | ||
243 | if (s.RegionInfo.RegionHandle == regionHandle) | ||
244 | { | ||
245 | //m_log.Debug("[LOCAL COMMS]: Found region to SendCloseAgent"); | ||
246 | return s.IncomingCloseAgent(id); | ||
247 | } | ||
248 | } | ||
249 | //m_log.Debug("[LOCAL COMMS]: region not found in SendCloseAgent"); | ||
250 | return false; | ||
251 | } | ||
252 | |||
253 | /** | ||
254 | * Object-related communications | ||
255 | */ | ||
256 | |||
257 | public bool SendCreateObject(ulong regionHandle, SceneObjectGroup sog, bool isLocalCall) | ||
258 | { | ||
259 | foreach (Scene s in m_sceneList) | ||
260 | { | ||
261 | if (s.RegionInfo.RegionHandle == regionHandle) | ||
262 | { | ||
263 | //m_log.Debug("[LOCAL COMMS]: Found region to SendCreateObject"); | ||
264 | if (isLocalCall) | ||
265 | { | ||
266 | // We need to make a local copy of the object | ||
267 | ISceneObject sogClone = sog.CloneForNewScene(); | ||
268 | sogClone.SetState(sog.GetStateSnapshot(), s); | ||
269 | return s.IncomingCreateObject(sogClone); | ||
270 | } | ||
271 | else | ||
272 | { | ||
273 | // Use the object as it came through the wire | ||
274 | return s.IncomingCreateObject(sog); | ||
275 | } | ||
276 | } | ||
277 | } | ||
278 | return false; | ||
279 | } | ||
280 | |||
281 | public bool SendCreateObject(ulong regionHandle, UUID userID, UUID itemID) | ||
282 | { | ||
283 | foreach (Scene s in m_sceneList) | ||
284 | { | ||
285 | if (s.RegionInfo.RegionHandle == regionHandle) | ||
286 | { | ||
287 | return s.IncomingCreateObject(userID, itemID); | ||
288 | } | ||
289 | } | ||
290 | return false; | ||
291 | } | ||
292 | |||
293 | |||
294 | #endregion /* IInterregionComms */ | ||
295 | |||
296 | #region Misc | ||
297 | |||
298 | public Scene GetScene(ulong regionhandle) | ||
299 | { | ||
300 | foreach (Scene s in m_sceneList) | ||
301 | { | ||
302 | if (s.RegionInfo.RegionHandle == regionhandle) | ||
303 | return s; | ||
304 | } | ||
305 | // ? weird. should not happen | ||
306 | return m_sceneList[0]; | ||
307 | } | ||
308 | |||
309 | public bool IsLocalRegion(ulong regionhandle) | ||
310 | { | ||
311 | foreach (Scene s in m_sceneList) | ||
312 | if (s.RegionInfo.RegionHandle == regionhandle) | ||
313 | return true; | ||
314 | return false; | ||
315 | } | ||
316 | |||
317 | #endregion | ||
318 | } | ||
319 | } | ||
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/RESTInterregionComms.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/RESTInterregionComms.cs deleted file mode 100644 index 10ab76f..0000000 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/RESTInterregionComms.cs +++ /dev/null | |||
@@ -1,844 +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 | |||
28 | using System; | ||
29 | using System.Collections; | ||
30 | using System.IO; | ||
31 | using System.Net; | ||
32 | using System.Reflection; | ||
33 | using System.Text; | ||
34 | using log4net; | ||
35 | using Nini.Config; | ||
36 | using OpenMetaverse; | ||
37 | using OpenMetaverse.StructuredData; | ||
38 | using OpenSim.Framework; | ||
39 | using OpenSim.Framework.Communications; | ||
40 | using OpenSim.Framework.Communications.Clients; | ||
41 | using OpenSim.Region.Framework.Interfaces; | ||
42 | using OpenSim.Region.Framework.Scenes; | ||
43 | using OpenSim.Region.Framework.Scenes.Hypergrid; | ||
44 | using OpenSim.Region.Framework.Scenes.Serialization; | ||
45 | using OpenSim.Services.Interfaces; | ||
46 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | ||
47 | |||
48 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion | ||
49 | { | ||
50 | public class RESTInterregionComms : ISharedRegionModule, IInterregionCommsOut | ||
51 | { | ||
52 | private bool initialized = false; | ||
53 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
54 | |||
55 | protected bool m_enabled = false; | ||
56 | protected Scene m_aScene; | ||
57 | // RESTInterregionComms does not care about local regions; it delegates that to the Local module | ||
58 | protected LocalInterregionComms m_localBackend; | ||
59 | |||
60 | protected CommunicationsManager m_commsManager; | ||
61 | |||
62 | protected RegionToRegionClient m_regionClient; | ||
63 | |||
64 | protected IHyperlinkService m_hyperlinkService; | ||
65 | |||
66 | protected bool m_safemode; | ||
67 | protected IPAddress m_thisIP; | ||
68 | |||
69 | #region IRegionModule | ||
70 | |||
71 | public virtual void Initialise(IConfigSource config) | ||
72 | { | ||
73 | IConfig startupConfig = config.Configs["Communications"]; | ||
74 | |||
75 | if ((startupConfig == null) || ((startupConfig != null) | ||
76 | && (startupConfig.GetString("InterregionComms", "RESTComms") == "RESTComms"))) | ||
77 | { | ||
78 | m_log.Info("[REST COMMS]: Enabling InterregionComms RESTComms module"); | ||
79 | m_enabled = true; | ||
80 | if (config.Configs["Hypergrid"] != null) | ||
81 | m_safemode = config.Configs["Hypergrid"].GetBoolean("safemode", false); | ||
82 | } | ||
83 | } | ||
84 | |||
85 | public virtual void PostInitialise() | ||
86 | { | ||
87 | } | ||
88 | |||
89 | public virtual void Close() | ||
90 | { | ||
91 | } | ||
92 | |||
93 | public void AddRegion(Scene scene) | ||
94 | { | ||
95 | } | ||
96 | |||
97 | public void RemoveRegion(Scene scene) | ||
98 | { | ||
99 | if (m_enabled) | ||
100 | { | ||
101 | m_localBackend.RemoveScene(scene); | ||
102 | scene.UnregisterModuleInterface<IInterregionCommsOut>(this); | ||
103 | } | ||
104 | } | ||
105 | |||
106 | public void RegionLoaded(Scene scene) | ||
107 | { | ||
108 | if (m_enabled) | ||
109 | { | ||
110 | if (!initialized) | ||
111 | { | ||
112 | InitOnce(scene); | ||
113 | initialized = true; | ||
114 | AddHTTPHandlers(); | ||
115 | } | ||
116 | InitEach(scene); | ||
117 | } | ||
118 | } | ||
119 | |||
120 | public Type ReplaceableInterface | ||
121 | { | ||
122 | get { return null; } | ||
123 | } | ||
124 | |||
125 | public virtual string Name | ||
126 | { | ||
127 | get { return "RESTInterregionCommsModule"; } | ||
128 | } | ||
129 | |||
130 | protected virtual void InitEach(Scene scene) | ||
131 | { | ||
132 | m_localBackend.Init(scene); | ||
133 | scene.RegisterModuleInterface<IInterregionCommsOut>(this); | ||
134 | } | ||
135 | |||
136 | protected virtual void InitOnce(Scene scene) | ||
137 | { | ||
138 | m_localBackend = new LocalInterregionComms(); | ||
139 | m_commsManager = scene.CommsManager; | ||
140 | m_aScene = scene; | ||
141 | m_hyperlinkService = m_aScene.RequestModuleInterface<IHyperlinkService>(); | ||
142 | m_regionClient = new RegionToRegionClient(m_aScene, m_hyperlinkService); | ||
143 | m_thisIP = Util.GetHostFromDNS(scene.RegionInfo.ExternalHostName); | ||
144 | } | ||
145 | |||
146 | protected virtual void AddHTTPHandlers() | ||
147 | { | ||
148 | MainServer.Instance.AddHTTPHandler("/agent/", AgentHandler); | ||
149 | MainServer.Instance.AddHTTPHandler("/object/", ObjectHandler); | ||
150 | } | ||
151 | |||
152 | #endregion /* IRegionModule */ | ||
153 | |||
154 | #region IInterregionComms | ||
155 | |||
156 | /** | ||
157 | * Agent-related communications | ||
158 | */ | ||
159 | |||
160 | public bool SendCreateChildAgent(ulong regionHandle, AgentCircuitData aCircuit, uint teleportFlags, out string reason) | ||
161 | { | ||
162 | // Try local first | ||
163 | if (m_localBackend.SendCreateChildAgent(regionHandle, aCircuit, teleportFlags, out reason)) | ||
164 | return true; | ||
165 | |||
166 | // else do the remote thing | ||
167 | if (!m_localBackend.IsLocalRegion(regionHandle)) | ||
168 | { | ||
169 | uint x = 0, y = 0; | ||
170 | Utils.LongToUInts(regionHandle, out x, out y); | ||
171 | GridRegion regInfo = m_aScene.GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y); | ||
172 | if (regInfo != null) | ||
173 | { | ||
174 | m_regionClient.SendUserInformation(regInfo, aCircuit); | ||
175 | |||
176 | return m_regionClient.DoCreateChildAgentCall(regInfo, aCircuit, "None", teleportFlags, out reason); | ||
177 | } | ||
178 | //else | ||
179 | // m_log.Warn("[REST COMMS]: Region not found " + regionHandle); | ||
180 | } | ||
181 | return false; | ||
182 | } | ||
183 | |||
184 | public bool SendChildAgentUpdate(ulong regionHandle, AgentData cAgentData) | ||
185 | { | ||
186 | // Try local first | ||
187 | if (m_localBackend.SendChildAgentUpdate(regionHandle, cAgentData)) | ||
188 | return true; | ||
189 | |||
190 | // else do the remote thing | ||
191 | if (!m_localBackend.IsLocalRegion(regionHandle)) | ||
192 | { | ||
193 | uint x = 0, y = 0; | ||
194 | Utils.LongToUInts(regionHandle, out x, out y); | ||
195 | GridRegion regInfo = m_aScene.GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y); | ||
196 | if (regInfo != null) | ||
197 | { | ||
198 | return m_regionClient.DoChildAgentUpdateCall(regInfo, cAgentData); | ||
199 | } | ||
200 | //else | ||
201 | // m_log.Warn("[REST COMMS]: Region not found " + regionHandle); | ||
202 | } | ||
203 | return false; | ||
204 | |||
205 | } | ||
206 | |||
207 | public bool SendChildAgentUpdate(ulong regionHandle, AgentPosition cAgentData) | ||
208 | { | ||
209 | // Try local first | ||
210 | if (m_localBackend.SendChildAgentUpdate(regionHandle, cAgentData)) | ||
211 | return true; | ||
212 | |||
213 | // else do the remote thing | ||
214 | if (!m_localBackend.IsLocalRegion(regionHandle)) | ||
215 | { | ||
216 | uint x = 0, y = 0; | ||
217 | Utils.LongToUInts(regionHandle, out x, out y); | ||
218 | GridRegion regInfo = m_aScene.GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y); | ||
219 | if (regInfo != null) | ||
220 | { | ||
221 | return m_regionClient.DoChildAgentUpdateCall(regInfo, cAgentData); | ||
222 | } | ||
223 | //else | ||
224 | // m_log.Warn("[REST COMMS]: Region not found " + regionHandle); | ||
225 | } | ||
226 | return false; | ||
227 | |||
228 | } | ||
229 | |||
230 | public bool SendRetrieveRootAgent(ulong regionHandle, UUID id, out IAgentData agent) | ||
231 | { | ||
232 | // Try local first | ||
233 | if (m_localBackend.SendRetrieveRootAgent(regionHandle, id, out agent)) | ||
234 | return true; | ||
235 | |||
236 | // else do the remote thing | ||
237 | if (!m_localBackend.IsLocalRegion(regionHandle)) | ||
238 | { | ||
239 | uint x = 0, y = 0; | ||
240 | Utils.LongToUInts(regionHandle, out x, out y); | ||
241 | GridRegion regInfo = m_aScene.GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y); | ||
242 | if (regInfo != null) | ||
243 | { | ||
244 | return m_regionClient.DoRetrieveRootAgentCall(regInfo, id, out agent); | ||
245 | } | ||
246 | //else | ||
247 | // m_log.Warn("[REST COMMS]: Region not found " + regionHandle); | ||
248 | } | ||
249 | return false; | ||
250 | |||
251 | } | ||
252 | |||
253 | public bool SendReleaseAgent(ulong regionHandle, UUID id, string uri) | ||
254 | { | ||
255 | // Try local first | ||
256 | if (m_localBackend.SendReleaseAgent(regionHandle, id, uri)) | ||
257 | return true; | ||
258 | |||
259 | // else do the remote thing | ||
260 | return m_regionClient.DoReleaseAgentCall(regionHandle, id, uri); | ||
261 | } | ||
262 | |||
263 | |||
264 | public bool SendCloseAgent(ulong regionHandle, UUID id) | ||
265 | { | ||
266 | // Try local first | ||
267 | if (m_localBackend.SendCloseAgent(regionHandle, id)) | ||
268 | return true; | ||
269 | |||
270 | // else do the remote thing | ||
271 | if (!m_localBackend.IsLocalRegion(regionHandle)) | ||
272 | { | ||
273 | uint x = 0, y = 0; | ||
274 | Utils.LongToUInts(regionHandle, out x, out y); | ||
275 | GridRegion regInfo = m_aScene.GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y); | ||
276 | if (regInfo != null) | ||
277 | { | ||
278 | return m_regionClient.DoCloseAgentCall(regInfo, id); | ||
279 | } | ||
280 | //else | ||
281 | // m_log.Warn("[REST COMMS]: Region not found " + regionHandle); | ||
282 | } | ||
283 | return false; | ||
284 | } | ||
285 | |||
286 | /** | ||
287 | * Object-related communications | ||
288 | */ | ||
289 | |||
290 | public bool SendCreateObject(ulong regionHandle, SceneObjectGroup sog, bool isLocalCall) | ||
291 | { | ||
292 | // Try local first | ||
293 | if (m_localBackend.SendCreateObject(regionHandle, sog, true)) | ||
294 | { | ||
295 | //m_log.Debug("[REST COMMS]: LocalBackEnd SendCreateObject succeeded"); | ||
296 | return true; | ||
297 | } | ||
298 | |||
299 | // else do the remote thing | ||
300 | if (!m_localBackend.IsLocalRegion(regionHandle)) | ||
301 | { | ||
302 | uint x = 0, y = 0; | ||
303 | Utils.LongToUInts(regionHandle, out x, out y); | ||
304 | GridRegion regInfo = m_aScene.GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y); | ||
305 | if (regInfo != null) | ||
306 | { | ||
307 | return m_regionClient.DoCreateObjectCall( | ||
308 | regInfo, sog, SceneObjectSerializer.ToXml2Format(sog), m_aScene.m_allowScriptCrossings); | ||
309 | } | ||
310 | //else | ||
311 | // m_log.Warn("[REST COMMS]: Region not found " + regionHandle); | ||
312 | } | ||
313 | return false; | ||
314 | } | ||
315 | |||
316 | public bool SendCreateObject(ulong regionHandle, UUID userID, UUID itemID) | ||
317 | { | ||
318 | // Not Implemented | ||
319 | return false; | ||
320 | } | ||
321 | |||
322 | #endregion /* IInterregionComms */ | ||
323 | |||
324 | #region Incoming calls from remote instances | ||
325 | |||
326 | /** | ||
327 | * Agent-related incoming calls | ||
328 | */ | ||
329 | |||
330 | public Hashtable AgentHandler(Hashtable request) | ||
331 | { | ||
332 | //m_log.Debug("[CONNECTION DEBUGGING]: AgentHandler Called"); | ||
333 | |||
334 | m_log.Debug("---------------------------"); | ||
335 | m_log.Debug(" >> uri=" + request["uri"]); | ||
336 | m_log.Debug(" >> content-type=" + request["content-type"]); | ||
337 | m_log.Debug(" >> http-method=" + request["http-method"]); | ||
338 | m_log.Debug("---------------------------\n"); | ||
339 | |||
340 | Hashtable responsedata = new Hashtable(); | ||
341 | responsedata["content_type"] = "text/html"; | ||
342 | responsedata["keepalive"] = false; | ||
343 | |||
344 | |||
345 | UUID agentID; | ||
346 | string action; | ||
347 | ulong regionHandle; | ||
348 | if (!GetParams((string)request["uri"], out agentID, out regionHandle, out action)) | ||
349 | { | ||
350 | m_log.InfoFormat("[REST COMMS]: Invalid parameters for agent message {0}", request["uri"]); | ||
351 | responsedata["int_response_code"] = 404; | ||
352 | responsedata["str_response_string"] = "false"; | ||
353 | |||
354 | return responsedata; | ||
355 | } | ||
356 | |||
357 | // Next, let's parse the verb | ||
358 | string method = (string)request["http-method"]; | ||
359 | if (method.Equals("PUT")) | ||
360 | { | ||
361 | DoAgentPut(request, responsedata); | ||
362 | return responsedata; | ||
363 | } | ||
364 | else if (method.Equals("POST")) | ||
365 | { | ||
366 | DoAgentPost(request, responsedata, agentID); | ||
367 | return responsedata; | ||
368 | } | ||
369 | else if (method.Equals("GET")) | ||
370 | { | ||
371 | DoAgentGet(request, responsedata, agentID, regionHandle); | ||
372 | return responsedata; | ||
373 | } | ||
374 | else if (method.Equals("DELETE")) | ||
375 | { | ||
376 | DoAgentDelete(request, responsedata, agentID, action, regionHandle); | ||
377 | return responsedata; | ||
378 | } | ||
379 | else | ||
380 | { | ||
381 | m_log.InfoFormat("[REST COMMS]: method {0} not supported in agent message", method); | ||
382 | responsedata["int_response_code"] = 404; | ||
383 | responsedata["str_response_string"] = "false"; | ||
384 | |||
385 | return responsedata; | ||
386 | } | ||
387 | |||
388 | } | ||
389 | |||
390 | protected virtual void DoAgentPost(Hashtable request, Hashtable responsedata, UUID id) | ||
391 | { | ||
392 | if (m_safemode) | ||
393 | { | ||
394 | // Authentication | ||
395 | string authority = string.Empty; | ||
396 | string authToken = string.Empty; | ||
397 | if (!GetAuthentication(request, out authority, out authToken)) | ||
398 | { | ||
399 | m_log.InfoFormat("[REST COMMS]: Authentication failed for agent message {0}", request["uri"]); | ||
400 | responsedata["int_response_code"] = 403; | ||
401 | responsedata["str_response_string"] = "Forbidden"; | ||
402 | return ; | ||
403 | } | ||
404 | if (!VerifyKey(id, authority, authToken)) | ||
405 | { | ||
406 | m_log.InfoFormat("[REST COMMS]: Authentication failed for agent message {0}", request["uri"]); | ||
407 | responsedata["int_response_code"] = 403; | ||
408 | responsedata["str_response_string"] = "Forbidden"; | ||
409 | return ; | ||
410 | } | ||
411 | m_log.DebugFormat("[REST COMMS]: Authentication succeeded for {0}", id); | ||
412 | } | ||
413 | |||
414 | OSDMap args = RegionClient.GetOSDMap((string)request["body"]); | ||
415 | if (args == null) | ||
416 | { | ||
417 | responsedata["int_response_code"] = 400; | ||
418 | responsedata["str_response_string"] = "false"; | ||
419 | return; | ||
420 | } | ||
421 | |||
422 | // retrieve the regionhandle | ||
423 | ulong regionhandle = 0; | ||
424 | if (args["destination_handle"] != null) | ||
425 | UInt64.TryParse(args["destination_handle"].AsString(), out regionhandle); | ||
426 | |||
427 | AgentCircuitData aCircuit = new AgentCircuitData(); | ||
428 | try | ||
429 | { | ||
430 | aCircuit.UnpackAgentCircuitData(args); | ||
431 | } | ||
432 | catch (Exception ex) | ||
433 | { | ||
434 | m_log.InfoFormat("[REST COMMS]: exception on unpacking ChildCreate message {0}", ex.Message); | ||
435 | return; | ||
436 | } | ||
437 | |||
438 | OSDMap resp = new OSDMap(2); | ||
439 | string reason = String.Empty; | ||
440 | uint teleportFlags = 0; | ||
441 | if (args.ContainsKey("teleport_flags")) | ||
442 | { | ||
443 | teleportFlags = args["teleport_flags"].AsUInteger(); | ||
444 | } | ||
445 | |||
446 | // This is the meaning of POST agent | ||
447 | m_regionClient.AdjustUserInformation(aCircuit); | ||
448 | bool result = m_localBackend.SendCreateChildAgent(regionhandle, aCircuit, teleportFlags, out reason); | ||
449 | |||
450 | resp["reason"] = OSD.FromString(reason); | ||
451 | resp["success"] = OSD.FromBoolean(result); | ||
452 | |||
453 | // TODO: add reason if not String.Empty? | ||
454 | responsedata["int_response_code"] = 200; | ||
455 | responsedata["str_response_string"] = OSDParser.SerializeJsonString(resp); | ||
456 | } | ||
457 | |||
458 | protected virtual void DoAgentPut(Hashtable request, Hashtable responsedata) | ||
459 | { | ||
460 | OSDMap args = RegionClient.GetOSDMap((string)request["body"]); | ||
461 | if (args == null) | ||
462 | { | ||
463 | responsedata["int_response_code"] = 400; | ||
464 | responsedata["str_response_string"] = "false"; | ||
465 | return; | ||
466 | } | ||
467 | |||
468 | // retrieve the regionhandle | ||
469 | ulong regionhandle = 0; | ||
470 | if (args["destination_handle"] != null) | ||
471 | UInt64.TryParse(args["destination_handle"].AsString(), out regionhandle); | ||
472 | |||
473 | string messageType; | ||
474 | if (args["message_type"] != null) | ||
475 | messageType = args["message_type"].AsString(); | ||
476 | else | ||
477 | { | ||
478 | m_log.Warn("[REST COMMS]: Agent Put Message Type not found. "); | ||
479 | messageType = "AgentData"; | ||
480 | } | ||
481 | |||
482 | bool result = true; | ||
483 | if ("AgentData".Equals(messageType)) | ||
484 | { | ||
485 | AgentData agent = new AgentData(); | ||
486 | try | ||
487 | { | ||
488 | agent.Unpack(args); | ||
489 | } | ||
490 | catch (Exception ex) | ||
491 | { | ||
492 | m_log.InfoFormat("[REST COMMS]: exception on unpacking ChildAgentUpdate message {0}", ex.Message); | ||
493 | return; | ||
494 | } | ||
495 | |||
496 | //agent.Dump(); | ||
497 | // This is one of the meanings of PUT agent | ||
498 | result = m_localBackend.SendChildAgentUpdate(regionhandle, agent); | ||
499 | |||
500 | } | ||
501 | else if ("AgentPosition".Equals(messageType)) | ||
502 | { | ||
503 | AgentPosition agent = new AgentPosition(); | ||
504 | try | ||
505 | { | ||
506 | agent.Unpack(args); | ||
507 | } | ||
508 | catch (Exception ex) | ||
509 | { | ||
510 | m_log.InfoFormat("[REST COMMS]: exception on unpacking ChildAgentUpdate message {0}", ex.Message); | ||
511 | return; | ||
512 | } | ||
513 | //agent.Dump(); | ||
514 | // This is one of the meanings of PUT agent | ||
515 | result = m_localBackend.SendChildAgentUpdate(regionhandle, agent); | ||
516 | |||
517 | } | ||
518 | |||
519 | responsedata["int_response_code"] = 200; | ||
520 | responsedata["str_response_string"] = result.ToString(); | ||
521 | } | ||
522 | |||
523 | protected virtual void DoAgentGet(Hashtable request, Hashtable responsedata, UUID id, ulong regionHandle) | ||
524 | { | ||
525 | IAgentData agent = null; | ||
526 | bool result = m_localBackend.SendRetrieveRootAgent(regionHandle, id, out agent); | ||
527 | OSDMap map = null; | ||
528 | if (result) | ||
529 | { | ||
530 | if (agent != null) // just to make sure | ||
531 | { | ||
532 | map = agent.Pack(); | ||
533 | string strBuffer = ""; | ||
534 | try | ||
535 | { | ||
536 | strBuffer = OSDParser.SerializeJsonString(map); | ||
537 | } | ||
538 | catch (Exception e) | ||
539 | { | ||
540 | m_log.WarnFormat("[REST COMMS]: Exception thrown on serialization of CreateObject: {0}", e.Message); | ||
541 | // ignore. buffer will be empty, caller should check. | ||
542 | } | ||
543 | |||
544 | responsedata["content_type"] = "application/json"; | ||
545 | responsedata["int_response_code"] = 200; | ||
546 | responsedata["str_response_string"] = strBuffer; | ||
547 | } | ||
548 | else | ||
549 | { | ||
550 | responsedata["int_response_code"] = 500; | ||
551 | responsedata["str_response_string"] = "Internal error"; | ||
552 | } | ||
553 | } | ||
554 | else | ||
555 | { | ||
556 | responsedata["int_response_code"] = 404; | ||
557 | responsedata["str_response_string"] = "Not Found"; | ||
558 | } | ||
559 | } | ||
560 | |||
561 | protected virtual void DoAgentDelete(Hashtable request, Hashtable responsedata, UUID id, string action, ulong regionHandle) | ||
562 | { | ||
563 | //m_log.Debug(" >>> DoDelete action:" + action + "; regionHandle:" + regionHandle); | ||
564 | |||
565 | if (action.Equals("release")) | ||
566 | m_localBackend.SendReleaseAgent(regionHandle, id, ""); | ||
567 | else | ||
568 | m_localBackend.SendCloseAgent(regionHandle, id); | ||
569 | |||
570 | responsedata["int_response_code"] = 200; | ||
571 | responsedata["str_response_string"] = "OpenSim agent " + id.ToString(); | ||
572 | |||
573 | m_log.Debug("[REST COMMS]: Agent Deleted."); | ||
574 | } | ||
575 | |||
576 | /** | ||
577 | * Object-related incoming calls | ||
578 | */ | ||
579 | |||
580 | public Hashtable ObjectHandler(Hashtable request) | ||
581 | { | ||
582 | m_log.Debug("[CONNECTION DEBUGGING]: ObjectHandler Called"); | ||
583 | |||
584 | m_log.Debug("---------------------------"); | ||
585 | m_log.Debug(" >> uri=" + request["uri"]); | ||
586 | m_log.Debug(" >> content-type=" + request["content-type"]); | ||
587 | m_log.Debug(" >> http-method=" + request["http-method"]); | ||
588 | m_log.Debug("---------------------------\n"); | ||
589 | |||
590 | Hashtable responsedata = new Hashtable(); | ||
591 | responsedata["content_type"] = "text/html"; | ||
592 | |||
593 | UUID objectID; | ||
594 | string action; | ||
595 | ulong regionHandle; | ||
596 | if (!GetParams((string)request["uri"], out objectID, out regionHandle, out action)) | ||
597 | { | ||
598 | m_log.InfoFormat("[REST COMMS]: Invalid parameters for object message {0}", request["uri"]); | ||
599 | responsedata["int_response_code"] = 404; | ||
600 | responsedata["str_response_string"] = "false"; | ||
601 | |||
602 | return responsedata; | ||
603 | } | ||
604 | |||
605 | // Next, let's parse the verb | ||
606 | string method = (string)request["http-method"]; | ||
607 | if (method.Equals("POST")) | ||
608 | { | ||
609 | DoObjectPost(request, responsedata, regionHandle); | ||
610 | return responsedata; | ||
611 | } | ||
612 | else if (method.Equals("PUT")) | ||
613 | { | ||
614 | DoObjectPut(request, responsedata, regionHandle); | ||
615 | return responsedata; | ||
616 | } | ||
617 | //else if (method.Equals("DELETE")) | ||
618 | //{ | ||
619 | // DoObjectDelete(request, responsedata, agentID, action, regionHandle); | ||
620 | // return responsedata; | ||
621 | //} | ||
622 | else | ||
623 | { | ||
624 | m_log.InfoFormat("[REST COMMS]: method {0} not supported in object message", method); | ||
625 | responsedata["int_response_code"] = 404; | ||
626 | responsedata["str_response_string"] = "false"; | ||
627 | |||
628 | return responsedata; | ||
629 | } | ||
630 | |||
631 | } | ||
632 | |||
633 | protected virtual void DoObjectPost(Hashtable request, Hashtable responsedata, ulong regionhandle) | ||
634 | { | ||
635 | OSDMap args = RegionClient.GetOSDMap((string)request["body"]); | ||
636 | if (args == null) | ||
637 | { | ||
638 | responsedata["int_response_code"] = 400; | ||
639 | responsedata["str_response_string"] = "false"; | ||
640 | return; | ||
641 | } | ||
642 | |||
643 | string sogXmlStr = "", extraStr = "", stateXmlStr = ""; | ||
644 | if (args["sog"] != null) | ||
645 | sogXmlStr = args["sog"].AsString(); | ||
646 | if (args["extra"] != null) | ||
647 | extraStr = args["extra"].AsString(); | ||
648 | |||
649 | IScene s = m_localBackend.GetScene(regionhandle); | ||
650 | SceneObjectGroup sog = null; | ||
651 | try | ||
652 | { | ||
653 | sog = SceneObjectSerializer.FromXml2Format(sogXmlStr); | ||
654 | sog.ExtraFromXmlString(extraStr); | ||
655 | } | ||
656 | catch (Exception ex) | ||
657 | { | ||
658 | m_log.InfoFormat("[REST COMMS]: exception on deserializing scene object {0}", ex.Message); | ||
659 | responsedata["int_response_code"] = 400; | ||
660 | responsedata["str_response_string"] = "false"; | ||
661 | return; | ||
662 | } | ||
663 | |||
664 | if ((args["state"] != null) && m_aScene.m_allowScriptCrossings) | ||
665 | { | ||
666 | stateXmlStr = args["state"].AsString(); | ||
667 | if (stateXmlStr != "") | ||
668 | { | ||
669 | try | ||
670 | { | ||
671 | sog.SetState(stateXmlStr, s); | ||
672 | } | ||
673 | catch (Exception ex) | ||
674 | { | ||
675 | m_log.InfoFormat("[REST COMMS]: exception on setting state for scene object {0}", ex.Message); | ||
676 | |||
677 | } | ||
678 | } | ||
679 | } | ||
680 | // This is the meaning of POST object | ||
681 | bool result = m_localBackend.SendCreateObject(regionhandle, sog, false); | ||
682 | |||
683 | responsedata["int_response_code"] = 200; | ||
684 | responsedata["str_response_string"] = result.ToString(); | ||
685 | } | ||
686 | |||
687 | protected virtual void DoObjectPut(Hashtable request, Hashtable responsedata, ulong regionhandle) | ||
688 | { | ||
689 | OSDMap args = RegionClient.GetOSDMap((string)request["body"]); | ||
690 | if (args == null) | ||
691 | { | ||
692 | responsedata["int_response_code"] = 400; | ||
693 | responsedata["str_response_string"] = "false"; | ||
694 | return; | ||
695 | } | ||
696 | |||
697 | UUID userID = UUID.Zero, itemID = UUID.Zero; | ||
698 | if (args["userid"] != null) | ||
699 | userID = args["userid"].AsUUID(); | ||
700 | if (args["itemid"] != null) | ||
701 | itemID = args["itemid"].AsUUID(); | ||
702 | |||
703 | // This is the meaning of PUT object | ||
704 | bool result = m_localBackend.SendCreateObject(regionhandle, userID, itemID); | ||
705 | |||
706 | responsedata["int_response_code"] = 200; | ||
707 | responsedata["str_response_string"] = result.ToString(); | ||
708 | } | ||
709 | |||
710 | #endregion | ||
711 | |||
712 | #region Misc | ||
713 | |||
714 | |||
715 | /// <summary> | ||
716 | /// Extract the param from an uri. | ||
717 | /// </summary> | ||
718 | /// <param name="uri">Something like this: /agent/uuid/ or /agent/uuid/handle/release</param> | ||
719 | /// <param name="uri">uuid on uuid field</param> | ||
720 | /// <param name="action">optional action</param> | ||
721 | public static bool GetParams(string uri, out UUID uuid, out ulong regionHandle, out string action) | ||
722 | { | ||
723 | uuid = UUID.Zero; | ||
724 | action = ""; | ||
725 | regionHandle = 0; | ||
726 | |||
727 | uri = uri.Trim(new char[] { '/' }); | ||
728 | string[] parts = uri.Split('/'); | ||
729 | if (parts.Length <= 1) | ||
730 | { | ||
731 | return false; | ||
732 | } | ||
733 | else | ||
734 | { | ||
735 | if (!UUID.TryParse(parts[1], out uuid)) | ||
736 | return false; | ||
737 | |||
738 | if (parts.Length >= 3) | ||
739 | UInt64.TryParse(parts[2], out regionHandle); | ||
740 | if (parts.Length >= 4) | ||
741 | action = parts[3]; | ||
742 | |||
743 | return true; | ||
744 | } | ||
745 | } | ||
746 | |||
747 | public static bool GetAuthentication(Hashtable request, out string authority, out string authKey) | ||
748 | { | ||
749 | authority = string.Empty; | ||
750 | authKey = string.Empty; | ||
751 | |||
752 | Uri authUri; | ||
753 | Hashtable headers = (Hashtable)request["headers"]; | ||
754 | |||
755 | // Authorization keys look like this: | ||
756 | // http://orgrid.org:8002/<uuid> | ||
757 | if (headers.ContainsKey("authorization") && (string)headers["authorization"] != "None") | ||
758 | { | ||
759 | if (Uri.TryCreate((string)headers["authorization"], UriKind.Absolute, out authUri)) | ||
760 | { | ||
761 | authority = authUri.Authority; | ||
762 | authKey = authUri.PathAndQuery.Trim('/'); | ||
763 | m_log.DebugFormat("[REST COMMS]: Got authority {0} and key {1}", authority, authKey); | ||
764 | return true; | ||
765 | } | ||
766 | else | ||
767 | m_log.Debug("[REST COMMS]: Wrong format for Authorization header: " + (string)headers["authorization"]); | ||
768 | } | ||
769 | else | ||
770 | m_log.Debug("[REST COMMS]: Authorization header not found"); | ||
771 | |||
772 | return false; | ||
773 | } | ||
774 | |||
775 | bool VerifyKey(UUID userID, string authority, string key) | ||
776 | { | ||
777 | string[] parts = authority.Split(':'); | ||
778 | IPAddress ipaddr = IPAddress.None; | ||
779 | uint port = 0; | ||
780 | if (parts.Length <= 2) | ||
781 | ipaddr = Util.GetHostFromDNS(parts[0]); | ||
782 | if (parts.Length == 2) | ||
783 | UInt32.TryParse(parts[1], out port); | ||
784 | return true; | ||
785 | |||
786 | //// local authority (standalone), local call | ||
787 | //if (m_thisIP.Equals(ipaddr) && (m_aScene.RegionInfo.HttpPort == port)) | ||
788 | // return ((IAuthentication)m_aScene.CommsManager.UserAdminService).VerifyKey(userID, key); | ||
789 | //// remote call | ||
790 | //else | ||
791 | // return AuthClient.VerifyKey("http://" + authority, userID, key); | ||
792 | } | ||
793 | |||
794 | |||
795 | #endregion Misc | ||
796 | |||
797 | protected class RegionToRegionClient : RegionClient | ||
798 | { | ||
799 | Scene m_aScene = null; | ||
800 | IHyperlinkService m_hyperlinkService; | ||
801 | |||
802 | public RegionToRegionClient(Scene s, IHyperlinkService hyperService) | ||
803 | { | ||
804 | m_aScene = s; | ||
805 | m_hyperlinkService = hyperService; | ||
806 | } | ||
807 | |||
808 | public override ulong GetRegionHandle(ulong handle) | ||
809 | { | ||
810 | if (m_aScene.SceneGridService is HGSceneCommunicationService) | ||
811 | { | ||
812 | if (m_hyperlinkService != null) | ||
813 | return m_hyperlinkService.FindRegionHandle(handle); | ||
814 | } | ||
815 | |||
816 | return handle; | ||
817 | } | ||
818 | |||
819 | public override bool IsHyperlink(ulong handle) | ||
820 | { | ||
821 | if (m_aScene.SceneGridService is HGSceneCommunicationService) | ||
822 | { | ||
823 | if ((m_hyperlinkService != null) && (m_hyperlinkService.GetHyperlinkRegion(handle) != null)) | ||
824 | return true; | ||
825 | } | ||
826 | return false; | ||
827 | } | ||
828 | |||
829 | public override void SendUserInformation(GridRegion regInfo, AgentCircuitData aCircuit) | ||
830 | { | ||
831 | if (m_hyperlinkService != null) | ||
832 | m_hyperlinkService.SendUserInformation(regInfo, aCircuit); | ||
833 | |||
834 | } | ||
835 | |||
836 | public override void AdjustUserInformation(AgentCircuitData aCircuit) | ||
837 | { | ||
838 | if (m_hyperlinkService != null) | ||
839 | m_hyperlinkService.AdjustUserInformation(aCircuit); | ||
840 | } | ||
841 | } | ||
842 | |||
843 | } | ||
844 | } | ||
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs index f485cd1..81496d6 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs | |||
@@ -37,7 +37,6 @@ using OpenMetaverse; | |||
37 | using OpenMetaverse.StructuredData; | 37 | using OpenMetaverse.StructuredData; |
38 | using OpenSim.Framework; | 38 | using OpenSim.Framework; |
39 | using OpenSim.Framework.Communications; | 39 | using OpenSim.Framework.Communications; |
40 | using OpenSim.Framework.Communications.Clients; | ||
41 | using OpenSim.Region.Framework.Interfaces; | 40 | using OpenSim.Region.Framework.Interfaces; |
42 | using OpenSim.Region.Framework.Scenes; | 41 | using OpenSim.Region.Framework.Scenes; |
43 | using OpenSim.Region.Framework.Scenes.Hypergrid; | 42 | using OpenSim.Region.Framework.Scenes.Hypergrid; |
@@ -306,52 +305,5 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation | |||
306 | 305 | ||
307 | #endregion /* IInterregionComms */ | 306 | #endregion /* IInterregionComms */ |
308 | 307 | ||
309 | |||
310 | protected class RegionToRegionClient : RegionClient | ||
311 | { | ||
312 | Scene m_aScene = null; | ||
313 | IHyperlinkService m_hyperlinkService; | ||
314 | |||
315 | public RegionToRegionClient(Scene s, IHyperlinkService hyperService) | ||
316 | { | ||
317 | m_aScene = s; | ||
318 | m_hyperlinkService = hyperService; | ||
319 | } | ||
320 | |||
321 | public override ulong GetRegionHandle(ulong handle) | ||
322 | { | ||
323 | if (m_aScene.SceneGridService is HGSceneCommunicationService) | ||
324 | { | ||
325 | if (m_hyperlinkService != null) | ||
326 | return m_hyperlinkService.FindRegionHandle(handle); | ||
327 | } | ||
328 | |||
329 | return handle; | ||
330 | } | ||
331 | |||
332 | public override bool IsHyperlink(ulong handle) | ||
333 | { | ||
334 | if (m_aScene.SceneGridService is HGSceneCommunicationService) | ||
335 | { | ||
336 | if ((m_hyperlinkService != null) && (m_hyperlinkService.GetHyperlinkRegion(handle) != null)) | ||
337 | return true; | ||
338 | } | ||
339 | return false; | ||
340 | } | ||
341 | |||
342 | public override void SendUserInformation(GridRegion regInfo, AgentCircuitData aCircuit) | ||
343 | { | ||
344 | if (m_hyperlinkService != null) | ||
345 | m_hyperlinkService.SendUserInformation(regInfo, aCircuit); | ||
346 | |||
347 | } | ||
348 | |||
349 | public override void AdjustUserInformation(AgentCircuitData aCircuit) | ||
350 | { | ||
351 | if (m_hyperlinkService != null) | ||
352 | m_hyperlinkService.AdjustUserInformation(aCircuit); | ||
353 | } | ||
354 | } | ||
355 | |||
356 | } | 308 | } |
357 | } | 309 | } |
diff --git a/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs b/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs index ec50598..35f90e4 100644 --- a/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs +++ b/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs | |||
@@ -33,7 +33,6 @@ using log4net; | |||
33 | using OpenMetaverse; | 33 | using OpenMetaverse; |
34 | using OpenSim.Framework; | 34 | using OpenSim.Framework; |
35 | using OpenSim.Framework.Communications.Cache; | 35 | using OpenSim.Framework.Communications.Cache; |
36 | using OpenSim.Framework.Communications.Clients; | ||
37 | using OpenSim.Region.Framework.Scenes.Serialization; | 36 | using OpenSim.Region.Framework.Scenes.Serialization; |
38 | using OpenSim.Region.Framework.Interfaces; | 37 | using OpenSim.Region.Framework.Interfaces; |
39 | using OpenSim.Services.Interfaces; | 38 | using OpenSim.Services.Interfaces; |
diff --git a/OpenSim/Region/Framework/Scenes/RegionStatsHandler.cs b/OpenSim/Region/Framework/Scenes/RegionStatsHandler.cs index e9660b1..a502153 100644 --- a/OpenSim/Region/Framework/Scenes/RegionStatsHandler.cs +++ b/OpenSim/Region/Framework/Scenes/RegionStatsHandler.cs | |||
@@ -36,7 +36,6 @@ using OpenMetaverse; | |||
36 | using OpenMetaverse.StructuredData; | 36 | using OpenMetaverse.StructuredData; |
37 | using OpenSim.Framework; | 37 | using OpenSim.Framework; |
38 | using OpenSim.Framework.Communications; | 38 | using OpenSim.Framework.Communications; |
39 | using OpenSim.Framework.Communications.Services; | ||
40 | using OpenSim.Framework.Communications.Cache; | 39 | using OpenSim.Framework.Communications.Cache; |
41 | using OpenSim.Framework.Console; | 40 | using OpenSim.Framework.Console; |
42 | using OpenSim.Framework.Servers; | 41 | using OpenSim.Framework.Servers; |
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 6d6f0b1..0493b4c 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -42,7 +42,6 @@ using OpenSim.Framework; | |||
42 | using OpenSim.Services.Interfaces; | 42 | using OpenSim.Services.Interfaces; |
43 | using OpenSim.Framework.Communications; | 43 | using OpenSim.Framework.Communications; |
44 | using OpenSim.Framework.Communications.Cache; | 44 | using OpenSim.Framework.Communications.Cache; |
45 | using OpenSim.Framework.Communications.Clients; | ||
46 | using OpenSim.Framework.Console; | 45 | using OpenSim.Framework.Console; |
47 | using OpenSim.Region.Framework.Interfaces; | 46 | using OpenSim.Region.Framework.Interfaces; |
48 | using OpenSim.Region.Framework.Scenes.Scripting; | 47 | using OpenSim.Region.Framework.Scenes.Scripting; |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs index 51134a9..2365e16 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs | |||
@@ -40,8 +40,8 @@ using OpenSim.Framework; | |||
40 | using OpenSim.Framework.Communications; | 40 | using OpenSim.Framework.Communications; |
41 | using OpenSim.Region.Framework.Scenes; | 41 | using OpenSim.Region.Framework.Scenes; |
42 | using OpenSim.Region.Framework.Interfaces; | 42 | using OpenSim.Region.Framework.Interfaces; |
43 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion; | ||
44 | using OpenSim.Region.CoreModules.World.Serialiser; | 43 | using OpenSim.Region.CoreModules.World.Serialiser; |
44 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; | ||
45 | using OpenSim.Tests.Common; | 45 | using OpenSim.Tests.Common; |
46 | using OpenSim.Tests.Common.Mock; | 46 | using OpenSim.Tests.Common.Mock; |
47 | using OpenSim.Tests.Common.Setup; | 47 | using OpenSim.Tests.Common.Setup; |
@@ -71,7 +71,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
71 | scene2 = SceneSetupHelpers.SetupScene("Neighbour x+1", UUID.Random(), 1001, 1000, cm); | 71 | scene2 = SceneSetupHelpers.SetupScene("Neighbour x+1", UUID.Random(), 1001, 1000, cm); |
72 | scene3 = SceneSetupHelpers.SetupScene("Neighbour x-1", UUID.Random(), 999, 1000, cm); | 72 | scene3 = SceneSetupHelpers.SetupScene("Neighbour x-1", UUID.Random(), 999, 1000, cm); |
73 | 73 | ||
74 | ISharedRegionModule interregionComms = new RESTInterregionComms(); | 74 | ISharedRegionModule interregionComms = new LocalSimulationConnectorModule(); |
75 | interregionComms.Initialise(new IniConfigSource()); | 75 | interregionComms.Initialise(new IniConfigSource()); |
76 | interregionComms.PostInitialise(); | 76 | interregionComms.PostInitialise(); |
77 | SceneSetupHelpers.SetupSceneModules(scene, new IniConfigSource(), interregionComms); | 77 | SceneSetupHelpers.SetupSceneModules(scene, new IniConfigSource(), interregionComms); |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/StandaloneTeleportTests.cs b/OpenSim/Region/Framework/Scenes/Tests/StandaloneTeleportTests.cs index b46eb8e..a030dc4 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/StandaloneTeleportTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/StandaloneTeleportTests.cs | |||
@@ -34,7 +34,7 @@ using OpenMetaverse; | |||
34 | using OpenSim.Framework; | 34 | using OpenSim.Framework; |
35 | using OpenSim.Framework.Communications; | 35 | using OpenSim.Framework.Communications; |
36 | using OpenSim.Region.Framework.Interfaces; | 36 | using OpenSim.Region.Framework.Interfaces; |
37 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion; | 37 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; |
38 | using OpenSim.Tests.Common; | 38 | using OpenSim.Tests.Common; |
39 | using OpenSim.Tests.Common.Mock; | 39 | using OpenSim.Tests.Common.Mock; |
40 | using OpenSim.Tests.Common.Setup; | 40 | using OpenSim.Tests.Common.Setup; |
@@ -116,7 +116,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
116 | TestCommunicationsManager cm = new TestCommunicationsManager(); | 116 | TestCommunicationsManager cm = new TestCommunicationsManager(); |
117 | 117 | ||
118 | // shared module | 118 | // shared module |
119 | ISharedRegionModule interregionComms = new RESTInterregionComms(); | 119 | ISharedRegionModule interregionComms = new LocalSimulationConnectorModule(); |
120 | 120 | ||
121 | 121 | ||
122 | Scene sceneB = SceneSetupHelpers.SetupScene("sceneB", sceneBId, 1010, 1010, cm, "grid"); | 122 | Scene sceneB = SceneSetupHelpers.SetupScene("sceneB", sceneBId, 1010, 1010, cm, "grid"); |