diff options
Diffstat (limited to '')
4 files changed, 37 insertions, 258 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs b/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs index 62efd60..b6fa41d 100644 --- a/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs +++ b/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs | |||
@@ -35,6 +35,7 @@ using OpenSim.Framework; | |||
35 | using OpenSim.Framework.Communications.Cache; | 35 | using OpenSim.Framework.Communications.Cache; |
36 | using OpenSim.Framework.Communications.Clients; | 36 | using OpenSim.Framework.Communications.Clients; |
37 | using OpenSim.Region.Framework.Scenes.Serialization; | 37 | using OpenSim.Region.Framework.Scenes.Serialization; |
38 | using OpenSim.Services.Interfaces; | ||
38 | 39 | ||
39 | //using HyperGrid.Framework; | 40 | //using HyperGrid.Framework; |
40 | //using OpenSim.Region.Communications.Hypergrid; | 41 | //using OpenSim.Region.Communications.Hypergrid; |
@@ -50,6 +51,18 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid | |||
50 | // private Dictionary<string, InventoryClient> m_inventoryServers = new Dictionary<string, InventoryClient>(); | 51 | // private Dictionary<string, InventoryClient> m_inventoryServers = new Dictionary<string, InventoryClient>(); |
51 | 52 | ||
52 | private Scene m_scene; | 53 | private Scene m_scene; |
54 | |||
55 | private IHyperlinkService m_hyper; | ||
56 | IHyperlinkService HyperlinkService | ||
57 | { | ||
58 | get | ||
59 | { | ||
60 | if (m_hyper == null) | ||
61 | m_hyper = m_scene.RequestModuleInterface<IHyperlinkService>(); | ||
62 | return m_hyper; | ||
63 | } | ||
64 | } | ||
65 | |||
53 | #endregion | 66 | #endregion |
54 | 67 | ||
55 | #region Constructor | 68 | #region Constructor |
@@ -79,22 +92,6 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid | |||
79 | // return null; | 92 | // return null; |
80 | // } | 93 | // } |
81 | 94 | ||
82 | private bool IsLocalUser(UUID userID) | ||
83 | { | ||
84 | CachedUserInfo uinfo = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(userID); | ||
85 | |||
86 | if (uinfo != null) | ||
87 | { | ||
88 | if (HGNetworkServersInfo.Singleton.IsLocalUser(uinfo.UserProfile)) | ||
89 | { | ||
90 | m_log.Debug("[HGScene]: Home user " + uinfo.UserProfile.FirstName + " " + uinfo.UserProfile.SurName); | ||
91 | return true; | ||
92 | } | ||
93 | } | ||
94 | |||
95 | m_log.Debug("[HGScene]: Foreign user " + uinfo.UserProfile.FirstName + " " + uinfo.UserProfile.SurName); | ||
96 | return false; | ||
97 | } | ||
98 | 95 | ||
99 | public AssetBase FetchAsset(string url, UUID assetID) | 96 | public AssetBase FetchAsset(string url, UUID assetID) |
100 | { | 97 | { |
@@ -170,7 +167,7 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid | |||
170 | 167 | ||
171 | public void Get(UUID assetID, UUID ownerID) | 168 | public void Get(UUID assetID, UUID ownerID) |
172 | { | 169 | { |
173 | if (!IsLocalUser(ownerID)) | 170 | if (!HyperlinkService.IsLocalUser(ownerID)) |
174 | { | 171 | { |
175 | // Get the item from the remote asset server onto the local AssetCache | 172 | // Get the item from the remote asset server onto the local AssetCache |
176 | // and place an entry in m_assetMap | 173 | // and place an entry in m_assetMap |
@@ -228,7 +225,7 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid | |||
228 | 225 | ||
229 | public void Post(UUID assetID, UUID ownerID) | 226 | public void Post(UUID assetID, UUID ownerID) |
230 | { | 227 | { |
231 | if (!IsLocalUser(ownerID)) | 228 | if (!HyperlinkService.IsLocalUser(ownerID)) |
232 | { | 229 | { |
233 | // Post the item from the local AssetCache onto the remote asset server | 230 | // Post the item from the local AssetCache onto the remote asset server |
234 | // and place an entry in m_assetMap | 231 | // and place an entry in m_assetMap |
diff --git a/OpenSim/Region/Framework/Scenes/Hypergrid/HGHyperlink.cs b/OpenSim/Region/Framework/Scenes/Hypergrid/HGHyperlink.cs deleted file mode 100644 index a576feb..0000000 --- a/OpenSim/Region/Framework/Scenes/Hypergrid/HGHyperlink.cs +++ /dev/null | |||
@@ -1,232 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Net; | ||
30 | using System.Reflection; | ||
31 | using log4net; | ||
32 | using OpenMetaverse; | ||
33 | using OpenSim.Framework; | ||
34 | |||
35 | namespace OpenSim.Region.Framework.Scenes.Hypergrid | ||
36 | { | ||
37 | public class HGHyperlink | ||
38 | { | ||
39 | private static readonly ILog m_log = | ||
40 | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
41 | private static Random random = new Random(); | ||
42 | |||
43 | public static RegionInfo TryLinkRegionToCoords(Scene m_scene, IClientAPI client, string mapName, uint xloc, uint yloc) | ||
44 | { | ||
45 | string host = "127.0.0.1"; | ||
46 | string portstr; | ||
47 | string regionName = ""; | ||
48 | uint port = 9000; | ||
49 | string[] parts = mapName.Split(new char[] { ':' }); | ||
50 | if (parts.Length >= 1) | ||
51 | { | ||
52 | host = parts[0]; | ||
53 | } | ||
54 | if (parts.Length >= 2) | ||
55 | { | ||
56 | portstr = parts[1]; | ||
57 | if (!UInt32.TryParse(portstr, out port)) | ||
58 | regionName = parts[1]; | ||
59 | } | ||
60 | // always take the last one | ||
61 | if (parts.Length >= 3) | ||
62 | { | ||
63 | regionName = parts[2]; | ||
64 | } | ||
65 | |||
66 | // Sanity check. Don't ever link to this sim. | ||
67 | IPAddress ipaddr = null; | ||
68 | try | ||
69 | { | ||
70 | ipaddr = Util.GetHostFromDNS(host); | ||
71 | } | ||
72 | catch { } | ||
73 | |||
74 | if ((ipaddr != null) && | ||
75 | !((m_scene.RegionInfo.ExternalEndPoint.Address.Equals(ipaddr)) && (m_scene.RegionInfo.HttpPort == port))) | ||
76 | { | ||
77 | RegionInfo regInfo; | ||
78 | bool success = TryCreateLink(m_scene, client, xloc, yloc, regionName, port, host, out regInfo); | ||
79 | if (success) | ||
80 | { | ||
81 | regInfo.RegionName = mapName; | ||
82 | return regInfo; | ||
83 | } | ||
84 | } | ||
85 | |||
86 | return null; | ||
87 | } | ||
88 | |||
89 | public static RegionInfo TryLinkRegion(Scene m_scene, IClientAPI client, string mapName) | ||
90 | { | ||
91 | uint xloc = (uint)(random.Next(0, Int16.MaxValue)); | ||
92 | return TryLinkRegionToCoords(m_scene, client, mapName, xloc, 0); | ||
93 | } | ||
94 | |||
95 | public static bool TryCreateLink(Scene m_scene, IClientAPI client, uint xloc, uint yloc, | ||
96 | string externalRegionName, uint externalPort, string externalHostName, out RegionInfo regInfo) | ||
97 | { | ||
98 | m_log.DebugFormat("[HGrid]: Link to {0}:{1}, in {2}-{3}", externalHostName, externalPort, xloc, yloc); | ||
99 | |||
100 | regInfo = new RegionInfo(); | ||
101 | regInfo.RegionName = externalRegionName; | ||
102 | regInfo.HttpPort = externalPort; | ||
103 | regInfo.ExternalHostName = externalHostName; | ||
104 | regInfo.RegionLocX = xloc; | ||
105 | regInfo.RegionLocY = yloc; | ||
106 | |||
107 | try | ||
108 | { | ||
109 | regInfo.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), (int)0); | ||
110 | } | ||
111 | catch (Exception e) | ||
112 | { | ||
113 | m_log.Warn("[HGrid]: Wrong format for link-region: " + e.Message); | ||
114 | return false; | ||
115 | } | ||
116 | regInfo.RemotingAddress = regInfo.ExternalEndPoint.Address.ToString(); | ||
117 | |||
118 | // Finally, link it | ||
119 | try | ||
120 | { | ||
121 | m_scene.CommsManager.GridService.RegisterRegion(regInfo); | ||
122 | } | ||
123 | catch (Exception e) | ||
124 | { | ||
125 | m_log.Warn("[HGrid]: Unable to link region: " + e.Message); | ||
126 | return false; | ||
127 | } | ||
128 | |||
129 | uint x, y; | ||
130 | if (!Check4096(m_scene, regInfo, out x, out y)) | ||
131 | { | ||
132 | m_scene.CommsManager.GridService.DeregisterRegion(regInfo); | ||
133 | if (client != null) | ||
134 | client.SendAlertMessage("Region is too far (" + x + ", " + y + ")"); | ||
135 | m_log.Info("[HGrid]: Unable to link, region is too far (" + x + ", " + y + ")"); | ||
136 | return false; | ||
137 | } | ||
138 | |||
139 | if (!CheckCoords(m_scene.RegionInfo.RegionLocX, m_scene.RegionInfo.RegionLocY, x, y)) | ||
140 | { | ||
141 | m_scene.CommsManager.GridService.DeregisterRegion(regInfo); | ||
142 | if (client != null) | ||
143 | client.SendAlertMessage("Region has incompatible coordinates (" + x + ", " + y + ")"); | ||
144 | m_log.Info("[HGrid]: Unable to link, region has incompatible coordinates (" + x + ", " + y + ")"); | ||
145 | return false; | ||
146 | } | ||
147 | |||
148 | m_log.Debug("[HGrid]: link region succeeded"); | ||
149 | return true; | ||
150 | } | ||
151 | |||
152 | public static bool TryUnlinkRegion(Scene m_scene, string mapName) | ||
153 | { | ||
154 | RegionInfo regInfo = null; | ||
155 | if (mapName.Contains(":")) | ||
156 | { | ||
157 | string host = "127.0.0.1"; | ||
158 | //string portstr; | ||
159 | //string regionName = ""; | ||
160 | uint port = 9000; | ||
161 | string[] parts = mapName.Split(new char[] { ':' }); | ||
162 | if (parts.Length >= 1) | ||
163 | { | ||
164 | host = parts[0]; | ||
165 | } | ||
166 | // if (parts.Length >= 2) | ||
167 | // { | ||
168 | // portstr = parts[1]; | ||
169 | // if (!UInt32.TryParse(portstr, out port)) | ||
170 | // regionName = parts[1]; | ||
171 | // } | ||
172 | // always take the last one | ||
173 | // if (parts.Length >= 3) | ||
174 | // { | ||
175 | // regionName = parts[2]; | ||
176 | // } | ||
177 | regInfo = m_scene.CommsManager.GridService.RequestNeighbourInfo(host, port); | ||
178 | } | ||
179 | else | ||
180 | { | ||
181 | regInfo = m_scene.CommsManager.GridService.RequestNeighbourInfo(mapName); | ||
182 | } | ||
183 | if (regInfo != null) | ||
184 | { | ||
185 | return m_scene.CommsManager.GridService.DeregisterRegion(regInfo); | ||
186 | } | ||
187 | else | ||
188 | { | ||
189 | m_log.InfoFormat("[HGrid]: Region {0} not found", mapName); | ||
190 | return false; | ||
191 | } | ||
192 | } | ||
193 | |||
194 | /// <summary> | ||
195 | /// Cope with this viewer limitation. | ||
196 | /// </summary> | ||
197 | /// <param name="regInfo"></param> | ||
198 | /// <returns></returns> | ||
199 | public static bool Check4096(Scene m_scene, RegionInfo regInfo, out uint x, out uint y) | ||
200 | { | ||
201 | ulong realHandle; | ||
202 | if (UInt64.TryParse(regInfo.regionSecret, out realHandle)) | ||
203 | { | ||
204 | Utils.LongToUInts(realHandle, out x, out y); | ||
205 | x = x / Constants.RegionSize; | ||
206 | y = y / Constants.RegionSize; | ||
207 | |||
208 | if ((Math.Abs((int)m_scene.RegionInfo.RegionLocX - (int)x) >= 4096) || | ||
209 | (Math.Abs((int)m_scene.RegionInfo.RegionLocY - (int)y) >= 4096)) | ||
210 | { | ||
211 | return false; | ||
212 | } | ||
213 | return true; | ||
214 | } | ||
215 | else | ||
216 | { | ||
217 | m_scene.CommsManager.GridService.RegisterRegion(regInfo); | ||
218 | m_log.Debug("[HGrid]: Gnomes. Region deregistered."); | ||
219 | x = y = 0; | ||
220 | return false; | ||
221 | } | ||
222 | } | ||
223 | |||
224 | public static bool CheckCoords(uint thisx, uint thisy, uint x, uint y) | ||
225 | { | ||
226 | if ((thisx == x) && (thisy == y)) | ||
227 | return false; | ||
228 | return true; | ||
229 | } | ||
230 | |||
231 | } | ||
232 | } | ||
diff --git a/OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.cs b/OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.cs index bf55df7..b1981b6 100644 --- a/OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.cs +++ b/OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.cs | |||
@@ -29,6 +29,7 @@ using OpenMetaverse; | |||
29 | using OpenSim.Framework; | 29 | using OpenSim.Framework; |
30 | using OpenSim.Framework.Communications.Cache; | 30 | using OpenSim.Framework.Communications.Cache; |
31 | using TPFlags = OpenSim.Framework.Constants.TeleportFlags; | 31 | using TPFlags = OpenSim.Framework.Constants.TeleportFlags; |
32 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | ||
32 | 33 | ||
33 | namespace OpenSim.Region.Framework.Scenes.Hypergrid | 34 | namespace OpenSim.Region.Framework.Scenes.Hypergrid |
34 | { | 35 | { |
@@ -50,7 +51,7 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid | |||
50 | 51 | ||
51 | if (UserProfile != null) | 52 | if (UserProfile != null) |
52 | { | 53 | { |
53 | RegionInfo regionInfo = CommsManager.GridService.RequestNeighbourInfo(UserProfile.HomeRegion); | 54 | GridRegion regionInfo = GridService.GetRegionByUUID(UUID.Zero, UserProfile.HomeRegionID); |
54 | //if (regionInfo != null) | 55 | //if (regionInfo != null) |
55 | //{ | 56 | //{ |
56 | // UserProfile.HomeRegionID = regionInfo.RegionID; | 57 | // UserProfile.HomeRegionID = regionInfo.RegionID; |
diff --git a/OpenSim/Region/Framework/Scenes/Hypergrid/HGSceneCommunicationService.cs b/OpenSim/Region/Framework/Scenes/Hypergrid/HGSceneCommunicationService.cs index efc644d..d7e62a8 100644 --- a/OpenSim/Region/Framework/Scenes/Hypergrid/HGSceneCommunicationService.cs +++ b/OpenSim/Region/Framework/Scenes/Hypergrid/HGSceneCommunicationService.cs | |||
@@ -38,6 +38,8 @@ using OpenSim.Framework.Communications; | |||
38 | using OpenSim.Framework.Communications.Cache; | 38 | using OpenSim.Framework.Communications.Cache; |
39 | using OpenSim.Framework.Capabilities; | 39 | using OpenSim.Framework.Capabilities; |
40 | using OpenSim.Region.Framework.Interfaces; | 40 | using OpenSim.Region.Framework.Interfaces; |
41 | using OpenSim.Services.Interfaces; | ||
42 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | ||
41 | 43 | ||
42 | namespace OpenSim.Region.Framework.Scenes.Hypergrid | 44 | namespace OpenSim.Region.Framework.Scenes.Hypergrid |
43 | { | 45 | { |
@@ -45,11 +47,19 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid | |||
45 | { | 47 | { |
46 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 48 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
47 | 49 | ||
48 | public readonly IHyperlink m_hg; | 50 | private IHyperlinkService m_hg; |
51 | IHyperlinkService HyperlinkService | ||
52 | { | ||
53 | get | ||
54 | { | ||
55 | if (m_hg == null) | ||
56 | m_hg = m_scene.RequestModuleInterface<IHyperlinkService>(); | ||
57 | return m_hg; | ||
58 | } | ||
59 | } | ||
49 | 60 | ||
50 | public HGSceneCommunicationService(CommunicationsManager commsMan, IHyperlink hg) : base(commsMan) | 61 | public HGSceneCommunicationService(CommunicationsManager commsMan) : base(commsMan) |
51 | { | 62 | { |
52 | m_hg = hg; | ||
53 | } | 63 | } |
54 | 64 | ||
55 | 65 | ||
@@ -112,7 +122,10 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid | |||
112 | } | 122 | } |
113 | else | 123 | else |
114 | { | 124 | { |
115 | RegionInfo reg = RequestNeighbouringRegionInfo(regionHandle); | 125 | uint x = 0, y = 0; |
126 | Utils.LongToUInts(regionHandle, out x, out y); | ||
127 | GridRegion reg = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, (int)x, (int)y); | ||
128 | |||
116 | if (reg != null) | 129 | if (reg != null) |
117 | { | 130 | { |
118 | 131 | ||
@@ -125,13 +138,13 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid | |||
125 | /// Hypergrid mod start | 138 | /// Hypergrid mod start |
126 | /// | 139 | /// |
127 | /// | 140 | /// |
128 | bool isHyperLink = m_hg.IsHyperlinkRegion(reg.RegionHandle); | 141 | bool isHyperLink = (HyperlinkService.GetHyperlinkRegion(reg.RegionHandle) != null); |
129 | bool isHomeUser = true; | 142 | bool isHomeUser = true; |
130 | ulong realHandle = regionHandle; | 143 | ulong realHandle = regionHandle; |
131 | CachedUserInfo uinfo = m_commsProvider.UserProfileCacheService.GetUserDetails(avatar.UUID); | 144 | CachedUserInfo uinfo = m_commsProvider.UserProfileCacheService.GetUserDetails(avatar.UUID); |
132 | if (uinfo != null) | 145 | if (uinfo != null) |
133 | { | 146 | { |
134 | isHomeUser = HGNetworkServersInfo.Singleton.IsLocalUser(uinfo.UserProfile); | 147 | isHomeUser = HyperlinkService.IsLocalUser(uinfo.UserProfile.ID); |
135 | realHandle = m_hg.FindRegionHandle(regionHandle); | 148 | realHandle = m_hg.FindRegionHandle(regionHandle); |
136 | m_log.Debug("XXX ---- home user? " + isHomeUser + " --- hyperlink? " + isHyperLink + " --- real handle: " + realHandle.ToString()); | 149 | m_log.Debug("XXX ---- home user? " + isHomeUser + " --- hyperlink? " + isHyperLink + " --- real handle: " + realHandle.ToString()); |
137 | } | 150 | } |
@@ -344,7 +357,7 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid | |||
344 | m_commsProvider.UserProfileCacheService.RemoveUser(avatar.UUID); | 357 | m_commsProvider.UserProfileCacheService.RemoveUser(avatar.UUID); |
345 | m_log.DebugFormat( | 358 | m_log.DebugFormat( |
346 | "[HGSceneCommService]: User {0} is going to another region, profile cache removed", | 359 | "[HGSceneCommService]: User {0} is going to another region, profile cache removed", |
347 | avatar.UUID); | 360 | avatar.UUID); |
348 | } | 361 | } |
349 | } | 362 | } |
350 | else | 363 | else |