aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Server
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Server')
-rw-r--r--OpenSim/Server/Base/ProtocolVersions.cs56
-rw-r--r--OpenSim/Server/Base/ServerUtils.cs2
-rw-r--r--OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs18
-rw-r--r--OpenSim/Server/Handlers/Grid/HypergridServerConnector.cs124
-rw-r--r--OpenSim/Server/Handlers/Neighbour/NeighbourHandlers.cs10
5 files changed, 192 insertions, 18 deletions
diff --git a/OpenSim/Server/Base/ProtocolVersions.cs b/OpenSim/Server/Base/ProtocolVersions.cs
new file mode 100644
index 0000000..8db5bb6
--- /dev/null
+++ b/OpenSim/Server/Base/ProtocolVersions.cs
@@ -0,0 +1,56 @@
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
28namespace OpenSim.Server.Base
29{
30 public class ProtocolVersions
31 {
32 /// <value>
33 /// This is the external protocol versions. It is separate from the OpenSimulator project version.
34 ///
35 /// These version numbers should be increased by 1 every time a code
36 /// change in the Service.Connectors and Server.Handlers, espectively,
37 /// makes the previous OpenSimulator revision incompatible
38 /// with the new revision.
39 ///
40 /// Changes which are compatible with an older revision (e.g. older revisions experience degraded functionality
41 /// but not outright failure) do not need a version number increment.
42 ///
43 /// Having this version number allows the grid service to reject connections from regions running a version
44 /// of the code that is too old.
45 ///
46 /// </value>
47
48 // The range of acceptable servers for client-side connectors
49 public readonly static int ClientProtocolVersionMin = 0;
50 public readonly static int ClientProtocolVersionMax = 0;
51
52 // The range of acceptable clients in server-side handlers
53 public readonly static int ServerProtocolVersionMin = 0;
54 public readonly static int ServerProtocolVersionMax = 0;
55 }
56}
diff --git a/OpenSim/Server/Base/ServerUtils.cs b/OpenSim/Server/Base/ServerUtils.cs
index 2340645..9beadd8 100644
--- a/OpenSim/Server/Base/ServerUtils.cs
+++ b/OpenSim/Server/Base/ServerUtils.cs
@@ -190,7 +190,7 @@ namespace OpenSim.Server.Base
190 { 190 {
191 string qstring = String.Empty; 191 string qstring = String.Empty;
192 192
193 foreach(KeyValuePair<string, string> kvp in data) 193 foreach (KeyValuePair<string, string> kvp in data)
194 { 194 {
195 string part; 195 string part;
196 if (kvp.Value != String.Empty) 196 if (kvp.Value != String.Empty)
diff --git a/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs b/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs
index b9a4867..e22328d 100644
--- a/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs
+++ b/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs
@@ -118,6 +118,24 @@ namespace OpenSim.Server.Handlers.Grid
118 else 118 else
119 m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to register region"); 119 m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to register region");
120 120
121 int versionNumberMin = 0, versionNumberMax = 0;
122 if (request.ContainsKey("VERSIONMIN"))
123 Int32.TryParse(request["VERSIONMIN"], out versionNumberMin);
124 else
125 m_log.WarnFormat("[GRID HANDLER]: no minimum protocol version in request to register region");
126
127 if (request.ContainsKey("VERSIONMAX"))
128 Int32.TryParse(request["VERSIONMAX"], out versionNumberMax);
129 else
130 m_log.WarnFormat("[GRID HANDLER]: no maximum protocol version in request to register region");
131
132 // Check the protocol version
133 if ((versionNumberMin > ProtocolVersions.ServerProtocolVersionMax && versionNumberMax < ProtocolVersions.ServerProtocolVersionMax))
134 {
135 // Can't do, there is no overlap in the acceptable ranges
136 return FailureResult();
137 }
138
121 Dictionary<string, object> rinfoData = new Dictionary<string, object>(); 139 Dictionary<string, object> rinfoData = new Dictionary<string, object>();
122 foreach (KeyValuePair<string, string> kvp in request) 140 foreach (KeyValuePair<string, string> kvp in request)
123 rinfoData[kvp.Key] = kvp.Value; 141 rinfoData[kvp.Key] = kvp.Value;
diff --git a/OpenSim/Server/Handlers/Grid/HypergridServerConnector.cs b/OpenSim/Server/Handlers/Grid/HypergridServerConnector.cs
index e226759..115ac29 100644
--- a/OpenSim/Server/Handlers/Grid/HypergridServerConnector.cs
+++ b/OpenSim/Server/Handlers/Grid/HypergridServerConnector.cs
@@ -36,7 +36,9 @@ using OpenSim.Server.Base;
36using OpenSim.Services.Interfaces; 36using OpenSim.Services.Interfaces;
37using OpenSim.Framework.Servers.HttpServer; 37using OpenSim.Framework.Servers.HttpServer;
38using OpenSim.Server.Handlers.Base; 38using OpenSim.Server.Handlers.Base;
39using GridRegion = OpenSim.Services.Interfaces.GridRegion;
39 40
41using OpenMetaverse;
40using log4net; 42using log4net;
41using Nwc.XmlRpc; 43using Nwc.XmlRpc;
42 44
@@ -48,12 +50,26 @@ namespace OpenSim.Server.Handlers.Grid
48 LogManager.GetLogger( 50 LogManager.GetLogger(
49 MethodBase.GetCurrentMethod().DeclaringType); 51 MethodBase.GetCurrentMethod().DeclaringType);
50 52
51 private List<SimpleRegionInfo> m_RegionsOnSim = new List<SimpleRegionInfo>(); 53 private List<GridRegion> m_RegionsOnSim = new List<GridRegion>();
54 private IHyperlinkService m_HyperlinkService;
52 55
53 public HypergridServiceInConnector(IConfigSource config, IHttpServer server) : 56 public HypergridServiceInConnector(IConfigSource config, IHttpServer server, IHyperlinkService hyperService) :
54 base(config, server, String.Empty) 57 base(config, server, String.Empty)
55 { 58 {
56 server.AddXmlRPCHandler("linkk_region", LinkRegionRequest, false); 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);
57 } 73 }
58 74
59 /// <summary> 75 /// <summary>
@@ -70,8 +86,8 @@ namespace OpenSim.Server.Handlers.Grid
70 86
71 m_log.DebugFormat("[HGrid]: Hyperlink request"); 87 m_log.DebugFormat("[HGrid]: Hyperlink request");
72 88
73 SimpleRegionInfo regInfo = null; 89 GridRegion regInfo = null;
74 foreach (SimpleRegionInfo r in m_RegionsOnSim) 90 foreach (GridRegion r in m_RegionsOnSim)
75 { 91 {
76 if ((r.RegionName != null) && (name != null) && (r.RegionName.ToLower() == name.ToLower())) 92 if ((r.RegionName != null) && (name != null) && (r.RegionName.ToLower() == name.ToLower()))
77 { 93 {
@@ -85,9 +101,9 @@ namespace OpenSim.Server.Handlers.Grid
85 101
86 Hashtable hash = new Hashtable(); 102 Hashtable hash = new Hashtable();
87 hash["uuid"] = regInfo.RegionID.ToString(); 103 hash["uuid"] = regInfo.RegionID.ToString();
104 m_log.Debug(">> Here " + regInfo.RegionID);
88 hash["handle"] = regInfo.RegionHandle.ToString(); 105 hash["handle"] = regInfo.RegionHandle.ToString();
89 //m_log.Debug(">> Here " + regInfo.RegionHandle); 106 hash["region_image"] = regInfo.TerrainImage.ToString();
90 //hash["region_image"] = regInfo.RegionSettings.TerrainImageID.ToString();
91 hash["region_name"] = regInfo.RegionName; 107 hash["region_name"] = regInfo.RegionName;
92 hash["internal_port"] = regInfo.InternalEndPoint.Port.ToString(); 108 hash["internal_port"] = regInfo.InternalEndPoint.Port.ToString();
93 //m_log.Debug(">> Here: " + regInfo.InternalEndPoint.Port); 109 //m_log.Debug(">> Here: " + regInfo.InternalEndPoint.Port);
@@ -98,15 +114,95 @@ namespace OpenSim.Server.Handlers.Grid
98 return response; 114 return response;
99 } 115 }
100 116
101 public void AddRegion(SimpleRegionInfo rinfo) 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)
102 { 127 {
103 m_RegionsOnSim.Add(rinfo); 128 Hashtable requestData = (Hashtable)request.Params[0];
104 } 129 ForeignUserProfileData userData = new ForeignUserProfileData();
105 130
106 public void RemoveRegion(SimpleRegionInfo rinfo) 131 userData.FirstName = (string)requestData["firstname"];
107 { 132 userData.SurName = (string)requestData["lastname"];
108 if (m_RegionsOnSim.Contains(rinfo)) 133 userData.ID = new UUID((string)requestData["agent_id"]);
109 m_RegionsOnSim.Remove(rinfo); 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;
110 } 205 }
206
111 } 207 }
112} 208}
diff --git a/OpenSim/Server/Handlers/Neighbour/NeighbourHandlers.cs b/OpenSim/Server/Handlers/Neighbour/NeighbourHandlers.cs
index c0933a8..d6ef22e 100644
--- a/OpenSim/Server/Handlers/Neighbour/NeighbourHandlers.cs
+++ b/OpenSim/Server/Handlers/Neighbour/NeighbourHandlers.cs
@@ -36,6 +36,7 @@ using OpenSim.Server.Handlers.Base;
36using OpenSim.Services.Interfaces; 36using OpenSim.Services.Interfaces;
37using OpenSim.Framework; 37using OpenSim.Framework;
38using OpenSim.Framework.Servers.HttpServer; 38using OpenSim.Framework.Servers.HttpServer;
39using GridRegion = OpenSim.Services.Interfaces.GridRegion;
39 40
40using OpenMetaverse; 41using OpenMetaverse;
41using OpenMetaverse.StructuredData; 42using OpenMetaverse.StructuredData;
@@ -148,11 +149,14 @@ namespace OpenSim.Server.Handlers.Neighbour
148 } 149 }
149 150
150 // Finally! 151 // Finally!
151 bool success = m_NeighbourService.HelloNeighbour(regionhandle, aRegion); 152 GridRegion thisRegion = m_NeighbourService.HelloNeighbour(regionhandle, aRegion);
152 153
153 OSDMap resp = new OSDMap(1); 154 OSDMap resp = new OSDMap(1);
154 155
155 resp["success"] = OSD.FromBoolean(success); 156 if (thisRegion != null)
157 resp["success"] = OSD.FromBoolean(true);
158 else
159 resp["success"] = OSD.FromBoolean(false);
156 160
157 httpResponse.StatusCode = (int)HttpStatusCode.OK; 161 httpResponse.StatusCode = (int)HttpStatusCode.OK;
158 162