aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorDiva Canto2010-01-17 07:37:43 -0800
committerDiva Canto2010-01-17 07:37:43 -0800
commit6dceb8b4a98974a6869e2695e605caa31711e7a5 (patch)
tree7359f5d9ac2ae55f7a0557ecc4482a6767462489
parentBeginning of rewriting HG. Compiles, and runs, but HG functions not restored ... (diff)
downloadopensim-SC_OLD-6dceb8b4a98974a6869e2695e605caa31711e7a5.zip
opensim-SC_OLD-6dceb8b4a98974a6869e2695e605caa31711e7a5.tar.gz
opensim-SC_OLD-6dceb8b4a98974a6869e2695e605caa31711e7a5.tar.bz2
opensim-SC_OLD-6dceb8b4a98974a6869e2695e605caa31711e7a5.tar.xz
These 2 were moved to corresponding Hypergrid folders. The server connector was renamed to Gatekeeper, because it will have all the handlers for the gatekeeper.
Diffstat (limited to '')
-rw-r--r--OpenSim/Server/Handlers/Grid/HypergridServerConnector.cs208
-rw-r--r--OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs262
2 files changed, 0 insertions, 470 deletions
diff --git a/OpenSim/Server/Handlers/Grid/HypergridServerConnector.cs b/OpenSim/Server/Handlers/Grid/HypergridServerConnector.cs
deleted file mode 100644
index 115ac29..0000000
--- a/OpenSim/Server/Handlers/Grid/HypergridServerConnector.cs
+++ /dev/null
@@ -1,208 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections;
30using System.Collections.Generic;
31using System.Reflection;
32using System.Net;
33using Nini.Config;
34using OpenSim.Framework;
35using OpenSim.Server.Base;
36using OpenSim.Services.Interfaces;
37using OpenSim.Framework.Servers.HttpServer;
38using OpenSim.Server.Handlers.Base;
39using GridRegion = OpenSim.Services.Interfaces.GridRegion;
40
41using OpenMetaverse;
42using log4net;
43using Nwc.XmlRpc;
44
45namespace OpenSim.Server.Handlers.Grid
46{
47 public class HypergridServiceInConnector : ServiceConnector
48 {
49 private static readonly ILog m_log =
50 LogManager.GetLogger(
51 MethodBase.GetCurrentMethod().DeclaringType);
52
53 private List<GridRegion> m_RegionsOnSim = new List<GridRegion>();
54 private IHyperlinkService m_HyperlinkService;
55
56 public HypergridServiceInConnector(IConfigSource config, IHttpServer server, IHyperlinkService hyperService) :
57 base(config, server, String.Empty)
58 {
59 m_HyperlinkService = hyperService;
60 server.AddXmlRPCHandler("link_region", LinkRegionRequest, false);
61 server.AddXmlRPCHandler("expect_hg_user", ExpectHGUser, false);
62 }
63
64 public void AddRegion(GridRegion rinfo)
65 {
66 m_RegionsOnSim.Add(rinfo);
67 }
68
69 public void RemoveRegion(GridRegion rinfo)
70 {
71 if (m_RegionsOnSim.Contains(rinfo))
72 m_RegionsOnSim.Remove(rinfo);
73 }
74
75 /// <summary>
76 /// Someone wants to link to us
77 /// </summary>
78 /// <param name="request"></param>
79 /// <returns></returns>
80 public XmlRpcResponse LinkRegionRequest(XmlRpcRequest request, IPEndPoint remoteClient)
81 {
82 Hashtable requestData = (Hashtable)request.Params[0];
83 //string host = (string)requestData["host"];
84 //string portstr = (string)requestData["port"];
85 string name = (string)requestData["region_name"];
86
87 m_log.DebugFormat("[HGrid]: Hyperlink request");
88
89 GridRegion regInfo = null;
90 foreach (GridRegion r in m_RegionsOnSim)
91 {
92 if ((r.RegionName != null) && (name != null) && (r.RegionName.ToLower() == name.ToLower()))
93 {
94 regInfo = r;
95 break;
96 }
97 }
98
99 if (regInfo == null)
100 regInfo = m_RegionsOnSim[0]; // Send out the first region
101
102 Hashtable hash = new Hashtable();
103 hash["uuid"] = regInfo.RegionID.ToString();
104 m_log.Debug(">> Here " + regInfo.RegionID);
105 hash["handle"] = regInfo.RegionHandle.ToString();
106 hash["region_image"] = regInfo.TerrainImage.ToString();
107 hash["region_name"] = regInfo.RegionName;
108 hash["internal_port"] = regInfo.InternalEndPoint.Port.ToString();
109 //m_log.Debug(">> Here: " + regInfo.InternalEndPoint.Port);
110
111
112 XmlRpcResponse response = new XmlRpcResponse();
113 response.Value = hash;
114 return response;
115 }
116
117 /// <summary>
118 /// Received from other HGrid nodes when a user wants to teleport here. This call allows
119 /// the region to prepare for direct communication from the client. Sends back an empty
120 /// xmlrpc response on completion.
121 /// This is somewhat similar to OGS1's ExpectUser, but with the additional task of
122 /// registering the user in the local user cache.
123 /// </summary>
124 /// <param name="request"></param>
125 /// <returns></returns>
126 public XmlRpcResponse ExpectHGUser(XmlRpcRequest request, IPEndPoint remoteClient)
127 {
128 Hashtable requestData = (Hashtable)request.Params[0];
129 ForeignUserProfileData userData = new ForeignUserProfileData();
130
131 userData.FirstName = (string)requestData["firstname"];
132 userData.SurName = (string)requestData["lastname"];
133 userData.ID = new UUID((string)requestData["agent_id"]);
134 UUID sessionID = new UUID((string)requestData["session_id"]);
135 userData.HomeLocation = new Vector3((float)Convert.ToDecimal((string)requestData["startpos_x"]),
136 (float)Convert.ToDecimal((string)requestData["startpos_y"]),
137 (float)Convert.ToDecimal((string)requestData["startpos_z"]));
138
139 userData.UserServerURI = (string)requestData["userserver_id"];
140 userData.UserAssetURI = (string)requestData["assetserver_id"];
141 userData.UserInventoryURI = (string)requestData["inventoryserver_id"];
142
143 m_log.DebugFormat("[HGrid]: Prepare for connection from {0} {1} (@{2}) UUID={3}",
144 userData.FirstName, userData.SurName, userData.UserServerURI, userData.ID);
145
146 ulong userRegionHandle = 0;
147 int userhomeinternalport = 0;
148 if (requestData.ContainsKey("region_uuid"))
149 {
150 UUID uuid = UUID.Zero;
151 UUID.TryParse((string)requestData["region_uuid"], out uuid);
152 userData.HomeRegionID = uuid;
153 userRegionHandle = Convert.ToUInt64((string)requestData["regionhandle"]);
154 userData.UserHomeAddress = (string)requestData["home_address"];
155 userData.UserHomePort = (string)requestData["home_port"];
156 userhomeinternalport = Convert.ToInt32((string)requestData["internal_port"]);
157
158 m_log.Debug("[HGrid]: home_address: " + userData.UserHomeAddress +
159 "; home_port: " + userData.UserHomePort);
160 }
161 else
162 m_log.WarnFormat("[HGrid]: User has no home region information");
163
164 XmlRpcResponse resp = new XmlRpcResponse();
165
166 // Let's check if someone is trying to get in with a stolen local identity.
167 // The need for this test is a consequence of not having truly global names :-/
168 bool comingHome = false;
169 if (m_HyperlinkService.CheckUserAtEntry(userData.ID, sessionID, out comingHome) == false)
170 {
171 m_log.WarnFormat("[HGrid]: Access denied to foreign user.");
172 Hashtable respdata = new Hashtable();
173 respdata["success"] = "FALSE";
174 respdata["reason"] = "Foreign user has the same ID as a local user, or logins disabled.";
175 resp.Value = respdata;
176 return resp;
177 }
178
179 // Finally, everything looks ok
180 //m_log.Debug("XXX---- EVERYTHING OK ---XXX");
181
182 if (!comingHome)
183 {
184 // We don't do this if the user is coming to the home grid
185 GridRegion home = new GridRegion();
186 home.RegionID = userData.HomeRegionID;
187 home.ExternalHostName = userData.UserHomeAddress;
188 home.HttpPort = Convert.ToUInt32(userData.UserHomePort);
189 uint x = 0, y = 0;
190 Utils.LongToUInts(userRegionHandle, out x, out y);
191 home.RegionLocX = (int)x;
192 home.RegionLocY = (int)y;
193 home.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), (int)userhomeinternalport);
194
195 m_HyperlinkService.AcceptUser(userData, home);
196 }
197 // else the user is coming to a non-home region of the home grid
198 // We simply drop this user information altogether
199
200 Hashtable respdata2 = new Hashtable();
201 respdata2["success"] = "TRUE";
202 resp.Value = respdata2;
203
204 return resp;
205 }
206
207 }
208}
diff --git a/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs b/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs
deleted file mode 100644
index 8b39171..0000000
--- a/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs
+++ /dev/null
@@ -1,262 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections;
30using System.Collections.Generic;
31using System.Text;
32using System.Drawing;
33using System.Net;
34using System.Reflection;
35using OpenSim.Services.Interfaces;
36using GridRegion = OpenSim.Services.Interfaces.GridRegion;
37
38using OpenSim.Framework;
39
40using OpenMetaverse;
41using OpenMetaverse.Imaging;
42using log4net;
43using Nwc.XmlRpc;
44
45namespace OpenSim.Services.Connectors.Grid
46{
47 public class HypergridServiceConnector
48 {
49 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
50
51 private IAssetService m_AssetService;
52
53 public HypergridServiceConnector(IAssetService assService)
54 {
55 m_AssetService = assService;
56 }
57
58 public bool LinkRegion(GridRegion info, out UUID regionID, out ulong regionHandle, out string reason)
59 {
60 regionID = LinkRegion(info, out regionHandle);
61 // reason...
62 reason = string.Empty;
63 return true;
64 }
65
66 public UUID LinkRegion(GridRegion info, out ulong realHandle)
67 {
68 UUID uuid = UUID.Zero;
69 realHandle = 0;
70
71 Hashtable hash = new Hashtable();
72 hash["region_name"] = info.RegionName;
73
74 IList paramList = new ArrayList();
75 paramList.Add(hash);
76
77 XmlRpcRequest request = new XmlRpcRequest("link_region", paramList);
78 string uri = "http://" + info.ExternalEndPoint.Address + ":" + info.HttpPort + "/";
79 m_log.Debug("[HGrid]: Linking to " + uri);
80 XmlRpcResponse response = null;
81 try
82 {
83 response = request.Send(uri, 10000);
84 }
85 catch (Exception e)
86 {
87 m_log.Debug("[HGrid]: Exception " + e.Message);
88 return uuid;
89 }
90
91 if (response.IsFault)
92 {
93 m_log.ErrorFormat("[HGrid]: remote call returned an error: {0}", response.FaultString);
94 }
95 else
96 {
97 hash = (Hashtable)response.Value;
98 //foreach (Object o in hash)
99 // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value);
100 try
101 {
102 UUID.TryParse((string)hash["uuid"], out uuid);
103 //m_log.Debug(">> HERE, uuid: " + uuid);
104 info.RegionID = uuid;
105 if ((string)hash["handle"] != null)
106 {
107 realHandle = Convert.ToUInt64((string)hash["handle"]);
108 //m_log.Debug(">> HERE, realHandle: " + realHandle);
109 }
110 //if (hash["region_image"] != null)
111 //{
112 // UUID img = UUID.Zero;
113 // UUID.TryParse((string)hash["region_image"], out img);
114 // info.RegionSettings.TerrainImageID = img;
115 //}
116 if (hash["region_name"] != null)
117 {
118 info.RegionName = (string)hash["region_name"];
119 //m_log.Debug(">> " + info.RegionName);
120 }
121 if (hash["internal_port"] != null)
122 {
123 int port = Convert.ToInt32((string)hash["internal_port"]);
124 info.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), port);
125 //m_log.Debug(">> " + info.InternalEndPoint.ToString());
126 }
127
128 }
129 catch (Exception e)
130 {
131 m_log.Error("[HGrid]: Got exception while parsing hyperlink response " + e.StackTrace);
132 }
133 }
134 return uuid;
135 }
136
137 public void GetMapImage(GridRegion info)
138 {
139 try
140 {
141 string regionimage = "regionImage" + info.RegionID.ToString();
142 regionimage = regionimage.Replace("-", "");
143
144 WebClient c = new WebClient();
145 string uri = "http://" + info.ExternalHostName + ":" + info.HttpPort + "/index.php?method=" + regionimage;
146 //m_log.Debug("JPEG: " + uri);
147 c.DownloadFile(uri, info.RegionID.ToString() + ".jpg");
148 Bitmap m = new Bitmap(info.RegionID.ToString() + ".jpg");
149 //m_log.Debug("Size: " + m.PhysicalDimension.Height + "-" + m.PhysicalDimension.Width);
150 byte[] imageData = OpenJPEG.EncodeFromImage(m, true);
151 AssetBase ass = new AssetBase(UUID.Random(), "region " + info.RegionID.ToString(), (sbyte)AssetType.Texture);
152
153 // !!! for now
154 //info.RegionSettings.TerrainImageID = ass.FullID;
155
156 ass.Temporary = true;
157 ass.Local = true;
158 ass.Data = imageData;
159
160 m_AssetService.Store(ass);
161
162 // finally
163 info.TerrainImage = ass.FullID;
164
165 }
166 catch // LEGIT: Catching problems caused by OpenJPEG p/invoke
167 {
168 m_log.Warn("[HGrid]: Failed getting/storing map image, because it is probably already in the cache");
169 }
170 }
171
172 public bool InformRegionOfUser(GridRegion regInfo, AgentCircuitData agentData, GridRegion home, string userServer, string assetServer, string inventoryServer)
173 {
174 string capsPath = agentData.CapsPath;
175 Hashtable loginParams = new Hashtable();
176 loginParams["session_id"] = agentData.SessionID.ToString();
177
178 loginParams["firstname"] = agentData.firstname;
179 loginParams["lastname"] = agentData.lastname;
180
181 loginParams["agent_id"] = agentData.AgentID.ToString();
182 loginParams["circuit_code"] = agentData.circuitcode.ToString();
183 loginParams["startpos_x"] = agentData.startpos.X.ToString();
184 loginParams["startpos_y"] = agentData.startpos.Y.ToString();
185 loginParams["startpos_z"] = agentData.startpos.Z.ToString();
186 loginParams["caps_path"] = capsPath;
187
188 if (home != null)
189 {
190 loginParams["region_uuid"] = home.RegionID.ToString();
191 loginParams["regionhandle"] = home.RegionHandle.ToString();
192 loginParams["home_address"] = home.ExternalHostName;
193 loginParams["home_port"] = home.HttpPort.ToString();
194 loginParams["internal_port"] = home.InternalEndPoint.Port.ToString();
195
196 m_log.Debug(" --------- Home -------");
197 m_log.Debug(" >> " + loginParams["home_address"] + " <<");
198 m_log.Debug(" >> " + loginParams["region_uuid"] + " <<");
199 m_log.Debug(" >> " + loginParams["regionhandle"] + " <<");
200 m_log.Debug(" >> " + loginParams["home_port"] + " <<");
201 m_log.Debug(" --------- ------------ -------");
202 }
203 else
204 m_log.WarnFormat("[HGrid]: Home region not found for {0} {1}", agentData.firstname, agentData.lastname);
205
206 loginParams["userserver_id"] = userServer;
207 loginParams["assetserver_id"] = assetServer;
208 loginParams["inventoryserver_id"] = inventoryServer;
209
210
211 ArrayList SendParams = new ArrayList();
212 SendParams.Add(loginParams);
213
214 // Send
215 string uri = "http://" + regInfo.ExternalHostName + ":" + regInfo.HttpPort + "/";
216 //m_log.Debug("XXX uri: " + uri);
217 XmlRpcRequest request = new XmlRpcRequest("expect_hg_user", SendParams);
218 XmlRpcResponse reply;
219 try
220 {
221 reply = request.Send(uri, 6000);
222 }
223 catch (Exception e)
224 {
225 m_log.Warn("[HGrid]: Failed to notify region about user. Reason: " + e.Message);
226 return false;
227 }
228
229 if (!reply.IsFault)
230 {
231 bool responseSuccess = true;
232 if (reply.Value != null)
233 {
234 Hashtable resp = (Hashtable)reply.Value;
235 if (resp.ContainsKey("success"))
236 {
237 if ((string)resp["success"] == "FALSE")
238 {
239 responseSuccess = false;
240 }
241 }
242 }
243 if (responseSuccess)
244 {
245 m_log.Info("[HGrid]: Successfully informed remote region about user " + agentData.AgentID);
246 return true;
247 }
248 else
249 {
250 m_log.ErrorFormat("[HGrid]: Region responded that it is not available to receive clients");
251 return false;
252 }
253 }
254 else
255 {
256 m_log.ErrorFormat("[HGrid]: XmlRpc request to region failed with message {0}, code {1} ", reply.FaultString, reply.FaultCode);
257 return false;
258 }
259 }
260
261 }
262}