diff options
author | John Hurliman | 2009-09-30 15:28:23 -0700 |
---|---|---|
committer | John Hurliman | 2009-09-30 15:28:23 -0700 |
commit | acfe2d9f4e5a55d38b16cac7d0d0a25b64b6b009 (patch) | |
tree | 305349e1bd0a5849fd7f96483e24d5e07b24b8f4 /OpenSim/Region/CoreModules/ServiceConnectorsOut | |
parent | * Adding Scale to EntityBase * Fixing the incorrect initialization of EntityB... (diff) | |
parent | Formatting cleanup. (diff) | |
download | opensim-SC_OLD-acfe2d9f4e5a55d38b16cac7d0d0a25b64b6b009.zip opensim-SC_OLD-acfe2d9f4e5a55d38b16cac7d0d0a25b64b6b009.tar.gz opensim-SC_OLD-acfe2d9f4e5a55d38b16cac7d0d0a25b64b6b009.tar.bz2 opensim-SC_OLD-acfe2d9f4e5a55d38b16cac7d0d0a25b64b6b009.tar.xz |
Merge branch 'master' of ssh://opensimulator.org/var/git/opensim
Diffstat (limited to 'OpenSim/Region/CoreModules/ServiceConnectorsOut')
14 files changed, 1812 insertions, 35 deletions
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/LocalAuthorizationServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/LocalAuthorizationServiceConnector.cs index e69613a..85a1ac3 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/LocalAuthorizationServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/LocalAuthorizationServiceConnector.cs | |||
@@ -134,7 +134,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization | |||
134 | 134 | ||
135 | public bool IsAuthorizedForRegion(string userID, string regionID, out string message) | 135 | public bool IsAuthorizedForRegion(string userID, string regionID, out string message) |
136 | { | 136 | { |
137 | return m_AuthorizationService.IsAuthorizedForRegion(userID, regionID, out message); | 137 | return m_AuthorizationService.IsAuthorizedForRegion(userID, regionID, out message); |
138 | } | 138 | } |
139 | 139 | ||
140 | } | 140 | } |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/RemoteAuthorizationServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/RemoteAuthorizationServiceConnector.cs index a672f4f..fca2df2 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/RemoteAuthorizationServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/RemoteAuthorizationServiceConnector.cs | |||
@@ -146,7 +146,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization | |||
146 | else | 146 | else |
147 | { | 147 | { |
148 | m_log.ErrorFormat("[REMOTE AUTHORIZATION CONNECTOR] IsAuthorizedForRegion, can't find scene to match region id of {0} ",regionID); | 148 | m_log.ErrorFormat("[REMOTE AUTHORIZATION CONNECTOR] IsAuthorizedForRegion, can't find scene to match region id of {0} ",regionID); |
149 | } | 149 | } |
150 | 150 | ||
151 | 151 | ||
152 | return isAuthorized; | 152 | return isAuthorized; |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGCommands.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGCommands.cs new file mode 100644 index 0000000..0974372 --- /dev/null +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGCommands.cs | |||
@@ -0,0 +1,303 @@ | |||
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.Reflection; | ||
31 | using System.Xml; | ||
32 | using log4net; | ||
33 | using Nini.Config; | ||
34 | using OpenSim.Framework; | ||
35 | //using OpenSim.Framework.Communications; | ||
36 | using OpenSim.Framework.Console; | ||
37 | using OpenSim.Region.Framework; | ||
38 | using OpenSim.Region.Framework.Scenes; | ||
39 | using OpenSim.Region.Framework.Scenes.Hypergrid; | ||
40 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | ||
41 | |||
42 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid | ||
43 | { | ||
44 | public class HGCommands | ||
45 | { | ||
46 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
47 | private HGGridConnector m_HGGridConnector; | ||
48 | private Scene m_scene; | ||
49 | |||
50 | private static uint m_autoMappingX = 0; | ||
51 | private static uint m_autoMappingY = 0; | ||
52 | private static bool m_enableAutoMapping = false; | ||
53 | |||
54 | public HGCommands(HGGridConnector hgConnector, Scene scene) | ||
55 | { | ||
56 | m_HGGridConnector = hgConnector; | ||
57 | m_scene = scene; | ||
58 | } | ||
59 | |||
60 | //public static Scene CreateScene(RegionInfo regionInfo, AgentCircuitManager circuitManager, CommunicationsManager m_commsManager, | ||
61 | // StorageManager storageManager, ModuleLoader m_moduleLoader, ConfigSettings m_configSettings, OpenSimConfigSource m_config, string m_version) | ||
62 | //{ | ||
63 | // HGSceneCommunicationService sceneGridService = new HGSceneCommunicationService(m_commsManager, HGServices); | ||
64 | |||
65 | // return | ||
66 | // new HGScene( | ||
67 | // regionInfo, circuitManager, m_commsManager, sceneGridService, storageManager, | ||
68 | // m_moduleLoader, false, m_configSettings.PhysicalPrim, | ||
69 | // m_configSettings.See_into_region_from_neighbor, m_config.Source, m_version); | ||
70 | //} | ||
71 | |||
72 | public void RunCommand(string module, string[] cmdparams) | ||
73 | { | ||
74 | List<string> args = new List<string>(cmdparams); | ||
75 | if (args.Count < 1) | ||
76 | return; | ||
77 | |||
78 | string command = args[0]; | ||
79 | args.RemoveAt(0); | ||
80 | |||
81 | cmdparams = args.ToArray(); | ||
82 | |||
83 | RunHGCommand(command, cmdparams); | ||
84 | |||
85 | } | ||
86 | |||
87 | private void RunHGCommand(string command, string[] cmdparams) | ||
88 | { | ||
89 | if (command.Equals("link-mapping")) | ||
90 | { | ||
91 | if (cmdparams.Length == 2) | ||
92 | { | ||
93 | try | ||
94 | { | ||
95 | m_autoMappingX = Convert.ToUInt32(cmdparams[0]); | ||
96 | m_autoMappingY = Convert.ToUInt32(cmdparams[1]); | ||
97 | m_enableAutoMapping = true; | ||
98 | } | ||
99 | catch (Exception) | ||
100 | { | ||
101 | m_autoMappingX = 0; | ||
102 | m_autoMappingY = 0; | ||
103 | m_enableAutoMapping = false; | ||
104 | } | ||
105 | } | ||
106 | } | ||
107 | else if (command.Equals("link-region")) | ||
108 | { | ||
109 | if (cmdparams.Length < 3) | ||
110 | { | ||
111 | if ((cmdparams.Length == 1) || (cmdparams.Length == 2)) | ||
112 | { | ||
113 | LoadXmlLinkFile(cmdparams); | ||
114 | } | ||
115 | else | ||
116 | { | ||
117 | LinkRegionCmdUsage(); | ||
118 | } | ||
119 | return; | ||
120 | } | ||
121 | |||
122 | if (cmdparams[2].Contains(":")) | ||
123 | { | ||
124 | // New format | ||
125 | int xloc, yloc; | ||
126 | string mapName; | ||
127 | try | ||
128 | { | ||
129 | xloc = Convert.ToInt32(cmdparams[0]); | ||
130 | yloc = Convert.ToInt32(cmdparams[1]); | ||
131 | mapName = cmdparams[2]; | ||
132 | if (cmdparams.Length > 3) | ||
133 | for (int i = 3; i < cmdparams.Length; i++) | ||
134 | mapName += " " + cmdparams[i]; | ||
135 | |||
136 | m_log.Info(">> MapName: " + mapName); | ||
137 | //internalPort = Convert.ToUInt32(cmdparams[4]); | ||
138 | //remotingPort = Convert.ToUInt32(cmdparams[5]); | ||
139 | } | ||
140 | catch (Exception e) | ||
141 | { | ||
142 | m_log.Warn("[HGrid] Wrong format for link-region command: " + e.Message); | ||
143 | LinkRegionCmdUsage(); | ||
144 | return; | ||
145 | } | ||
146 | |||
147 | // Convert cell coordinates given by the user to meters | ||
148 | xloc = xloc * (int)Constants.RegionSize; | ||
149 | yloc = yloc * (int)Constants.RegionSize; | ||
150 | m_HGGridConnector.TryLinkRegionToCoords(m_scene, null, mapName, xloc, yloc); | ||
151 | } | ||
152 | else | ||
153 | { | ||
154 | // old format | ||
155 | GridRegion regInfo; | ||
156 | int xloc, yloc; | ||
157 | uint externalPort; | ||
158 | string externalHostName; | ||
159 | try | ||
160 | { | ||
161 | xloc = Convert.ToInt32(cmdparams[0]); | ||
162 | yloc = Convert.ToInt32(cmdparams[1]); | ||
163 | externalPort = Convert.ToUInt32(cmdparams[3]); | ||
164 | externalHostName = cmdparams[2]; | ||
165 | //internalPort = Convert.ToUInt32(cmdparams[4]); | ||
166 | //remotingPort = Convert.ToUInt32(cmdparams[5]); | ||
167 | } | ||
168 | catch (Exception e) | ||
169 | { | ||
170 | m_log.Warn("[HGrid] Wrong format for link-region command: " + e.Message); | ||
171 | LinkRegionCmdUsage(); | ||
172 | return; | ||
173 | } | ||
174 | |||
175 | // Convert cell coordinates given by the user to meters | ||
176 | xloc = xloc * (int)Constants.RegionSize; | ||
177 | yloc = yloc * (int)Constants.RegionSize; | ||
178 | if (m_HGGridConnector.TryCreateLink(m_scene, null, xloc, yloc, "", externalPort, externalHostName, out regInfo)) | ||
179 | { | ||
180 | if (cmdparams.Length >= 5) | ||
181 | { | ||
182 | regInfo.RegionName = ""; | ||
183 | for (int i = 4; i < cmdparams.Length; i++) | ||
184 | regInfo.RegionName += cmdparams[i] + " "; | ||
185 | } | ||
186 | } | ||
187 | } | ||
188 | return; | ||
189 | } | ||
190 | else if (command.Equals("unlink-region")) | ||
191 | { | ||
192 | if (cmdparams.Length < 1) | ||
193 | { | ||
194 | UnlinkRegionCmdUsage(); | ||
195 | return; | ||
196 | } | ||
197 | if (m_HGGridConnector.TryUnlinkRegion(m_scene, cmdparams[0])) | ||
198 | m_log.InfoFormat("[HGrid]: Successfully unlinked {0}", cmdparams[0]); | ||
199 | else | ||
200 | m_log.InfoFormat("[HGrid]: Unable to unlink {0}, region not found", cmdparams[0]); | ||
201 | } | ||
202 | } | ||
203 | |||
204 | private void LoadXmlLinkFile(string[] cmdparams) | ||
205 | { | ||
206 | //use http://www.hgurl.com/hypergrid.xml for test | ||
207 | try | ||
208 | { | ||
209 | XmlReader r = XmlReader.Create(cmdparams[0]); | ||
210 | XmlConfigSource cs = new XmlConfigSource(r); | ||
211 | string[] excludeSections = null; | ||
212 | |||
213 | if (cmdparams.Length == 2) | ||
214 | { | ||
215 | if (cmdparams[1].ToLower().StartsWith("excludelist:")) | ||
216 | { | ||
217 | string excludeString = cmdparams[1].ToLower(); | ||
218 | excludeString = excludeString.Remove(0, 12); | ||
219 | char[] splitter = { ';' }; | ||
220 | |||
221 | excludeSections = excludeString.Split(splitter); | ||
222 | } | ||
223 | } | ||
224 | |||
225 | for (int i = 0; i < cs.Configs.Count; i++) | ||
226 | { | ||
227 | bool skip = false; | ||
228 | if ((excludeSections != null) && (excludeSections.Length > 0)) | ||
229 | { | ||
230 | for (int n = 0; n < excludeSections.Length; n++) | ||
231 | { | ||
232 | if (excludeSections[n] == cs.Configs[i].Name.ToLower()) | ||
233 | { | ||
234 | skip = true; | ||
235 | break; | ||
236 | } | ||
237 | } | ||
238 | } | ||
239 | if (!skip) | ||
240 | { | ||
241 | ReadLinkFromConfig(cs.Configs[i]); | ||
242 | } | ||
243 | } | ||
244 | } | ||
245 | catch (Exception e) | ||
246 | { | ||
247 | m_log.Error(e.ToString()); | ||
248 | } | ||
249 | } | ||
250 | |||
251 | |||
252 | private void ReadLinkFromConfig(IConfig config) | ||
253 | { | ||
254 | GridRegion regInfo; | ||
255 | int xloc, yloc; | ||
256 | uint externalPort; | ||
257 | string externalHostName; | ||
258 | uint realXLoc, realYLoc; | ||
259 | |||
260 | xloc = Convert.ToInt32(config.GetString("xloc", "0")); | ||
261 | yloc = Convert.ToInt32(config.GetString("yloc", "0")); | ||
262 | externalPort = Convert.ToUInt32(config.GetString("externalPort", "0")); | ||
263 | externalHostName = config.GetString("externalHostName", ""); | ||
264 | realXLoc = Convert.ToUInt32(config.GetString("real-xloc", "0")); | ||
265 | realYLoc = Convert.ToUInt32(config.GetString("real-yloc", "0")); | ||
266 | |||
267 | if (m_enableAutoMapping) | ||
268 | { | ||
269 | xloc = (int)((xloc % 100) + m_autoMappingX); | ||
270 | yloc = (int)((yloc % 100) + m_autoMappingY); | ||
271 | } | ||
272 | |||
273 | if (((realXLoc == 0) && (realYLoc == 0)) || | ||
274 | (((realXLoc - xloc < 3896) || (xloc - realXLoc < 3896)) && | ||
275 | ((realYLoc - yloc < 3896) || (yloc - realYLoc < 3896)))) | ||
276 | { | ||
277 | xloc = xloc * (int)Constants.RegionSize; | ||
278 | yloc = yloc * (int)Constants.RegionSize; | ||
279 | if ( | ||
280 | m_HGGridConnector.TryCreateLink(m_scene, null, xloc, yloc, "", externalPort, | ||
281 | externalHostName, out regInfo)) | ||
282 | { | ||
283 | regInfo.RegionName = config.GetString("localName", ""); | ||
284 | } | ||
285 | } | ||
286 | } | ||
287 | |||
288 | |||
289 | private void LinkRegionCmdUsage() | ||
290 | { | ||
291 | m_log.Info("Usage: link-region <Xloc> <Yloc> <HostName>:<HttpPort>[:<RemoteRegionName>]"); | ||
292 | m_log.Info("Usage: link-region <Xloc> <Yloc> <HostName> <HttpPort> [<LocalName>]"); | ||
293 | m_log.Info("Usage: link-region <URI_of_xml> [<exclude>]"); | ||
294 | } | ||
295 | |||
296 | private void UnlinkRegionCmdUsage() | ||
297 | { | ||
298 | m_log.Info("Usage: unlink-region <HostName>:<HttpPort>"); | ||
299 | m_log.Info("Usage: unlink-region <LocalName>"); | ||
300 | } | ||
301 | |||
302 | } | ||
303 | } | ||
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs new file mode 100644 index 0000000..148331b --- /dev/null +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs | |||
@@ -0,0 +1,795 @@ | |||
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 System.Xml; | ||
33 | |||
34 | using OpenSim.Framework.Communications.Cache; | ||
35 | using OpenSim.Framework; | ||
36 | using OpenSim.Region.Framework.Interfaces; | ||
37 | using OpenSim.Region.Framework.Scenes; | ||
38 | using OpenSim.Region.Framework.Scenes.Hypergrid; | ||
39 | using OpenSim.Services.Interfaces; | ||
40 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | ||
41 | using OpenSim.Server.Base; | ||
42 | using OpenSim.Services.Connectors.Grid; | ||
43 | using OpenSim.Framework.Console; | ||
44 | |||
45 | using OpenMetaverse; | ||
46 | using log4net; | ||
47 | using Nini.Config; | ||
48 | |||
49 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid | ||
50 | { | ||
51 | public class HGGridConnector : ISharedRegionModule, IGridService, IHyperlinkService | ||
52 | { | ||
53 | private static readonly ILog m_log = | ||
54 | LogManager.GetLogger( | ||
55 | MethodBase.GetCurrentMethod().DeclaringType); | ||
56 | private static string LocalAssetServerURI, LocalInventoryServerURI, LocalUserServerURI; | ||
57 | |||
58 | private bool m_Enabled = false; | ||
59 | private bool m_Initialized = false; | ||
60 | |||
61 | private Scene m_aScene; | ||
62 | private Dictionary<ulong, Scene> m_LocalScenes = new Dictionary<ulong, Scene>(); | ||
63 | |||
64 | private IGridService m_GridServiceConnector; | ||
65 | private HypergridServiceConnector m_HypergridServiceConnector; | ||
66 | |||
67 | // Hyperlink regions are hyperlinks on the map | ||
68 | protected Dictionary<UUID, GridRegion> m_HyperlinkRegions = new Dictionary<UUID, GridRegion>(); | ||
69 | |||
70 | // Known regions are home regions of visiting foreign users. | ||
71 | // They are not on the map as static hyperlinks. They are dynamic hyperlinks, they go away when | ||
72 | // the visitor goes away. They are mapped to X=0 on the map. | ||
73 | // This is key-ed on agent ID | ||
74 | protected Dictionary<UUID, GridRegion> m_knownRegions = new Dictionary<UUID, GridRegion>(); | ||
75 | |||
76 | protected Dictionary<UUID, ulong> m_HyperlinkHandles = new Dictionary<UUID, ulong>(); | ||
77 | |||
78 | #region ISharedRegionModule | ||
79 | |||
80 | public Type ReplaceableInterface | ||
81 | { | ||
82 | get { return null; } | ||
83 | } | ||
84 | |||
85 | public string Name | ||
86 | { | ||
87 | get { return "HGGridServicesConnector"; } | ||
88 | } | ||
89 | |||
90 | public void Initialise(IConfigSource source) | ||
91 | { | ||
92 | IConfig moduleConfig = source.Configs["Modules"]; | ||
93 | if (moduleConfig != null) | ||
94 | { | ||
95 | string name = moduleConfig.GetString("GridServices", ""); | ||
96 | if (name == Name) | ||
97 | { | ||
98 | IConfig gridConfig = source.Configs["GridService"]; | ||
99 | if (gridConfig == null) | ||
100 | { | ||
101 | m_log.Error("[HGGRID CONNECTOR]: GridService missing from OpenSim.ini"); | ||
102 | return; | ||
103 | } | ||
104 | |||
105 | |||
106 | InitialiseConnectorModule(source); | ||
107 | |||
108 | m_Enabled = true; | ||
109 | m_log.Info("[HGGRID CONNECTOR]: HG grid enabled"); | ||
110 | } | ||
111 | } | ||
112 | } | ||
113 | |||
114 | private void InitialiseConnectorModule(IConfigSource source) | ||
115 | { | ||
116 | IConfig gridConfig = source.Configs["GridService"]; | ||
117 | if (gridConfig == null) | ||
118 | { | ||
119 | m_log.Error("[HGGRID CONNECTOR]: GridService missing from OpenSim.ini"); | ||
120 | throw new Exception("Grid connector init error"); | ||
121 | } | ||
122 | |||
123 | string module = gridConfig.GetString("GridServiceConnectorModule", String.Empty); | ||
124 | if (module == String.Empty) | ||
125 | { | ||
126 | m_log.Error("[HGGRID CONNECTOR]: No GridServiceConnectorModule named in section GridService"); | ||
127 | //return; | ||
128 | throw new Exception("Unable to proceed. Please make sure your ini files in config-include are updated according to .example's"); | ||
129 | } | ||
130 | |||
131 | Object[] args = new Object[] { source }; | ||
132 | m_GridServiceConnector = ServerUtils.LoadPlugin<IGridService>(module, args); | ||
133 | |||
134 | } | ||
135 | |||
136 | public void PostInitialise() | ||
137 | { | ||
138 | if (m_Enabled) | ||
139 | ((ISharedRegionModule)m_GridServiceConnector).PostInitialise(); | ||
140 | } | ||
141 | |||
142 | public void Close() | ||
143 | { | ||
144 | } | ||
145 | |||
146 | public void AddRegion(Scene scene) | ||
147 | { | ||
148 | if (!m_Enabled) | ||
149 | return; | ||
150 | |||
151 | m_LocalScenes[scene.RegionInfo.RegionHandle] = scene; | ||
152 | scene.RegisterModuleInterface<IGridService>(this); | ||
153 | scene.RegisterModuleInterface<IHyperlinkService>(this); | ||
154 | |||
155 | ((ISharedRegionModule)m_GridServiceConnector).AddRegion(scene); | ||
156 | |||
157 | } | ||
158 | |||
159 | public void RemoveRegion(Scene scene) | ||
160 | { | ||
161 | if (m_Enabled) | ||
162 | { | ||
163 | m_LocalScenes.Remove(scene.RegionInfo.RegionHandle); | ||
164 | ((ISharedRegionModule)m_GridServiceConnector).RemoveRegion(scene); | ||
165 | } | ||
166 | } | ||
167 | |||
168 | public void RegionLoaded(Scene scene) | ||
169 | { | ||
170 | if (!m_Enabled) | ||
171 | return; | ||
172 | |||
173 | if (!m_Initialized) | ||
174 | { | ||
175 | m_aScene = scene; | ||
176 | LocalAssetServerURI = m_aScene.CommsManager.NetworkServersInfo.UserURL; | ||
177 | LocalInventoryServerURI = m_aScene.CommsManager.NetworkServersInfo.InventoryURL; | ||
178 | LocalUserServerURI = m_aScene.CommsManager.NetworkServersInfo.UserURL; | ||
179 | |||
180 | m_HypergridServiceConnector = new HypergridServiceConnector(scene.AssetService); | ||
181 | |||
182 | HGCommands hgCommands = new HGCommands(this, scene); | ||
183 | MainConsole.Instance.Commands.AddCommand("HGGridServicesConnector", false, "link-region", | ||
184 | "link-region <Xloc> <Yloc> <HostName>:<HttpPort>[:<RemoteRegionName>] <cr>", | ||
185 | "Link a hypergrid region", hgCommands.RunCommand); | ||
186 | MainConsole.Instance.Commands.AddCommand("HGGridServicesConnector", false, "unlink-region", | ||
187 | "unlink-region <local name> or <HostName>:<HttpPort> <cr>", | ||
188 | "Unlink a hypergrid region", hgCommands.RunCommand); | ||
189 | MainConsole.Instance.Commands.AddCommand("HGGridServicesConnector", false, "link-mapping", "link-mapping [<x> <y>] <cr>", | ||
190 | "Set local coordinate to map HG regions to", hgCommands.RunCommand); | ||
191 | |||
192 | // Yikes!! Remove this as soon as user services get refactored | ||
193 | HGNetworkServersInfo.Init(LocalAssetServerURI, LocalInventoryServerURI, LocalUserServerURI); | ||
194 | |||
195 | m_Initialized = true; | ||
196 | } | ||
197 | } | ||
198 | |||
199 | #endregion | ||
200 | |||
201 | #region IGridService | ||
202 | |||
203 | public bool RegisterRegion(UUID scopeID, GridRegion regionInfo) | ||
204 | { | ||
205 | // Region doesn't exist here. Trying to link remote region | ||
206 | if (regionInfo.RegionID.Equals(UUID.Zero)) | ||
207 | { | ||
208 | m_log.Info("[HGrid]: Linking remote region " + regionInfo.ExternalHostName + ":" + regionInfo.HttpPort); | ||
209 | ulong regionHandle = 0; | ||
210 | regionInfo.RegionID = m_HypergridServiceConnector.LinkRegion(regionInfo, out regionHandle); | ||
211 | if (!regionInfo.RegionID.Equals(UUID.Zero)) | ||
212 | { | ||
213 | AddHyperlinkRegion(regionInfo, regionHandle); | ||
214 | m_log.Info("[HGrid]: Successfully linked to region_uuid " + regionInfo.RegionID); | ||
215 | |||
216 | // Try get the map image | ||
217 | m_HypergridServiceConnector.GetMapImage(regionInfo); | ||
218 | return true; | ||
219 | } | ||
220 | else | ||
221 | { | ||
222 | m_log.Info("[HGrid]: No such region " + regionInfo.ExternalHostName + ":" + regionInfo.HttpPort + "(" + regionInfo.InternalEndPoint.Port + ")"); | ||
223 | return false; | ||
224 | } | ||
225 | // Note that these remote regions aren't registered in localBackend, so return null, no local listeners | ||
226 | } | ||
227 | else // normal grid | ||
228 | return m_GridServiceConnector.RegisterRegion(scopeID, regionInfo); | ||
229 | } | ||
230 | |||
231 | public bool DeregisterRegion(UUID regionID) | ||
232 | { | ||
233 | // Try the hyperlink collection | ||
234 | if (m_HyperlinkRegions.ContainsKey(regionID)) | ||
235 | { | ||
236 | RemoveHyperlinkRegion(regionID); | ||
237 | return true; | ||
238 | } | ||
239 | // Try the foreign users home collection | ||
240 | |||
241 | foreach (GridRegion r in m_knownRegions.Values) | ||
242 | if (r.RegionID == regionID) | ||
243 | { | ||
244 | RemoveHyperlinkHomeRegion(regionID); | ||
245 | return true; | ||
246 | } | ||
247 | |||
248 | // Finally, try the normal route | ||
249 | return m_GridServiceConnector.DeregisterRegion(regionID); | ||
250 | } | ||
251 | |||
252 | public List<GridRegion> GetNeighbours(UUID scopeID, UUID regionID) | ||
253 | { | ||
254 | // No serving neighbours on hyperliked regions. | ||
255 | // Just the regular regions. | ||
256 | return m_GridServiceConnector.GetNeighbours(scopeID, regionID); | ||
257 | } | ||
258 | |||
259 | public GridRegion GetRegionByUUID(UUID scopeID, UUID regionID) | ||
260 | { | ||
261 | // Try the hyperlink collection | ||
262 | if (m_HyperlinkRegions.ContainsKey(regionID)) | ||
263 | return m_HyperlinkRegions[regionID]; | ||
264 | |||
265 | // Try the foreign users home collection | ||
266 | foreach (GridRegion r in m_knownRegions.Values) | ||
267 | if (r.RegionID == regionID) | ||
268 | return r; | ||
269 | |||
270 | // Finally, try the normal route | ||
271 | return m_GridServiceConnector.GetRegionByUUID(scopeID, regionID); | ||
272 | } | ||
273 | |||
274 | public GridRegion GetRegionByPosition(UUID scopeID, int x, int y) | ||
275 | { | ||
276 | int snapX = (int) (x / Constants.RegionSize) * (int)Constants.RegionSize; | ||
277 | int snapY = (int) (y / Constants.RegionSize) * (int)Constants.RegionSize; | ||
278 | // Try the hyperlink collection | ||
279 | foreach (GridRegion r in m_HyperlinkRegions.Values) | ||
280 | { | ||
281 | if ((r.RegionLocX == snapX) && (r.RegionLocY == snapY)) | ||
282 | return r; | ||
283 | } | ||
284 | |||
285 | // Try the foreign users home collection | ||
286 | foreach (GridRegion r in m_knownRegions.Values) | ||
287 | { | ||
288 | if ((r.RegionLocX == snapX) && (r.RegionLocY == snapY)) | ||
289 | { | ||
290 | return r; | ||
291 | } | ||
292 | } | ||
293 | |||
294 | // Finally, try the normal route | ||
295 | return m_GridServiceConnector.GetRegionByPosition(scopeID, x, y); | ||
296 | } | ||
297 | |||
298 | public GridRegion GetRegionByName(UUID scopeID, string regionName) | ||
299 | { | ||
300 | // Try normal grid first | ||
301 | GridRegion region = m_GridServiceConnector.GetRegionByName(scopeID, regionName); | ||
302 | if (region != null) | ||
303 | return region; | ||
304 | |||
305 | // Try the hyperlink collection | ||
306 | foreach (GridRegion r in m_HyperlinkRegions.Values) | ||
307 | { | ||
308 | if (r.RegionName == regionName) | ||
309 | return r; | ||
310 | } | ||
311 | |||
312 | // Try the foreign users home collection | ||
313 | foreach (GridRegion r in m_knownRegions.Values) | ||
314 | { | ||
315 | if (r.RegionName == regionName) | ||
316 | return r; | ||
317 | } | ||
318 | return null; | ||
319 | } | ||
320 | |||
321 | public List<GridRegion> GetRegionsByName(UUID scopeID, string name, int maxNumber) | ||
322 | { | ||
323 | List<GridRegion> rinfos = new List<GridRegion>(); | ||
324 | |||
325 | // Commenting until regionname exists | ||
326 | //foreach (SimpleRegionInfo r in m_HyperlinkRegions.Values) | ||
327 | // if ((r.RegionName != null) && r.RegionName.StartsWith(name)) | ||
328 | // rinfos.Add(r); | ||
329 | |||
330 | rinfos.AddRange(m_GridServiceConnector.GetRegionsByName(scopeID, name, maxNumber)); | ||
331 | return rinfos; | ||
332 | } | ||
333 | |||
334 | public List<GridRegion> GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax) | ||
335 | { | ||
336 | int snapXmin = (int)(xmin / Constants.RegionSize) * (int)Constants.RegionSize; | ||
337 | int snapXmax = (int)(xmax / Constants.RegionSize) * (int)Constants.RegionSize; | ||
338 | int snapYmin = (int)(ymin / Constants.RegionSize) * (int)Constants.RegionSize; | ||
339 | int snapYmax = (int)(ymax / Constants.RegionSize) * (int)Constants.RegionSize; | ||
340 | |||
341 | List<GridRegion> rinfos = new List<GridRegion>(); | ||
342 | foreach (GridRegion r in m_HyperlinkRegions.Values) | ||
343 | if ((r.RegionLocX > snapXmin) && (r.RegionLocX < snapYmax) && | ||
344 | (r.RegionLocY > snapYmin) && (r.RegionLocY < snapYmax)) | ||
345 | rinfos.Add(r); | ||
346 | |||
347 | rinfos.AddRange(m_GridServiceConnector.GetRegionRange(scopeID, xmin, xmax, ymin, ymax)); | ||
348 | |||
349 | return rinfos; | ||
350 | } | ||
351 | |||
352 | #endregion | ||
353 | |||
354 | #region Auxiliary | ||
355 | |||
356 | private void AddHyperlinkRegion(GridRegion regionInfo, ulong regionHandle) | ||
357 | { | ||
358 | m_HyperlinkRegions[regionInfo.RegionID] = regionInfo; | ||
359 | m_HyperlinkHandles[regionInfo.RegionID] = regionHandle; | ||
360 | } | ||
361 | |||
362 | private void RemoveHyperlinkRegion(UUID regionID) | ||
363 | { | ||
364 | m_HyperlinkRegions.Remove(regionID); | ||
365 | m_HyperlinkHandles.Remove(regionID); | ||
366 | } | ||
367 | |||
368 | private void AddHyperlinkHomeRegion(UUID userID, GridRegion regionInfo, ulong regionHandle) | ||
369 | { | ||
370 | m_knownRegions[userID] = regionInfo; | ||
371 | m_HyperlinkHandles[regionInfo.RegionID] = regionHandle; | ||
372 | } | ||
373 | |||
374 | private void RemoveHyperlinkHomeRegion(UUID regionID) | ||
375 | { | ||
376 | foreach (KeyValuePair<UUID, GridRegion> kvp in m_knownRegions) | ||
377 | { | ||
378 | if (kvp.Value.RegionID == regionID) | ||
379 | { | ||
380 | m_knownRegions.Remove(kvp.Key); | ||
381 | } | ||
382 | } | ||
383 | m_HyperlinkHandles.Remove(regionID); | ||
384 | } | ||
385 | #endregion | ||
386 | |||
387 | #region IHyperlinkService | ||
388 | |||
389 | private static Random random = new Random(); | ||
390 | |||
391 | |||
392 | public GridRegion TryLinkRegionToCoords(Scene m_scene, IClientAPI client, string mapName, int xloc, int yloc) | ||
393 | { | ||
394 | string host = "127.0.0.1"; | ||
395 | string portstr; | ||
396 | string regionName = ""; | ||
397 | uint port = 9000; | ||
398 | string[] parts = mapName.Split(new char[] { ':' }); | ||
399 | if (parts.Length >= 1) | ||
400 | { | ||
401 | host = parts[0]; | ||
402 | } | ||
403 | if (parts.Length >= 2) | ||
404 | { | ||
405 | portstr = parts[1]; | ||
406 | if (!UInt32.TryParse(portstr, out port)) | ||
407 | regionName = parts[1]; | ||
408 | } | ||
409 | // always take the last one | ||
410 | if (parts.Length >= 3) | ||
411 | { | ||
412 | regionName = parts[2]; | ||
413 | } | ||
414 | |||
415 | // Sanity check. Don't ever link to this sim. | ||
416 | IPAddress ipaddr = null; | ||
417 | try | ||
418 | { | ||
419 | ipaddr = Util.GetHostFromDNS(host); | ||
420 | } | ||
421 | catch { } | ||
422 | |||
423 | if ((ipaddr != null) && | ||
424 | !((m_scene.RegionInfo.ExternalEndPoint.Address.Equals(ipaddr)) && (m_scene.RegionInfo.HttpPort == port))) | ||
425 | { | ||
426 | GridRegion regInfo; | ||
427 | bool success = TryCreateLink(m_scene, client, xloc, yloc, regionName, port, host, out regInfo); | ||
428 | if (success) | ||
429 | { | ||
430 | regInfo.RegionName = mapName; | ||
431 | return regInfo; | ||
432 | } | ||
433 | } | ||
434 | |||
435 | return null; | ||
436 | } | ||
437 | |||
438 | |||
439 | // From the map search and secondlife://blah | ||
440 | public GridRegion TryLinkRegion(Scene m_scene, IClientAPI client, string mapName) | ||
441 | { | ||
442 | int xloc = random.Next(0, Int16.MaxValue) * (int) Constants.RegionSize; | ||
443 | return TryLinkRegionToCoords(m_scene, client, mapName, xloc, 0); | ||
444 | } | ||
445 | |||
446 | public bool TryCreateLink(Scene m_scene, IClientAPI client, int xloc, int yloc, | ||
447 | string externalRegionName, uint externalPort, string externalHostName, out GridRegion regInfo) | ||
448 | { | ||
449 | m_log.DebugFormat("[HGrid]: Link to {0}:{1}, in {2}-{3}", externalHostName, externalPort, xloc, yloc); | ||
450 | |||
451 | regInfo = new GridRegion(); | ||
452 | regInfo.RegionName = externalRegionName; | ||
453 | regInfo.HttpPort = externalPort; | ||
454 | regInfo.ExternalHostName = externalHostName; | ||
455 | regInfo.RegionLocX = xloc; | ||
456 | regInfo.RegionLocY = yloc; | ||
457 | |||
458 | try | ||
459 | { | ||
460 | regInfo.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), (int)0); | ||
461 | } | ||
462 | catch (Exception e) | ||
463 | { | ||
464 | m_log.Warn("[HGrid]: Wrong format for link-region: " + e.Message); | ||
465 | return false; | ||
466 | } | ||
467 | |||
468 | // Finally, link it | ||
469 | if (!RegisterRegion(UUID.Zero, regInfo)) | ||
470 | { | ||
471 | m_log.Warn("[HGrid]: Unable to link region"); | ||
472 | return false; | ||
473 | } | ||
474 | |||
475 | int x, y; | ||
476 | if (!Check4096(m_scene, regInfo, out x, out y)) | ||
477 | { | ||
478 | DeregisterRegion(regInfo.RegionID); | ||
479 | if (client != null) | ||
480 | client.SendAlertMessage("Region is too far (" + x + ", " + y + ")"); | ||
481 | m_log.Info("[HGrid]: Unable to link, region is too far (" + x + ", " + y + ")"); | ||
482 | return false; | ||
483 | } | ||
484 | |||
485 | if (!CheckCoords(m_scene.RegionInfo.RegionLocX, m_scene.RegionInfo.RegionLocY, x, y)) | ||
486 | { | ||
487 | DeregisterRegion(regInfo.RegionID); | ||
488 | if (client != null) | ||
489 | client.SendAlertMessage("Region has incompatible coordinates (" + x + ", " + y + ")"); | ||
490 | m_log.Info("[HGrid]: Unable to link, region has incompatible coordinates (" + x + ", " + y + ")"); | ||
491 | return false; | ||
492 | } | ||
493 | |||
494 | m_log.Debug("[HGrid]: link region succeeded"); | ||
495 | return true; | ||
496 | } | ||
497 | |||
498 | public bool TryUnlinkRegion(Scene m_scene, string mapName) | ||
499 | { | ||
500 | GridRegion regInfo = null; | ||
501 | if (mapName.Contains(":")) | ||
502 | { | ||
503 | string host = "127.0.0.1"; | ||
504 | //string portstr; | ||
505 | //string regionName = ""; | ||
506 | uint port = 9000; | ||
507 | string[] parts = mapName.Split(new char[] { ':' }); | ||
508 | if (parts.Length >= 1) | ||
509 | { | ||
510 | host = parts[0]; | ||
511 | } | ||
512 | // if (parts.Length >= 2) | ||
513 | // { | ||
514 | // portstr = parts[1]; | ||
515 | // if (!UInt32.TryParse(portstr, out port)) | ||
516 | // regionName = parts[1]; | ||
517 | // } | ||
518 | // always take the last one | ||
519 | // if (parts.Length >= 3) | ||
520 | // { | ||
521 | // regionName = parts[2]; | ||
522 | // } | ||
523 | foreach (GridRegion r in m_HyperlinkRegions.Values) | ||
524 | if (host.Equals(r.ExternalHostName) && (port == r.HttpPort)) | ||
525 | regInfo = r; | ||
526 | } | ||
527 | else | ||
528 | { | ||
529 | foreach (GridRegion r in m_HyperlinkRegions.Values) | ||
530 | if (r.RegionName.Equals(mapName)) | ||
531 | regInfo = r; | ||
532 | } | ||
533 | if (regInfo != null) | ||
534 | { | ||
535 | return DeregisterRegion(regInfo.RegionID); | ||
536 | } | ||
537 | else | ||
538 | { | ||
539 | m_log.InfoFormat("[HGrid]: Region {0} not found", mapName); | ||
540 | return false; | ||
541 | } | ||
542 | } | ||
543 | |||
544 | /// <summary> | ||
545 | /// Cope with this viewer limitation. | ||
546 | /// </summary> | ||
547 | /// <param name="regInfo"></param> | ||
548 | /// <returns></returns> | ||
549 | public bool Check4096(Scene m_scene, GridRegion regInfo, out int x, out int y) | ||
550 | { | ||
551 | ulong realHandle = m_HyperlinkHandles[regInfo.RegionID]; | ||
552 | uint ux = 0, uy = 0; | ||
553 | Utils.LongToUInts(realHandle, out ux, out uy); | ||
554 | x = (int)(ux / Constants.RegionSize); | ||
555 | y = (int)(uy / Constants.RegionSize); | ||
556 | |||
557 | if ((Math.Abs((int)m_scene.RegionInfo.RegionLocX - x) >= 4096) || | ||
558 | (Math.Abs((int)m_scene.RegionInfo.RegionLocY - y) >= 4096)) | ||
559 | { | ||
560 | return false; | ||
561 | } | ||
562 | return true; | ||
563 | } | ||
564 | |||
565 | public bool CheckCoords(uint thisx, uint thisy, int x, int y) | ||
566 | { | ||
567 | if ((thisx == x) && (thisy == y)) | ||
568 | return false; | ||
569 | return true; | ||
570 | } | ||
571 | |||
572 | public GridRegion TryLinkRegion(IClientAPI client, string regionDescriptor) | ||
573 | { | ||
574 | return TryLinkRegion((Scene)client.Scene, client, regionDescriptor); | ||
575 | } | ||
576 | |||
577 | public GridRegion GetHyperlinkRegion(ulong handle) | ||
578 | { | ||
579 | foreach (GridRegion r in m_HyperlinkRegions.Values) | ||
580 | if (r.RegionHandle == handle) | ||
581 | return r; | ||
582 | foreach (GridRegion r in m_knownRegions.Values) | ||
583 | if (r.RegionHandle == handle) | ||
584 | return r; | ||
585 | return null; | ||
586 | } | ||
587 | |||
588 | public ulong FindRegionHandle(ulong handle) | ||
589 | { | ||
590 | foreach (GridRegion r in m_HyperlinkRegions.Values) | ||
591 | if ((r.RegionHandle == handle) && (m_HyperlinkHandles.ContainsKey(r.RegionID))) | ||
592 | return m_HyperlinkHandles[r.RegionID]; | ||
593 | |||
594 | foreach (GridRegion r in m_knownRegions.Values) | ||
595 | if ((r.RegionHandle == handle) && (m_HyperlinkHandles.ContainsKey(r.RegionID))) | ||
596 | return m_HyperlinkHandles[r.RegionID]; | ||
597 | |||
598 | return handle; | ||
599 | } | ||
600 | |||
601 | public bool SendUserInformation(GridRegion regInfo, AgentCircuitData agentData) | ||
602 | { | ||
603 | CachedUserInfo uinfo = m_aScene.CommsManager.UserProfileCacheService.GetUserDetails(agentData.AgentID); | ||
604 | |||
605 | if ((IsLocalUser(uinfo) && (GetHyperlinkRegion(regInfo.RegionHandle) != null)) || | ||
606 | (!IsLocalUser(uinfo) && !IsGoingHome(uinfo, regInfo))) | ||
607 | { | ||
608 | m_log.Info("[HGrid]: Local user is going to foreign region or foreign user is going elsewhere"); | ||
609 | |||
610 | // Set the position of the region on the remote grid | ||
611 | ulong realHandle = FindRegionHandle(regInfo.RegionHandle); | ||
612 | uint x = 0, y = 0; | ||
613 | Utils.LongToUInts(regInfo.RegionHandle, out x, out y); | ||
614 | GridRegion clonedRegion = new GridRegion(regInfo); | ||
615 | clonedRegion.RegionLocX = (int)x; | ||
616 | clonedRegion.RegionLocY = (int)y; | ||
617 | |||
618 | // Get the user's home region information | ||
619 | GridRegion home = m_aScene.GridService.GetRegionByUUID(m_aScene.RegionInfo.ScopeID, uinfo.UserProfile.HomeRegionID); | ||
620 | |||
621 | // Get the user's service URLs | ||
622 | string serverURI = ""; | ||
623 | if (uinfo.UserProfile is ForeignUserProfileData) | ||
624 | serverURI = Util.ServerURI(((ForeignUserProfileData)uinfo.UserProfile).UserServerURI); | ||
625 | string userServer = (serverURI == "") || (serverURI == null) ? LocalUserServerURI : serverURI; | ||
626 | |||
627 | string assetServer = Util.ServerURI(uinfo.UserProfile.UserAssetURI); | ||
628 | if ((assetServer == null) || (assetServer == "")) | ||
629 | assetServer = LocalAssetServerURI; | ||
630 | |||
631 | string inventoryServer = Util.ServerURI(uinfo.UserProfile.UserInventoryURI); | ||
632 | if ((inventoryServer == null) || (inventoryServer == "")) | ||
633 | inventoryServer = LocalInventoryServerURI; | ||
634 | |||
635 | if (!m_HypergridServiceConnector.InformRegionOfUser(clonedRegion, agentData, home, userServer, assetServer, inventoryServer)) | ||
636 | { | ||
637 | m_log.Warn("[HGrid]: Could not inform remote region of transferring user."); | ||
638 | return false; | ||
639 | } | ||
640 | } | ||
641 | //if ((uinfo == null) || !IsGoingHome(uinfo, regInfo)) | ||
642 | //{ | ||
643 | // m_log.Info("[HGrid]: User seems to be going to foreign region."); | ||
644 | // if (!InformRegionOfUser(regInfo, agentData)) | ||
645 | // { | ||
646 | // m_log.Warn("[HGrid]: Could not inform remote region of transferring user."); | ||
647 | // return false; | ||
648 | // } | ||
649 | //} | ||
650 | //else | ||
651 | // m_log.Info("[HGrid]: User seems to be going home " + uinfo.UserProfile.FirstName + " " + uinfo.UserProfile.SurName); | ||
652 | |||
653 | // May need to change agent's name | ||
654 | if (IsLocalUser(uinfo) && (GetHyperlinkRegion(regInfo.RegionHandle) != null)) | ||
655 | { | ||
656 | agentData.firstname = agentData.firstname + "." + agentData.lastname; | ||
657 | agentData.lastname = "@" + LocalUserServerURI.Replace("http://", ""); ; //HGNetworkServersInfo.Singleton.LocalUserServerURI; | ||
658 | } | ||
659 | |||
660 | return true; | ||
661 | } | ||
662 | |||
663 | public void AdjustUserInformation(AgentCircuitData agentData) | ||
664 | { | ||
665 | CachedUserInfo uinfo = m_aScene.CommsManager.UserProfileCacheService.GetUserDetails(agentData.AgentID); | ||
666 | if ((uinfo != null) && (uinfo.UserProfile != null) && | ||
667 | (IsLocalUser(uinfo) || !(uinfo.UserProfile is ForeignUserProfileData))) | ||
668 | { | ||
669 | //m_log.Debug("---------------> Local User!"); | ||
670 | string[] parts = agentData.firstname.Split(new char[] { '.' }); | ||
671 | if (parts.Length == 2) | ||
672 | { | ||
673 | agentData.firstname = parts[0]; | ||
674 | agentData.lastname = parts[1]; | ||
675 | } | ||
676 | } | ||
677 | //else | ||
678 | // m_log.Debug("---------------> Foreign User!"); | ||
679 | } | ||
680 | |||
681 | // Check if a local user exists with the same UUID as the incoming foreign user | ||
682 | public bool CheckUserAtEntry(UUID userID, UUID sessionID, out bool comingHome) | ||
683 | { | ||
684 | comingHome = false; | ||
685 | if (!m_aScene.SceneGridService.RegionLoginsEnabled) | ||
686 | return false; | ||
687 | |||
688 | CachedUserInfo uinfo = m_aScene.CommsManager.UserProfileCacheService.GetUserDetails(userID); | ||
689 | if (uinfo != null) | ||
690 | { | ||
691 | // uh-oh we have a potential intruder | ||
692 | if (uinfo.SessionID != sessionID) | ||
693 | // can't have a foreigner with a local UUID | ||
694 | return false; | ||
695 | else | ||
696 | // oh, so it's you! welcome back | ||
697 | comingHome = true; | ||
698 | } | ||
699 | |||
700 | // OK, user can come in | ||
701 | return true; | ||
702 | } | ||
703 | |||
704 | public void AcceptUser(ForeignUserProfileData user, GridRegion home) | ||
705 | { | ||
706 | m_aScene.CommsManager.UserProfileCacheService.PreloadUserCache(user); | ||
707 | ulong realHandle = home.RegionHandle; | ||
708 | // Change the local coordinates | ||
709 | // X=0 on the map | ||
710 | home.RegionLocX = 0; | ||
711 | home.RegionLocY = random.Next(0, 10000) * (int)Constants.RegionSize; | ||
712 | |||
713 | AddHyperlinkHomeRegion(user.ID, home, realHandle); | ||
714 | |||
715 | DumpUserData(user); | ||
716 | DumpRegionData(home); | ||
717 | |||
718 | } | ||
719 | |||
720 | public bool IsLocalUser(UUID userID) | ||
721 | { | ||
722 | CachedUserInfo uinfo = m_aScene.CommsManager.UserProfileCacheService.GetUserDetails(userID); | ||
723 | return IsLocalUser(uinfo); | ||
724 | } | ||
725 | |||
726 | #endregion | ||
727 | |||
728 | #region IHyperlink Misc | ||
729 | |||
730 | protected bool IsComingHome(ForeignUserProfileData userData) | ||
731 | { | ||
732 | return (userData.UserServerURI == LocalUserServerURI); | ||
733 | } | ||
734 | |||
735 | // Is the user going back to the home region or the home grid? | ||
736 | protected bool IsGoingHome(CachedUserInfo uinfo, GridRegion rinfo) | ||
737 | { | ||
738 | if (uinfo.UserProfile == null) | ||
739 | return false; | ||
740 | |||
741 | if (!(uinfo.UserProfile is ForeignUserProfileData)) | ||
742 | // it's a home user, can't be outside to return home | ||
743 | return false; | ||
744 | |||
745 | // OK, it's a foreign user with a ForeignUserProfileData | ||
746 | // and is going back to exactly the home region. | ||
747 | // We can't check if it's going back to a non-home region | ||
748 | // of the home grid. That will be dealt with in the | ||
749 | // receiving end | ||
750 | return (uinfo.UserProfile.HomeRegionID == rinfo.RegionID); | ||
751 | } | ||
752 | |||
753 | protected bool IsLocalUser(CachedUserInfo uinfo) | ||
754 | { | ||
755 | if (uinfo == null) | ||
756 | return false; | ||
757 | |||
758 | return !(uinfo.UserProfile is ForeignUserProfileData); | ||
759 | |||
760 | } | ||
761 | |||
762 | protected bool IsLocalRegion(ulong handle) | ||
763 | { | ||
764 | return m_LocalScenes.ContainsKey(handle); | ||
765 | } | ||
766 | |||
767 | private void DumpUserData(ForeignUserProfileData userData) | ||
768 | { | ||
769 | m_log.Info(" ------------ User Data Dump ----------"); | ||
770 | m_log.Info(" >> Name: " + userData.FirstName + " " + userData.SurName); | ||
771 | m_log.Info(" >> HomeID: " + userData.HomeRegionID); | ||
772 | m_log.Info(" >> UserServer: " + userData.UserServerURI); | ||
773 | m_log.Info(" >> InvServer: " + userData.UserInventoryURI); | ||
774 | m_log.Info(" >> AssetServer: " + userData.UserAssetURI); | ||
775 | m_log.Info(" ------------ -------------- ----------"); | ||
776 | } | ||
777 | |||
778 | private void DumpRegionData(GridRegion rinfo) | ||
779 | { | ||
780 | m_log.Info(" ------------ Region Data Dump ----------"); | ||
781 | m_log.Info(" >> handle: " + rinfo.RegionHandle); | ||
782 | m_log.Info(" >> coords: " + rinfo.RegionLocX + ", " + rinfo.RegionLocY); | ||
783 | m_log.Info(" >> external host name: " + rinfo.ExternalHostName); | ||
784 | m_log.Info(" >> http port: " + rinfo.HttpPort); | ||
785 | m_log.Info(" >> external EP address: " + rinfo.ExternalEndPoint.Address); | ||
786 | m_log.Info(" >> external EP port: " + rinfo.ExternalEndPoint.Port); | ||
787 | m_log.Info(" ------------ -------------- ----------"); | ||
788 | } | ||
789 | |||
790 | |||
791 | #endregion | ||
792 | |||
793 | |||
794 | } | ||
795 | } | ||
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs new file mode 100644 index 0000000..3ca4882 --- /dev/null +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs | |||
@@ -0,0 +1,240 @@ | |||
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 Nini.Config; | ||
30 | using System; | ||
31 | using System.Collections.Generic; | ||
32 | using System.Reflection; | ||
33 | using OpenSim.Framework; | ||
34 | using OpenSim.Framework.Console; | ||
35 | using OpenSim.Server.Base; | ||
36 | using OpenSim.Region.Framework.Interfaces; | ||
37 | using OpenSim.Region.Framework.Scenes; | ||
38 | using OpenSim.Services.Interfaces; | ||
39 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | ||
40 | using OpenMetaverse; | ||
41 | |||
42 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid | ||
43 | { | ||
44 | public class LocalGridServicesConnector : | ||
45 | ISharedRegionModule, IGridService | ||
46 | { | ||
47 | private static readonly ILog m_log = | ||
48 | LogManager.GetLogger( | ||
49 | MethodBase.GetCurrentMethod().DeclaringType); | ||
50 | |||
51 | private static LocalGridServicesConnector m_MainInstance; | ||
52 | |||
53 | private IGridService m_GridService; | ||
54 | private Dictionary<UUID, RegionCache> m_LocalCache = new Dictionary<UUID, RegionCache>(); | ||
55 | |||
56 | private bool m_Enabled = false; | ||
57 | |||
58 | public LocalGridServicesConnector() | ||
59 | { | ||
60 | } | ||
61 | |||
62 | public LocalGridServicesConnector(IConfigSource source) | ||
63 | { | ||
64 | m_log.Debug("[LOCAL GRID CONNECTOR]: LocalGridServicesConnector instantiated"); | ||
65 | m_MainInstance = this; | ||
66 | InitialiseService(source); | ||
67 | } | ||
68 | |||
69 | #region ISharedRegionModule | ||
70 | |||
71 | public Type ReplaceableInterface | ||
72 | { | ||
73 | get { return null; } | ||
74 | } | ||
75 | |||
76 | public string Name | ||
77 | { | ||
78 | get { return "LocalGridServicesConnector"; } | ||
79 | } | ||
80 | |||
81 | public void Initialise(IConfigSource source) | ||
82 | { | ||
83 | IConfig moduleConfig = source.Configs["Modules"]; | ||
84 | if (moduleConfig != null) | ||
85 | { | ||
86 | string name = moduleConfig.GetString("GridServices", ""); | ||
87 | if (name == Name) | ||
88 | { | ||
89 | InitialiseService(source); | ||
90 | m_MainInstance = this; | ||
91 | m_Enabled = true; | ||
92 | m_log.Info("[LOCAL GRID CONNECTOR]: Local grid connector enabled"); | ||
93 | } | ||
94 | } | ||
95 | } | ||
96 | |||
97 | private void InitialiseService(IConfigSource source) | ||
98 | { | ||
99 | IConfig assetConfig = source.Configs["GridService"]; | ||
100 | if (assetConfig == null) | ||
101 | { | ||
102 | m_log.Error("[LOCAL GRID CONNECTOR]: GridService missing from OpenSim.ini"); | ||
103 | return; | ||
104 | } | ||
105 | |||
106 | string serviceDll = assetConfig.GetString("LocalServiceModule", | ||
107 | String.Empty); | ||
108 | |||
109 | if (serviceDll == String.Empty) | ||
110 | { | ||
111 | m_log.Error("[LOCAL GRID CONNECTOR]: No LocalServiceModule named in section GridService"); | ||
112 | return; | ||
113 | } | ||
114 | |||
115 | Object[] args = new Object[] { source }; | ||
116 | m_GridService = | ||
117 | ServerUtils.LoadPlugin<IGridService>(serviceDll, | ||
118 | args); | ||
119 | |||
120 | if (m_GridService == null) | ||
121 | { | ||
122 | m_log.Error("[LOCAL GRID CONNECTOR]: Can't load grid service"); | ||
123 | return; | ||
124 | } | ||
125 | } | ||
126 | |||
127 | public void PostInitialise() | ||
128 | { | ||
129 | if (m_MainInstance == this) | ||
130 | { | ||
131 | MainConsole.Instance.Commands.AddCommand("LocalGridConnector", false, "show neighbours", | ||
132 | "show neighbours", | ||
133 | "Shows the local regions' neighbours", NeighboursCommand); | ||
134 | } | ||
135 | } | ||
136 | |||
137 | public void Close() | ||
138 | { | ||
139 | } | ||
140 | |||
141 | public void AddRegion(Scene scene) | ||
142 | { | ||
143 | if (m_Enabled) | ||
144 | scene.RegisterModuleInterface<IGridService>(this); | ||
145 | |||
146 | if (m_MainInstance == this) | ||
147 | { | ||
148 | if (m_LocalCache.ContainsKey(scene.RegionInfo.RegionID)) | ||
149 | m_log.ErrorFormat("[LOCAL GRID CONNECTOR]: simulator seems to have more than one region with the same UUID. Please correct this!"); | ||
150 | else | ||
151 | m_LocalCache.Add(scene.RegionInfo.RegionID, new RegionCache(scene)); | ||
152 | } | ||
153 | } | ||
154 | |||
155 | public void RemoveRegion(Scene scene) | ||
156 | { | ||
157 | if (m_MainInstance == this) | ||
158 | { | ||
159 | m_LocalCache[scene.RegionInfo.RegionID].Clear(); | ||
160 | m_LocalCache.Remove(scene.RegionInfo.RegionID); | ||
161 | } | ||
162 | } | ||
163 | |||
164 | public void RegionLoaded(Scene scene) | ||
165 | { | ||
166 | } | ||
167 | |||
168 | #endregion | ||
169 | |||
170 | #region IGridService | ||
171 | |||
172 | public bool RegisterRegion(UUID scopeID, GridRegion regionInfo) | ||
173 | { | ||
174 | return m_GridService.RegisterRegion(scopeID, regionInfo); | ||
175 | } | ||
176 | |||
177 | public bool DeregisterRegion(UUID regionID) | ||
178 | { | ||
179 | return m_GridService.DeregisterRegion(regionID); | ||
180 | } | ||
181 | |||
182 | public List<GridRegion> GetNeighbours(UUID scopeID, UUID regionID) | ||
183 | { | ||
184 | if (m_LocalCache.ContainsKey(regionID)) | ||
185 | { | ||
186 | List<GridRegion> neighbours = m_LocalCache[regionID].GetNeighbours(); | ||
187 | if (neighbours.Count == 0) | ||
188 | // try the DB | ||
189 | neighbours = m_GridService.GetNeighbours(scopeID, regionID); | ||
190 | return neighbours; | ||
191 | } | ||
192 | else | ||
193 | { | ||
194 | m_log.WarnFormat("[LOCAL GRID CONNECTOR]: GetNeighbours: Requested region {0} is not on this sim", regionID); | ||
195 | return new List<GridRegion>(); | ||
196 | } | ||
197 | |||
198 | // Don't go to the DB | ||
199 | //return m_GridService.GetNeighbours(scopeID, regionID); | ||
200 | } | ||
201 | |||
202 | public GridRegion GetRegionByUUID(UUID scopeID, UUID regionID) | ||
203 | { | ||
204 | return m_GridService.GetRegionByUUID(scopeID, regionID); | ||
205 | } | ||
206 | |||
207 | public GridRegion GetRegionByPosition(UUID scopeID, int x, int y) | ||
208 | { | ||
209 | return m_GridService.GetRegionByPosition(scopeID, x, y); | ||
210 | } | ||
211 | |||
212 | public GridRegion GetRegionByName(UUID scopeID, string regionName) | ||
213 | { | ||
214 | return m_GridService.GetRegionByName(scopeID, regionName); | ||
215 | } | ||
216 | |||
217 | public List<GridRegion> GetRegionsByName(UUID scopeID, string name, int maxNumber) | ||
218 | { | ||
219 | return m_GridService.GetRegionsByName(scopeID, name, maxNumber); | ||
220 | } | ||
221 | |||
222 | public List<GridRegion> GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax) | ||
223 | { | ||
224 | return m_GridService.GetRegionRange(scopeID, xmin, xmax, ymin, ymax); | ||
225 | } | ||
226 | |||
227 | #endregion | ||
228 | |||
229 | public void NeighboursCommand(string module, string[] cmdparams) | ||
230 | { | ||
231 | foreach (KeyValuePair<UUID, RegionCache> kvp in m_LocalCache) | ||
232 | { | ||
233 | m_log.InfoFormat("*** Neighbours of {0} {1} ***", kvp.Key, kvp.Value.RegionName); | ||
234 | List<GridRegion> regions = kvp.Value.GetNeighbours(); | ||
235 | foreach (GridRegion r in regions) | ||
236 | m_log.InfoFormat(" {0} @ {1}={2}", r.RegionName, r.RegionLocX / Constants.RegionSize, r.RegionLocY / Constants.RegionSize); | ||
237 | } | ||
238 | } | ||
239 | } | ||
240 | } | ||
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionCache.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionCache.cs new file mode 100644 index 0000000..2b336bb --- /dev/null +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionCache.cs | |||
@@ -0,0 +1,79 @@ | |||
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.Reflection; | ||
31 | |||
32 | using OpenSim.Region.Framework.Scenes; | ||
33 | using OpenSim.Services.Interfaces; | ||
34 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | ||
35 | |||
36 | using log4net; | ||
37 | |||
38 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid | ||
39 | { | ||
40 | public class RegionCache | ||
41 | { | ||
42 | private static readonly ILog m_log = | ||
43 | LogManager.GetLogger( | ||
44 | MethodBase.GetCurrentMethod().DeclaringType); | ||
45 | |||
46 | private Scene m_scene; | ||
47 | private Dictionary<ulong, GridRegion> m_neighbours = new Dictionary<ulong, GridRegion>(); | ||
48 | |||
49 | public string RegionName | ||
50 | { | ||
51 | get { return m_scene.RegionInfo.RegionName; } | ||
52 | } | ||
53 | |||
54 | public RegionCache(Scene s) | ||
55 | { | ||
56 | m_scene = s; | ||
57 | m_scene.EventManager.OnRegionUp += OnRegionUp; | ||
58 | } | ||
59 | |||
60 | private void OnRegionUp(GridRegion otherRegion) | ||
61 | { | ||
62 | m_log.DebugFormat("[REGION CACHE]: (on region {0}) Region {1} is up @ {2}-{3}", | ||
63 | m_scene.RegionInfo.RegionName, otherRegion.RegionName, otherRegion.RegionLocX, otherRegion.RegionLocY); | ||
64 | |||
65 | m_neighbours[otherRegion.RegionHandle] = otherRegion; | ||
66 | } | ||
67 | |||
68 | public void Clear() | ||
69 | { | ||
70 | m_scene.EventManager.OnRegionUp -= OnRegionUp; | ||
71 | m_neighbours.Clear(); | ||
72 | } | ||
73 | |||
74 | public List<GridRegion> GetNeighbours() | ||
75 | { | ||
76 | return new List<GridRegion>(m_neighbours.Values); | ||
77 | } | ||
78 | } | ||
79 | } | ||
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs new file mode 100644 index 0000000..72c00fc --- /dev/null +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs | |||
@@ -0,0 +1,194 @@ | |||
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.Reflection; | ||
32 | using Nini.Config; | ||
33 | using OpenMetaverse; | ||
34 | |||
35 | using OpenSim.Framework; | ||
36 | using OpenSim.Services.Connectors; | ||
37 | using OpenSim.Region.Framework.Interfaces; | ||
38 | using OpenSim.Region.Framework.Scenes; | ||
39 | using OpenSim.Services.Interfaces; | ||
40 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | ||
41 | |||
42 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid | ||
43 | { | ||
44 | public class RemoteGridServicesConnector : | ||
45 | GridServicesConnector, ISharedRegionModule, IGridService | ||
46 | { | ||
47 | private static readonly ILog m_log = | ||
48 | LogManager.GetLogger( | ||
49 | MethodBase.GetCurrentMethod().DeclaringType); | ||
50 | |||
51 | private bool m_Enabled = false; | ||
52 | |||
53 | private IGridService m_LocalGridService; | ||
54 | |||
55 | public RemoteGridServicesConnector() | ||
56 | { | ||
57 | } | ||
58 | |||
59 | public RemoteGridServicesConnector(IConfigSource source) | ||
60 | { | ||
61 | InitialiseServices(source); | ||
62 | } | ||
63 | |||
64 | #region ISharedRegionmodule | ||
65 | |||
66 | public Type ReplaceableInterface | ||
67 | { | ||
68 | get { return null; } | ||
69 | } | ||
70 | |||
71 | public string Name | ||
72 | { | ||
73 | get { return "RemoteGridServicesConnector"; } | ||
74 | } | ||
75 | |||
76 | public override void Initialise(IConfigSource source) | ||
77 | { | ||
78 | IConfig moduleConfig = source.Configs["Modules"]; | ||
79 | if (moduleConfig != null) | ||
80 | { | ||
81 | string name = moduleConfig.GetString("GridServices", ""); | ||
82 | if (name == Name) | ||
83 | { | ||
84 | InitialiseServices(source); | ||
85 | m_Enabled = true; | ||
86 | m_log.Info("[REMOTE GRID CONNECTOR]: Remote grid enabled"); | ||
87 | } | ||
88 | } | ||
89 | } | ||
90 | |||
91 | private void InitialiseServices(IConfigSource source) | ||
92 | { | ||
93 | IConfig gridConfig = source.Configs["GridService"]; | ||
94 | if (gridConfig == null) | ||
95 | { | ||
96 | m_log.Error("[REMOTE GRID CONNECTOR]: GridService missing from OpenSim.ini"); | ||
97 | return; | ||
98 | } | ||
99 | |||
100 | base.Initialise(source); | ||
101 | |||
102 | m_LocalGridService = new LocalGridServicesConnector(source); | ||
103 | } | ||
104 | |||
105 | public void PostInitialise() | ||
106 | { | ||
107 | if (m_LocalGridService != null) | ||
108 | ((ISharedRegionModule)m_LocalGridService).PostInitialise(); | ||
109 | } | ||
110 | |||
111 | public void Close() | ||
112 | { | ||
113 | } | ||
114 | |||
115 | public void AddRegion(Scene scene) | ||
116 | { | ||
117 | if (m_Enabled) | ||
118 | scene.RegisterModuleInterface<IGridService>(this); | ||
119 | |||
120 | if (m_LocalGridService != null) | ||
121 | ((ISharedRegionModule)m_LocalGridService).AddRegion(scene); | ||
122 | } | ||
123 | |||
124 | public void RemoveRegion(Scene scene) | ||
125 | { | ||
126 | if (m_LocalGridService != null) | ||
127 | ((ISharedRegionModule)m_LocalGridService).RemoveRegion(scene); | ||
128 | } | ||
129 | |||
130 | public void RegionLoaded(Scene scene) | ||
131 | { | ||
132 | } | ||
133 | |||
134 | #endregion | ||
135 | |||
136 | #region IGridService | ||
137 | |||
138 | public override bool RegisterRegion(UUID scopeID, GridRegion regionInfo) | ||
139 | { | ||
140 | if (m_LocalGridService.RegisterRegion(scopeID, regionInfo)) | ||
141 | return base.RegisterRegion(scopeID, regionInfo); | ||
142 | |||
143 | return false; | ||
144 | } | ||
145 | |||
146 | public override bool DeregisterRegion(UUID regionID) | ||
147 | { | ||
148 | if (m_LocalGridService.DeregisterRegion(regionID)) | ||
149 | return base.DeregisterRegion(regionID); | ||
150 | |||
151 | return false; | ||
152 | } | ||
153 | |||
154 | // Let's override GetNeighbours completely -- never go to the grid server | ||
155 | // Neighbours are/should be cached locally | ||
156 | // For retrieval from the DB, caller should call GetRegionByPosition | ||
157 | public override List<GridRegion> GetNeighbours(UUID scopeID, UUID regionID) | ||
158 | { | ||
159 | return m_LocalGridService.GetNeighbours(scopeID, regionID); | ||
160 | } | ||
161 | |||
162 | public override GridRegion GetRegionByUUID(UUID scopeID, UUID regionID) | ||
163 | { | ||
164 | GridRegion rinfo = m_LocalGridService.GetRegionByUUID(scopeID, regionID); | ||
165 | if (rinfo == null) | ||
166 | rinfo = base.GetRegionByUUID(scopeID, regionID); | ||
167 | |||
168 | return rinfo; | ||
169 | } | ||
170 | |||
171 | public override GridRegion GetRegionByPosition(UUID scopeID, int x, int y) | ||
172 | { | ||
173 | GridRegion rinfo = m_LocalGridService.GetRegionByPosition(scopeID, x, y); | ||
174 | if (rinfo == null) | ||
175 | rinfo = base.GetRegionByPosition(scopeID, x, y); | ||
176 | |||
177 | return rinfo; | ||
178 | } | ||
179 | |||
180 | public override GridRegion GetRegionByName(UUID scopeID, string regionName) | ||
181 | { | ||
182 | GridRegion rinfo = m_LocalGridService.GetRegionByName(scopeID, regionName); | ||
183 | if (rinfo == null) | ||
184 | rinfo = base.GetRegionByName(scopeID, regionName); | ||
185 | |||
186 | return rinfo; | ||
187 | } | ||
188 | |||
189 | // Let's not override GetRegionsByName -- let's get them all from the grid server | ||
190 | // Let's not override GetRegionRange -- let's get them all from the grid server | ||
191 | |||
192 | #endregion | ||
193 | } | ||
194 | } | ||
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs new file mode 100644 index 0000000..2ca90f8 --- /dev/null +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs | |||
@@ -0,0 +1,141 @@ | |||
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.IO; | ||
31 | using System.Reflection; | ||
32 | using System.Threading; | ||
33 | using log4net.Config; | ||
34 | using NUnit.Framework; | ||
35 | using NUnit.Framework.SyntaxHelpers; | ||
36 | using OpenMetaverse; | ||
37 | using OpenSim.Framework; | ||
38 | using Nini.Config; | ||
39 | |||
40 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid; | ||
41 | using OpenSim.Region.Framework.Scenes; | ||
42 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | ||
43 | using OpenSim.Tests.Common; | ||
44 | using OpenSim.Tests.Common.Setup; | ||
45 | |||
46 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid.Tests | ||
47 | { | ||
48 | [TestFixture] | ||
49 | public class GridConnectorsTests | ||
50 | { | ||
51 | LocalGridServicesConnector m_LocalConnector; | ||
52 | private void SetUp() | ||
53 | { | ||
54 | IConfigSource config = new IniConfigSource(); | ||
55 | config.AddConfig("Modules"); | ||
56 | config.AddConfig("GridService"); | ||
57 | config.Configs["Modules"].Set("GridServices", "LocalGridServicesConnector"); | ||
58 | config.Configs["GridService"].Set("LocalServiceModule", "OpenSim.Services.GridService.dll:GridService"); | ||
59 | config.Configs["GridService"].Set("StorageProvider", "OpenSim.Data.Null.dll:NullRegionData"); | ||
60 | |||
61 | m_LocalConnector = new LocalGridServicesConnector(config); | ||
62 | } | ||
63 | |||
64 | /// <summary> | ||
65 | /// Test saving a V0.2 OpenSim Region Archive. | ||
66 | /// </summary> | ||
67 | [Test] | ||
68 | public void TestRegisterRegionV0_2() | ||
69 | { | ||
70 | SetUp(); | ||
71 | |||
72 | // Create 3 regions | ||
73 | GridRegion r1 = new GridRegion(); | ||
74 | r1.RegionName = "Test Region 1"; | ||
75 | r1.RegionID = new UUID(1); | ||
76 | r1.RegionLocX = 1000 * (int)Constants.RegionSize; | ||
77 | r1.RegionLocY = 1000 * (int)Constants.RegionSize; | ||
78 | r1.ExternalHostName = "127.0.0.1"; | ||
79 | r1.HttpPort = 9001; | ||
80 | r1.InternalEndPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("0.0.0.0"), 0); | ||
81 | Scene s = new Scene(new RegionInfo()); | ||
82 | s.RegionInfo.RegionID = r1.RegionID; | ||
83 | m_LocalConnector.AddRegion(s); | ||
84 | |||
85 | |||
86 | GridRegion r2 = new GridRegion(); | ||
87 | r2.RegionName = "Test Region 2"; | ||
88 | r2.RegionID = new UUID(2); | ||
89 | r2.RegionLocX = 1001 * (int)Constants.RegionSize; | ||
90 | r2.RegionLocY = 1000 * (int)Constants.RegionSize; | ||
91 | r2.ExternalHostName = "127.0.0.1"; | ||
92 | r2.HttpPort = 9002; | ||
93 | r2.InternalEndPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("0.0.0.0"), 0); | ||
94 | s = new Scene(new RegionInfo()); | ||
95 | s.RegionInfo.RegionID = r1.RegionID; | ||
96 | m_LocalConnector.AddRegion(s); | ||
97 | |||
98 | GridRegion r3 = new GridRegion(); | ||
99 | r3.RegionName = "Test Region 3"; | ||
100 | r3.RegionID = new UUID(3); | ||
101 | r3.RegionLocX = 1005 * (int)Constants.RegionSize; | ||
102 | r3.RegionLocY = 1000 * (int)Constants.RegionSize; | ||
103 | r3.ExternalHostName = "127.0.0.1"; | ||
104 | r3.HttpPort = 9003; | ||
105 | r3.InternalEndPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("0.0.0.0"), 0); | ||
106 | s = new Scene(new RegionInfo()); | ||
107 | s.RegionInfo.RegionID = r1.RegionID; | ||
108 | m_LocalConnector.AddRegion(s); | ||
109 | |||
110 | m_LocalConnector.RegisterRegion(UUID.Zero, r1); | ||
111 | GridRegion result = m_LocalConnector.GetRegionByName(UUID.Zero, "Test"); | ||
112 | Assert.IsNotNull(result, "Retrieved GetRegionByName is null"); | ||
113 | Assert.That(result.RegionName, Is.EqualTo("Test Region 1"), "Retrieved region's name does not match"); | ||
114 | |||
115 | result = m_LocalConnector.GetRegionByUUID(UUID.Zero, new UUID(1)); | ||
116 | Assert.IsNotNull(result, "Retrieved GetRegionByUUID is null"); | ||
117 | Assert.That(result.RegionID, Is.EqualTo(new UUID(1)), "Retrieved region's UUID does not match"); | ||
118 | |||
119 | result = m_LocalConnector.GetRegionByPosition(UUID.Zero, 1000 * (int)Constants.RegionSize, 1000 * (int)Constants.RegionSize); | ||
120 | Assert.IsNotNull(result, "Retrieved GetRegionByPosition is null"); | ||
121 | Assert.That(result.RegionLocX, Is.EqualTo(1000 * (int)Constants.RegionSize), "Retrieved region's position does not match"); | ||
122 | |||
123 | m_LocalConnector.RegisterRegion(UUID.Zero, r2); | ||
124 | m_LocalConnector.RegisterRegion(UUID.Zero, r3); | ||
125 | |||
126 | List<GridRegion> results = m_LocalConnector.GetNeighbours(UUID.Zero, new UUID(1)); | ||
127 | Assert.IsNotNull(results, "Retrieved neighbours list is null"); | ||
128 | Assert.That(results.Count, Is.EqualTo(1), "Retrieved neighbour collection is greater than expected"); | ||
129 | Assert.That(results[0].RegionID, Is.EqualTo(new UUID(2)), "Retrieved region's UUID does not match"); | ||
130 | |||
131 | results = m_LocalConnector.GetRegionsByName(UUID.Zero, "Test", 10); | ||
132 | Assert.IsNotNull(results, "Retrieved GetRegionsByName list is null"); | ||
133 | Assert.That(results.Count, Is.EqualTo(3), "Retrieved neighbour collection is less than expected"); | ||
134 | |||
135 | results = m_LocalConnector.GetRegionRange(UUID.Zero, 900 * (int)Constants.RegionSize, 1002 * (int)Constants.RegionSize, | ||
136 | 900 * (int)Constants.RegionSize, 1100 * (int)Constants.RegionSize); | ||
137 | Assert.IsNotNull(results, "Retrieved GetRegionRange list is null"); | ||
138 | Assert.That(results.Count, Is.EqualTo(2), "Retrieved neighbour collection is not the number expected"); | ||
139 | } | ||
140 | } | ||
141 | } | ||
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/RESTInterregionComms.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/RESTInterregionComms.cs index 9519e23..696225c 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/RESTInterregionComms.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/RESTInterregionComms.cs | |||
@@ -42,6 +42,8 @@ using OpenSim.Region.Framework.Interfaces; | |||
42 | using OpenSim.Region.Framework.Scenes; | 42 | using OpenSim.Region.Framework.Scenes; |
43 | using OpenSim.Region.Framework.Scenes.Hypergrid; | 43 | using OpenSim.Region.Framework.Scenes.Hypergrid; |
44 | using OpenSim.Region.Framework.Scenes.Serialization; | 44 | using OpenSim.Region.Framework.Scenes.Serialization; |
45 | using OpenSim.Services.Interfaces; | ||
46 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | ||
45 | 47 | ||
46 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion | 48 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion |
47 | { | 49 | { |
@@ -59,6 +61,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion | |||
59 | 61 | ||
60 | protected RegionToRegionClient m_regionClient; | 62 | protected RegionToRegionClient m_regionClient; |
61 | 63 | ||
64 | protected IHyperlinkService m_hyperlinkService; | ||
65 | |||
62 | protected bool m_safemode; | 66 | protected bool m_safemode; |
63 | protected IPAddress m_thisIP; | 67 | protected IPAddress m_thisIP; |
64 | 68 | ||
@@ -134,7 +138,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion | |||
134 | m_localBackend = new LocalInterregionComms(); | 138 | m_localBackend = new LocalInterregionComms(); |
135 | m_commsManager = scene.CommsManager; | 139 | m_commsManager = scene.CommsManager; |
136 | m_aScene = scene; | 140 | m_aScene = scene; |
137 | m_regionClient = new RegionToRegionClient(m_aScene); | 141 | m_hyperlinkService = m_aScene.RequestModuleInterface<IHyperlinkService>(); |
142 | m_regionClient = new RegionToRegionClient(m_aScene, m_hyperlinkService); | ||
138 | m_thisIP = Util.GetHostFromDNS(scene.RegionInfo.ExternalHostName); | 143 | m_thisIP = Util.GetHostFromDNS(scene.RegionInfo.ExternalHostName); |
139 | } | 144 | } |
140 | 145 | ||
@@ -161,7 +166,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion | |||
161 | // else do the remote thing | 166 | // else do the remote thing |
162 | if (!m_localBackend.IsLocalRegion(regionHandle)) | 167 | if (!m_localBackend.IsLocalRegion(regionHandle)) |
163 | { | 168 | { |
164 | RegionInfo regInfo = m_commsManager.GridService.RequestNeighbourInfo(regionHandle); | 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); | ||
165 | if (regInfo != null) | 172 | if (regInfo != null) |
166 | { | 173 | { |
167 | m_regionClient.SendUserInformation(regInfo, aCircuit); | 174 | m_regionClient.SendUserInformation(regInfo, aCircuit); |
@@ -183,7 +190,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion | |||
183 | // else do the remote thing | 190 | // else do the remote thing |
184 | if (!m_localBackend.IsLocalRegion(regionHandle)) | 191 | if (!m_localBackend.IsLocalRegion(regionHandle)) |
185 | { | 192 | { |
186 | RegionInfo regInfo = m_commsManager.GridService.RequestNeighbourInfo(regionHandle); | 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); | ||
187 | if (regInfo != null) | 196 | if (regInfo != null) |
188 | { | 197 | { |
189 | return m_regionClient.DoChildAgentUpdateCall(regInfo, cAgentData); | 198 | return m_regionClient.DoChildAgentUpdateCall(regInfo, cAgentData); |
@@ -204,7 +213,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion | |||
204 | // else do the remote thing | 213 | // else do the remote thing |
205 | if (!m_localBackend.IsLocalRegion(regionHandle)) | 214 | if (!m_localBackend.IsLocalRegion(regionHandle)) |
206 | { | 215 | { |
207 | RegionInfo regInfo = m_commsManager.GridService.RequestNeighbourInfo(regionHandle); | 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); | ||
208 | if (regInfo != null) | 219 | if (regInfo != null) |
209 | { | 220 | { |
210 | return m_regionClient.DoChildAgentUpdateCall(regInfo, cAgentData); | 221 | return m_regionClient.DoChildAgentUpdateCall(regInfo, cAgentData); |
@@ -225,7 +236,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion | |||
225 | // else do the remote thing | 236 | // else do the remote thing |
226 | if (!m_localBackend.IsLocalRegion(regionHandle)) | 237 | if (!m_localBackend.IsLocalRegion(regionHandle)) |
227 | { | 238 | { |
228 | RegionInfo regInfo = m_commsManager.GridService.RequestNeighbourInfo(regionHandle); | 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); | ||
229 | if (regInfo != null) | 242 | if (regInfo != null) |
230 | { | 243 | { |
231 | return m_regionClient.DoRetrieveRootAgentCall(regInfo, id, out agent); | 244 | return m_regionClient.DoRetrieveRootAgentCall(regInfo, id, out agent); |
@@ -257,7 +270,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion | |||
257 | // else do the remote thing | 270 | // else do the remote thing |
258 | if (!m_localBackend.IsLocalRegion(regionHandle)) | 271 | if (!m_localBackend.IsLocalRegion(regionHandle)) |
259 | { | 272 | { |
260 | RegionInfo regInfo = m_commsManager.GridService.RequestNeighbourInfo(regionHandle); | 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); | ||
261 | if (regInfo != null) | 276 | if (regInfo != null) |
262 | { | 277 | { |
263 | return m_regionClient.DoCloseAgentCall(regInfo, id); | 278 | return m_regionClient.DoCloseAgentCall(regInfo, id); |
@@ -284,7 +299,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion | |||
284 | // else do the remote thing | 299 | // else do the remote thing |
285 | if (!m_localBackend.IsLocalRegion(regionHandle)) | 300 | if (!m_localBackend.IsLocalRegion(regionHandle)) |
286 | { | 301 | { |
287 | RegionInfo regInfo = m_commsManager.GridService.RequestNeighbourInfo(regionHandle); | 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); | ||
288 | if (regInfo != null) | 305 | if (regInfo != null) |
289 | { | 306 | { |
290 | return m_regionClient.DoCreateObjectCall( | 307 | return m_regionClient.DoCreateObjectCall( |
@@ -776,16 +793,21 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion | |||
776 | protected class RegionToRegionClient : RegionClient | 793 | protected class RegionToRegionClient : RegionClient |
777 | { | 794 | { |
778 | Scene m_aScene = null; | 795 | Scene m_aScene = null; |
796 | IHyperlinkService m_hyperlinkService; | ||
779 | 797 | ||
780 | public RegionToRegionClient(Scene s) | 798 | public RegionToRegionClient(Scene s, IHyperlinkService hyperService) |
781 | { | 799 | { |
782 | m_aScene = s; | 800 | m_aScene = s; |
801 | m_hyperlinkService = hyperService; | ||
783 | } | 802 | } |
784 | 803 | ||
785 | public override ulong GetRegionHandle(ulong handle) | 804 | public override ulong GetRegionHandle(ulong handle) |
786 | { | 805 | { |
787 | if (m_aScene.SceneGridService is HGSceneCommunicationService) | 806 | if (m_aScene.SceneGridService is HGSceneCommunicationService) |
788 | return ((HGSceneCommunicationService)(m_aScene.SceneGridService)).m_hg.FindRegionHandle(handle); | 807 | { |
808 | if (m_hyperlinkService != null) | ||
809 | return m_hyperlinkService.FindRegionHandle(handle); | ||
810 | } | ||
789 | 811 | ||
790 | return handle; | 812 | return handle; |
791 | } | 813 | } |
@@ -793,29 +815,24 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion | |||
793 | public override bool IsHyperlink(ulong handle) | 815 | public override bool IsHyperlink(ulong handle) |
794 | { | 816 | { |
795 | if (m_aScene.SceneGridService is HGSceneCommunicationService) | 817 | if (m_aScene.SceneGridService is HGSceneCommunicationService) |
796 | return ((HGSceneCommunicationService)(m_aScene.SceneGridService)).m_hg.IsHyperlinkRegion(handle); | 818 | { |
797 | 819 | if ((m_hyperlinkService != null) && (m_hyperlinkService.GetHyperlinkRegion(handle) != null)) | |
820 | return true; | ||
821 | } | ||
798 | return false; | 822 | return false; |
799 | } | 823 | } |
800 | 824 | ||
801 | public override void SendUserInformation(RegionInfo regInfo, AgentCircuitData aCircuit) | 825 | public override void SendUserInformation(GridRegion regInfo, AgentCircuitData aCircuit) |
802 | { | 826 | { |
803 | try | 827 | if (m_hyperlinkService != null) |
804 | { | 828 | m_hyperlinkService.SendUserInformation(regInfo, aCircuit); |
805 | if (m_aScene.SceneGridService is HGSceneCommunicationService) | ||
806 | { | ||
807 | ((HGSceneCommunicationService)(m_aScene.SceneGridService)).m_hg.SendUserInformation(regInfo, aCircuit); | ||
808 | } | ||
809 | } | ||
810 | catch // Bad cast | ||
811 | { } | ||
812 | 829 | ||
813 | } | 830 | } |
814 | 831 | ||
815 | public override void AdjustUserInformation(AgentCircuitData aCircuit) | 832 | public override void AdjustUserInformation(AgentCircuitData aCircuit) |
816 | { | 833 | { |
817 | if (m_aScene.SceneGridService is HGSceneCommunicationService) | 834 | if (m_hyperlinkService != null) |
818 | ((HGSceneCommunicationService)(m_aScene.SceneGridService)).m_hg.AdjustUserInformation(aCircuit); | 835 | m_hyperlinkService.AdjustUserInformation(aCircuit); |
819 | } | 836 | } |
820 | } | 837 | } |
821 | 838 | ||
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs index 1c66254..fd1a759 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs | |||
@@ -525,7 +525,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory | |||
525 | return true; | 525 | return true; |
526 | } | 526 | } |
527 | 527 | ||
528 | string userInventoryServerURI = HGNetworkServersInfo.ServerURI(uinfo.UserProfile.UserInventoryURI); | 528 | if ((uinfo.UserProfile.UserInventoryURI == null) || (uinfo.UserProfile.UserInventoryURI == "")) |
529 | // this happens in standalone profiles, apparently | ||
530 | return true; | ||
531 | |||
532 | string userInventoryServerURI = Util.ServerURI(uinfo.UserProfile.UserInventoryURI); | ||
533 | |||
529 | string uri = m_LocalGridInventoryURI.TrimEnd('/'); | 534 | string uri = m_LocalGridInventoryURI.TrimEnd('/'); |
530 | 535 | ||
531 | if ((userInventoryServerURI == uri) || (userInventoryServerURI == "")) | 536 | if ((userInventoryServerURI == uri) || (userInventoryServerURI == "")) |
@@ -544,7 +549,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory | |||
544 | if ((uinfo == null) || (uinfo.UserProfile == null)) | 549 | if ((uinfo == null) || (uinfo.UserProfile == null)) |
545 | return invURI; | 550 | return invURI; |
546 | 551 | ||
547 | string userInventoryServerURI = HGNetworkServersInfo.ServerURI(uinfo.UserProfile.UserInventoryURI); | 552 | string userInventoryServerURI = Util.ServerURI(uinfo.UserProfile.UserInventoryURI); |
548 | 553 | ||
549 | if ((userInventoryServerURI != null) && | 554 | if ((userInventoryServerURI != null) && |
550 | (userInventoryServerURI != "")) | 555 | (userInventoryServerURI != "")) |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteInventoryServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteInventoryServiceConnector.cs index 0d32c77..69504df 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteInventoryServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteInventoryServiceConnector.cs | |||
@@ -107,7 +107,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory | |||
107 | public void AddRegion(Scene scene) | 107 | public void AddRegion(Scene scene) |
108 | { | 108 | { |
109 | m_Scene = scene; | 109 | m_Scene = scene; |
110 | m_log.Debug("[XXXX] Adding scene " + m_Scene.RegionInfo.RegionName); | 110 | //m_log.Debug("[XXXX] Adding scene " + m_Scene.RegionInfo.RegionName); |
111 | 111 | ||
112 | if (!m_Enabled) | 112 | if (!m_Enabled) |
113 | return; | 113 | return; |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Land/RemoteLandServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Land/RemoteLandServiceConnector.cs index a52c70b..b0ace39 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Land/RemoteLandServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Land/RemoteLandServiceConnector.cs | |||
@@ -37,6 +37,7 @@ using OpenSim.Region.Framework.Scenes; | |||
37 | using OpenSim.Services.Interfaces; | 37 | using OpenSim.Services.Interfaces; |
38 | using OpenSim.Server.Base; | 38 | using OpenSim.Server.Base; |
39 | 39 | ||
40 | |||
40 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Land | 41 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Land |
41 | { | 42 | { |
42 | public class RemoteLandServicesConnector : | 43 | public class RemoteLandServicesConnector : |
@@ -89,7 +90,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Land | |||
89 | if (!m_Enabled) | 90 | if (!m_Enabled) |
90 | return; | 91 | return; |
91 | 92 | ||
92 | m_MapService = scene.CommsManager.GridService; | 93 | m_GridService = scene.GridService; |
93 | m_LocalService.AddRegion(scene); | 94 | m_LocalService.AddRegion(scene); |
94 | scene.RegisterModuleInterface<ILandService>(this); | 95 | scene.RegisterModuleInterface<ILandService>(this); |
95 | } | 96 | } |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Neighbour/LocalNeighbourServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Neighbour/LocalNeighbourServiceConnector.cs index 61bf481..daba0b3 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Neighbour/LocalNeighbourServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Neighbour/LocalNeighbourServiceConnector.cs | |||
@@ -119,7 +119,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Neighbour | |||
119 | 119 | ||
120 | #region INeighbourService | 120 | #region INeighbourService |
121 | 121 | ||
122 | public bool HelloNeighbour(ulong regionHandle, RegionInfo thisRegion) | 122 | public GridRegion HelloNeighbour(ulong regionHandle, RegionInfo thisRegion) |
123 | { | 123 | { |
124 | m_log.DebugFormat("[NEIGHBOUR CONNECTOR]: HelloNeighbour from {0}, to {1}. Count = {2}", | 124 | m_log.DebugFormat("[NEIGHBOUR CONNECTOR]: HelloNeighbour from {0}, to {1}. Count = {2}", |
125 | thisRegion.RegionName, regionHandle, m_Scenes.Count); | 125 | thisRegion.RegionName, regionHandle, m_Scenes.Count); |
@@ -132,7 +132,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Neighbour | |||
132 | } | 132 | } |
133 | } | 133 | } |
134 | m_log.DebugFormat("[NEIGHBOUR CONNECTOR]: region handle {0} not found", regionHandle); | 134 | m_log.DebugFormat("[NEIGHBOUR CONNECTOR]: region handle {0} not found", regionHandle); |
135 | return false; | 135 | return null; |
136 | } | 136 | } |
137 | 137 | ||
138 | #endregion INeighbourService | 138 | #endregion INeighbourService |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Neighbour/RemoteNeighourServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Neighbour/RemoteNeighourServiceConnector.cs index c5bc03b..c6fc2a1 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Neighbour/RemoteNeighourServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Neighbour/RemoteNeighourServiceConnector.cs | |||
@@ -118,7 +118,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Neighbour | |||
118 | if (!m_Enabled) | 118 | if (!m_Enabled) |
119 | return; | 119 | return; |
120 | 120 | ||
121 | m_MapService = scene.CommsManager.GridService; | ||
122 | m_LocalService.AddRegion(scene); | 121 | m_LocalService.AddRegion(scene); |
123 | scene.RegisterModuleInterface<INeighbourService>(this); | 122 | scene.RegisterModuleInterface<INeighbourService>(this); |
124 | } | 123 | } |
@@ -134,16 +133,19 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Neighbour | |||
134 | if (!m_Enabled) | 133 | if (!m_Enabled) |
135 | return; | 134 | return; |
136 | 135 | ||
136 | m_GridService = scene.GridService; | ||
137 | |||
137 | m_log.InfoFormat("[NEIGHBOUR CONNECTOR]: Enabled remote neighbours for region {0}", scene.RegionInfo.RegionName); | 138 | m_log.InfoFormat("[NEIGHBOUR CONNECTOR]: Enabled remote neighbours for region {0}", scene.RegionInfo.RegionName); |
138 | 139 | ||
139 | } | 140 | } |
140 | 141 | ||
141 | #region INeighbourService | 142 | #region INeighbourService |
142 | 143 | ||
143 | public override bool HelloNeighbour(ulong regionHandle, RegionInfo thisRegion) | 144 | public override GridRegion HelloNeighbour(ulong regionHandle, RegionInfo thisRegion) |
144 | { | 145 | { |
145 | if (m_LocalService.HelloNeighbour(regionHandle, thisRegion)) | 146 | GridRegion region = m_LocalService.HelloNeighbour(regionHandle, thisRegion); |
146 | return true; | 147 | if (region != null) |
148 | return region; | ||
147 | 149 | ||
148 | return base.HelloNeighbour(regionHandle, thisRegion); | 150 | return base.HelloNeighbour(regionHandle, thisRegion); |
149 | } | 151 | } |