aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Server
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Server')
-rw-r--r--OpenSim/Server/Handlers/Grid/HypergridServerConnector.cs111
1 files changed, 103 insertions, 8 deletions
diff --git a/OpenSim/Server/Handlers/Grid/HypergridServerConnector.cs b/OpenSim/Server/Handlers/Grid/HypergridServerConnector.cs
index d2e791b..c47f652 100644
--- a/OpenSim/Server/Handlers/Grid/HypergridServerConnector.cs
+++ b/OpenSim/Server/Handlers/Grid/HypergridServerConnector.cs
@@ -38,6 +38,7 @@ using OpenSim.Framework.Servers.HttpServer;
38using OpenSim.Server.Handlers.Base; 38using OpenSim.Server.Handlers.Base;
39using GridRegion = OpenSim.Services.Interfaces.GridRegion; 39using GridRegion = OpenSim.Services.Interfaces.GridRegion;
40 40
41using OpenMetaverse;
41using log4net; 42using log4net;
42using Nwc.XmlRpc; 43using Nwc.XmlRpc;
43 44
@@ -50,11 +51,25 @@ namespace OpenSim.Server.Handlers.Grid
50 MethodBase.GetCurrentMethod().DeclaringType); 51 MethodBase.GetCurrentMethod().DeclaringType);
51 52
52 private List<GridRegion> m_RegionsOnSim = new List<GridRegion>(); 53 private List<GridRegion> m_RegionsOnSim = new List<GridRegion>();
54 private IHyperlinkService m_HyperlinkService;
53 55
54 public HypergridServiceInConnector(IConfigSource config, IHttpServer server) : 56 public HypergridServiceInConnector(IConfigSource config, IHttpServer server, IHyperlinkService hyperService) :
55 base(config, server) 57 base(config, server)
56 { 58 {
59 m_HyperlinkService = hyperService;
57 server.AddXmlRPCHandler("link_region", LinkRegionRequest, false); 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);
58 } 73 }
59 74
60 /// <summary> 75 /// <summary>
@@ -99,15 +114,95 @@ namespace OpenSim.Server.Handlers.Grid
99 return response; 114 return response;
100 } 115 }
101 116
102 public void AddRegion(GridRegion 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)
103 { 127 {
104 m_RegionsOnSim.Add(rinfo); 128 Hashtable requestData = (Hashtable)request.Params[0];
105 } 129 ForeignUserProfileData userData = new ForeignUserProfileData();
106 130
107 public void RemoveRegion(GridRegion rinfo) 131 userData.FirstName = (string)requestData["firstname"];
108 { 132 userData.SurName = (string)requestData["lastname"];
109 if (m_RegionsOnSim.Contains(rinfo)) 133 userData.ID = new UUID((string)requestData["agent_id"]);
110 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;
111 } 205 }
206
112 } 207 }
113} 208}