diff options
author | Melanie | 2010-08-20 08:36:54 +0100 |
---|---|---|
committer | Melanie | 2010-08-20 08:36:54 +0100 |
commit | 82abaadd556ac6215474886daf9f9e943c64b685 (patch) | |
tree | 5ee8683e183d5e9263d04d3e610457b94ef9d378 | |
parent | Add some maptile options, change maptile generation from OpenSimBase to Scene (diff) | |
parent | Merge branch 'master' of ssh://diva@opensimulator.org/var/git/opensim (diff) | |
download | opensim-SC-82abaadd556ac6215474886daf9f9e943c64b685.zip opensim-SC-82abaadd556ac6215474886daf9f9e943c64b685.tar.gz opensim-SC-82abaadd556ac6215474886daf9f9e943c64b685.tar.bz2 opensim-SC-82abaadd556ac6215474886daf9f9e943c64b685.tar.xz |
Merge branch 'master' of melanie@opensimulator.org:/var/git/opensim
Diffstat (limited to '')
11 files changed, 213 insertions, 164 deletions
diff --git a/OpenSim/Framework/Constants.cs b/OpenSim/Framework/Constants.cs index 5757061..1b1aaf2 100644 --- a/OpenSim/Framework/Constants.cs +++ b/OpenSim/Framework/Constants.cs | |||
@@ -83,7 +83,9 @@ namespace OpenSim.Framework | |||
83 | /// <summary>Finished, Sim Changed</summary> | 83 | /// <summary>Finished, Sim Changed</summary> |
84 | FinishedViaNewSim = 1 << 28, | 84 | FinishedViaNewSim = 1 << 28, |
85 | /// <summary>Finished, Same Sim</summary> | 85 | /// <summary>Finished, Same Sim</summary> |
86 | FinishedViaSameSim = 1 << 29 | 86 | FinishedViaSameSim = 1 << 29, |
87 | /// <summary>Agent coming into the grid from another grid</summary> | ||
88 | ViaHGLogin = 1 << 30 | ||
87 | } | 89 | } |
88 | 90 | ||
89 | } | 91 | } |
diff --git a/OpenSim/Framework/NetworkUtil.cs b/OpenSim/Framework/NetworkUtil.cs index 831ff70..2e94b0d 100644 --- a/OpenSim/Framework/NetworkUtil.cs +++ b/OpenSim/Framework/NetworkUtil.cs | |||
@@ -181,18 +181,10 @@ namespace OpenSim.Framework | |||
181 | throw new ArgumentException("[NetworkUtil] Unable to resolve defaultHostname to an IPv4 address for an IPv4 client"); | 181 | throw new ArgumentException("[NetworkUtil] Unable to resolve defaultHostname to an IPv4 address for an IPv4 client"); |
182 | } | 182 | } |
183 | 183 | ||
184 | static IPAddress externalIPAddress; | ||
185 | |||
186 | static NetworkUtil() | 184 | static NetworkUtil() |
187 | { | 185 | { |
188 | try | 186 | try |
189 | { | 187 | { |
190 | externalIPAddress = GetExternalIP(); | ||
191 | } | ||
192 | catch { /* ignore */ } | ||
193 | |||
194 | try | ||
195 | { | ||
196 | foreach (NetworkInterface ni in NetworkInterface.GetAllNetworkInterfaces()) | 188 | foreach (NetworkInterface ni in NetworkInterface.GetAllNetworkInterfaces()) |
197 | { | 189 | { |
198 | foreach (UnicastIPAddressInformation address in ni.GetIPProperties().UnicastAddresses) | 190 | foreach (UnicastIPAddressInformation address in ni.GetIPProperties().UnicastAddresses) |
@@ -254,79 +246,5 @@ namespace OpenSim.Framework | |||
254 | return defaultHostname; | 246 | return defaultHostname; |
255 | } | 247 | } |
256 | 248 | ||
257 | public static IPAddress GetExternalIPOf(IPAddress user) | ||
258 | { | ||
259 | if (externalIPAddress == null) | ||
260 | return user; | ||
261 | |||
262 | if (user.ToString() == "127.0.0.1") | ||
263 | { | ||
264 | m_log.Info("[NetworkUtil] 127.0.0.1 user detected, sending '" + externalIPAddress + "' instead of '" + user + "'"); | ||
265 | return externalIPAddress; | ||
266 | } | ||
267 | // Check if we're accessing localhost. | ||
268 | foreach (IPAddress host in Dns.GetHostAddresses(Dns.GetHostName())) | ||
269 | { | ||
270 | if (host.Equals(user) && host.AddressFamily == AddressFamily.InterNetwork) | ||
271 | { | ||
272 | m_log.Info("[NetworkUtil] Localhost user detected, sending '" + externalIPAddress + "' instead of '" + user + "'"); | ||
273 | return externalIPAddress; | ||
274 | } | ||
275 | } | ||
276 | |||
277 | // Check for same LAN segment | ||
278 | foreach (KeyValuePair<IPAddress, IPAddress> subnet in m_subnets) | ||
279 | { | ||
280 | byte[] subnetBytes = subnet.Value.GetAddressBytes(); | ||
281 | byte[] localBytes = subnet.Key.GetAddressBytes(); | ||
282 | byte[] destBytes = user.GetAddressBytes(); | ||
283 | |||
284 | if (subnetBytes.Length != destBytes.Length || subnetBytes.Length != localBytes.Length) | ||
285 | return user; | ||
286 | |||
287 | bool valid = true; | ||
288 | |||
289 | for (int i = 0; i < subnetBytes.Length; i++) | ||
290 | { | ||
291 | if ((localBytes[i] & subnetBytes[i]) != (destBytes[i] & subnetBytes[i])) | ||
292 | { | ||
293 | valid = false; | ||
294 | break; | ||
295 | } | ||
296 | } | ||
297 | |||
298 | if (subnet.Key.AddressFamily != AddressFamily.InterNetwork) | ||
299 | valid = false; | ||
300 | |||
301 | if (valid) | ||
302 | { | ||
303 | m_log.Info("[NetworkUtil] Local LAN user detected, sending '" + externalIPAddress + "' instead of '" + user + "'"); | ||
304 | return externalIPAddress; | ||
305 | } | ||
306 | } | ||
307 | |||
308 | // Otherwise, return user address | ||
309 | return user; | ||
310 | } | ||
311 | |||
312 | private static IPAddress GetExternalIP() | ||
313 | { | ||
314 | string whatIsMyIp = "http://www.whatismyip.com/automation/n09230945.asp"; | ||
315 | WebClient wc = new WebClient(); | ||
316 | UTF8Encoding utf8 = new UTF8Encoding(); | ||
317 | string requestHtml = ""; | ||
318 | try | ||
319 | { | ||
320 | requestHtml = utf8.GetString(wc.DownloadData(whatIsMyIp)); | ||
321 | } | ||
322 | catch (WebException we) | ||
323 | { | ||
324 | m_log.Info("[NetworkUtil]: Exception in GetExternalIP: " + we.ToString()); | ||
325 | return null; | ||
326 | } | ||
327 | |||
328 | IPAddress externalIp = IPAddress.Parse(requestHtml); | ||
329 | return externalIp; | ||
330 | } | ||
331 | } | 249 | } |
332 | } | 250 | } |
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 2890ecd..2f862ea 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -2538,26 +2538,26 @@ namespace OpenSim.Region.Framework.Scenes | |||
2538 | { | 2538 | { |
2539 | AgentCircuitData aCircuit = m_authenticateHandler.GetAgentCircuitData(client.CircuitCode); | 2539 | AgentCircuitData aCircuit = m_authenticateHandler.GetAgentCircuitData(client.CircuitCode); |
2540 | 2540 | ||
2541 | // Do the verification here | 2541 | //// Do the verification here -- No, really don't do this here. This is UDP address, let it go. |
2542 | System.Net.IPEndPoint ep = (System.Net.IPEndPoint)client.GetClientEP(); | 2542 | //System.Net.IPEndPoint ep = (System.Net.IPEndPoint)client.GetClientEP(); |
2543 | if (aCircuit != null) | 2543 | //if (aCircuit != null) |
2544 | { | 2544 | //{ |
2545 | if (!VerifyClient(aCircuit, ep, out vialogin)) | 2545 | // if (!VerifyClient(aCircuit, ep, out vialogin)) |
2546 | { | 2546 | // { |
2547 | // uh-oh, this is fishy | 2547 | // // uh-oh, this is fishy |
2548 | m_log.WarnFormat("[SCENE]: Agent {0} with session {1} connecting with unidentified end point {2}. Refusing service.", | 2548 | // m_log.WarnFormat("[SCENE]: Agent {0} with session {1} connecting with unidentified end point {2}. Refusing service.", |
2549 | client.AgentId, client.SessionId, ep.ToString()); | 2549 | // client.AgentId, client.SessionId, ep.ToString()); |
2550 | try | 2550 | // try |
2551 | { | 2551 | // { |
2552 | client.Close(); | 2552 | // client.Close(); |
2553 | } | 2553 | // } |
2554 | catch (Exception e) | 2554 | // catch (Exception e) |
2555 | { | 2555 | // { |
2556 | m_log.DebugFormat("[SCENE]: Exception while closing aborted client: {0}", e.StackTrace); | 2556 | // m_log.DebugFormat("[SCENE]: Exception while closing aborted client: {0}", e.StackTrace); |
2557 | } | 2557 | // } |
2558 | return; | 2558 | // return; |
2559 | } | 2559 | // } |
2560 | } | 2560 | //} |
2561 | 2561 | ||
2562 | m_log.Debug("[SCENE]: Adding new agent " + client.Name + " to scene " + RegionInfo.RegionName); | 2562 | m_log.Debug("[SCENE]: Adding new agent " + client.Name + " to scene " + RegionInfo.RegionName); |
2563 | 2563 | ||
@@ -2586,16 +2586,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
2586 | vialogin = false; | 2586 | vialogin = false; |
2587 | 2587 | ||
2588 | // Do the verification here | 2588 | // Do the verification here |
2589 | if ((aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0) | 2589 | if ((aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0) |
2590 | { | 2590 | { |
2591 | m_log.DebugFormat("[SCENE]: Incoming client {0} {1} in region {2} via Login", aCircuit.firstname, aCircuit.lastname, RegionInfo.RegionName); | 2591 | m_log.DebugFormat("[SCENE]: Incoming client {0} {1} in region {2} via HG login", aCircuit.firstname, aCircuit.lastname, RegionInfo.RegionName); |
2592 | vialogin = true; | 2592 | vialogin = true; |
2593 | IUserAgentVerificationModule userVerification = RequestModuleInterface<IUserAgentVerificationModule>(); | 2593 | IUserAgentVerificationModule userVerification = RequestModuleInterface<IUserAgentVerificationModule>(); |
2594 | if (userVerification != null && ep != null) | 2594 | if (userVerification != null && ep != null) |
2595 | { | 2595 | { |
2596 | System.Net.IPAddress addr = NetworkUtil.GetExternalIPOf(ep.Address); | 2596 | if (!userVerification.VerifyClient(aCircuit, ep.Address.ToString())) |
2597 | |||
2598 | if (!userVerification.VerifyClient(aCircuit, /*ep.Address.ToString() */ addr.ToString())) | ||
2599 | { | 2597 | { |
2600 | // uh-oh, this is fishy | 2598 | // uh-oh, this is fishy |
2601 | m_log.DebugFormat("[SCENE]: User Client Verification for {0} {1} in {2} returned false", aCircuit.firstname, aCircuit.lastname, RegionInfo.RegionName); | 2599 | m_log.DebugFormat("[SCENE]: User Client Verification for {0} {1} in {2} returned false", aCircuit.firstname, aCircuit.lastname, RegionInfo.RegionName); |
@@ -2606,6 +2604,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
2606 | } | 2604 | } |
2607 | } | 2605 | } |
2608 | 2606 | ||
2607 | else if ((aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0) | ||
2608 | m_log.DebugFormat("[SCENE]: Incoming client {0} {1} in region {2} via regular login. Client IP verification not performed.", | ||
2609 | aCircuit.firstname, aCircuit.lastname, RegionInfo.RegionName); | ||
2610 | |||
2609 | return true; | 2611 | return true; |
2610 | } | 2612 | } |
2611 | 2613 | ||
diff --git a/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs b/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs index d261678..392927a 100644 --- a/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs +++ b/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs | |||
@@ -178,6 +178,8 @@ namespace OpenSim.Server.Handlers.Simulation | |||
178 | 178 | ||
179 | resp["reason"] = OSD.FromString(reason); | 179 | resp["reason"] = OSD.FromString(reason); |
180 | resp["success"] = OSD.FromBoolean(result); | 180 | resp["success"] = OSD.FromBoolean(result); |
181 | // Let's also send out the IP address of the caller back to the caller (HG 1.5) | ||
182 | resp["your_ip"] = OSD.FromString(GetCallerIP(request)); | ||
181 | 183 | ||
182 | // TODO: add reason if not String.Empty? | 184 | // TODO: add reason if not String.Empty? |
183 | responsedata["int_response_code"] = HttpStatusCode.OK; | 185 | responsedata["int_response_code"] = HttpStatusCode.OK; |
@@ -352,6 +354,24 @@ namespace OpenSim.Server.Handlers.Simulation | |||
352 | { | 354 | { |
353 | m_SimulationService.ReleaseAgent(regionID, id, ""); | 355 | m_SimulationService.ReleaseAgent(regionID, id, ""); |
354 | } | 356 | } |
357 | |||
358 | private string GetCallerIP(Hashtable req) | ||
359 | { | ||
360 | if (req.ContainsKey("headers")) | ||
361 | { | ||
362 | try | ||
363 | { | ||
364 | Hashtable headers = (Hashtable)req["headers"]; | ||
365 | if (headers.ContainsKey("remote_addr") && headers["remote_addr"] != null) | ||
366 | return headers["remote_addr"].ToString(); | ||
367 | } | ||
368 | catch (Exception e) | ||
369 | { | ||
370 | m_log.WarnFormat("[AGENT HANDLER]: exception in GetCallerIP: {0}", e.Message); | ||
371 | } | ||
372 | } | ||
373 | return string.Empty; | ||
374 | } | ||
355 | } | 375 | } |
356 | 376 | ||
357 | } | 377 | } |
diff --git a/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs index c426bba..291dd73 100644 --- a/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs +++ b/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs | |||
@@ -38,6 +38,7 @@ using GridRegion = OpenSim.Services.Interfaces.GridRegion; | |||
38 | 38 | ||
39 | using OpenMetaverse; | 39 | using OpenMetaverse; |
40 | using OpenMetaverse.Imaging; | 40 | using OpenMetaverse.Imaging; |
41 | using OpenMetaverse.StructuredData; | ||
41 | using Nwc.XmlRpc; | 42 | using Nwc.XmlRpc; |
42 | using log4net; | 43 | using log4net; |
43 | 44 | ||
@@ -268,5 +269,48 @@ namespace OpenSim.Services.Connectors.Hypergrid | |||
268 | return null; | 269 | return null; |
269 | } | 270 | } |
270 | 271 | ||
272 | public bool CreateAgent(GridRegion destination, AgentCircuitData aCircuit, uint flags, out string myipaddress, out string reason) | ||
273 | { | ||
274 | HttpWebRequest AgentCreateRequest = null; | ||
275 | myipaddress = String.Empty; | ||
276 | reason = String.Empty; | ||
277 | |||
278 | if (SendRequest(destination, aCircuit, flags, out reason, out AgentCreateRequest)) | ||
279 | { | ||
280 | string response = GetResponse(AgentCreateRequest, out reason); | ||
281 | bool success = true; | ||
282 | UnpackResponse(response, out success, out reason, out myipaddress); | ||
283 | return success; | ||
284 | } | ||
285 | |||
286 | return false; | ||
287 | } | ||
288 | |||
289 | protected void UnpackResponse(string response, out bool result, out string reason, out string ipaddress) | ||
290 | { | ||
291 | result = true; | ||
292 | reason = string.Empty; | ||
293 | ipaddress = string.Empty; | ||
294 | |||
295 | if (!String.IsNullOrEmpty(response)) | ||
296 | { | ||
297 | try | ||
298 | { | ||
299 | // we assume we got an OSDMap back | ||
300 | OSDMap r = Util.GetOSDMap(response); | ||
301 | result = r["success"].AsBoolean(); | ||
302 | reason = r["reason"].AsString(); | ||
303 | ipaddress = r["your_ip"].AsString(); | ||
304 | } | ||
305 | catch (NullReferenceException e) | ||
306 | { | ||
307 | m_log.InfoFormat("[GATEKEEPER SERVICE CONNECTOR]: exception on UnpackResponse of DoCreateChildAgentCall {0}", e.Message); | ||
308 | reason = "Internal error"; | ||
309 | result = false; | ||
310 | } | ||
311 | } | ||
312 | } | ||
313 | |||
314 | |||
271 | } | 315 | } |
272 | } | 316 | } |
diff --git a/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs index 69dff3c..c1e5949 100644 --- a/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs +++ b/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs | |||
@@ -73,6 +73,13 @@ namespace OpenSim.Services.Connectors.Hypergrid | |||
73 | { | 73 | { |
74 | } | 74 | } |
75 | 75 | ||
76 | public bool LoginAgentToGrid(AgentCircuitData agent, GridRegion gatekeeper, GridRegion finalDestination, IPEndPoint ipaddress, out string reason) | ||
77 | { | ||
78 | // not available over remote calls | ||
79 | reason = "Method not available over remote calls"; | ||
80 | return false; | ||
81 | } | ||
82 | |||
76 | public bool LoginAgentToGrid(AgentCircuitData aCircuit, GridRegion gatekeeper, GridRegion destination, out string reason) | 83 | public bool LoginAgentToGrid(AgentCircuitData aCircuit, GridRegion gatekeeper, GridRegion destination, out string reason) |
77 | { | 84 | { |
78 | reason = String.Empty; | 85 | reason = String.Empty; |
diff --git a/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs index 6244565..2b96b96 100644 --- a/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs +++ b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs | |||
@@ -77,8 +77,26 @@ namespace OpenSim.Services.Connectors.Simulation | |||
77 | 77 | ||
78 | public bool CreateAgent(GridRegion destination, AgentCircuitData aCircuit, uint flags, out string reason) | 78 | public bool CreateAgent(GridRegion destination, AgentCircuitData aCircuit, uint flags, out string reason) |
79 | { | 79 | { |
80 | HttpWebRequest AgentCreateRequest = null; | ||
80 | reason = String.Empty; | 81 | reason = String.Empty; |
81 | 82 | ||
83 | if (SendRequest(destination, aCircuit, flags, out reason, out AgentCreateRequest)) | ||
84 | { | ||
85 | string response = GetResponse(AgentCreateRequest, out reason); | ||
86 | bool success = true; | ||
87 | UnpackResponse(response, out success, out reason); | ||
88 | return success; | ||
89 | } | ||
90 | |||
91 | return false; | ||
92 | } | ||
93 | |||
94 | |||
95 | protected bool SendRequest(GridRegion destination, AgentCircuitData aCircuit, uint flags, out string reason, out HttpWebRequest AgentCreateRequest) | ||
96 | { | ||
97 | reason = String.Empty; | ||
98 | AgentCreateRequest = null; | ||
99 | |||
82 | if (destination == null) | 100 | if (destination == null) |
83 | { | 101 | { |
84 | reason = "Destination is null"; | 102 | reason = "Destination is null"; |
@@ -101,7 +119,7 @@ namespace OpenSim.Services.Connectors.Simulation | |||
101 | 119 | ||
102 | //Console.WriteLine(" >>> DoCreateChildAgentCall <<< " + uri); | 120 | //Console.WriteLine(" >>> DoCreateChildAgentCall <<< " + uri); |
103 | 121 | ||
104 | HttpWebRequest AgentCreateRequest = (HttpWebRequest)WebRequest.Create(uri); | 122 | AgentCreateRequest = (HttpWebRequest)WebRequest.Create(uri); |
105 | AgentCreateRequest.Method = "POST"; | 123 | AgentCreateRequest.Method = "POST"; |
106 | AgentCreateRequest.ContentType = "application/json"; | 124 | AgentCreateRequest.ContentType = "application/json"; |
107 | AgentCreateRequest.Timeout = 10000; | 125 | AgentCreateRequest.Timeout = 10000; |
@@ -134,7 +152,7 @@ namespace OpenSim.Services.Connectors.Simulation | |||
134 | AgentCreateRequest.ContentLength = buffer.Length; //Count bytes to send | 152 | AgentCreateRequest.ContentLength = buffer.Length; //Count bytes to send |
135 | os = AgentCreateRequest.GetRequestStream(); | 153 | os = AgentCreateRequest.GetRequestStream(); |
136 | os.Write(buffer, 0, strBuffer.Length); //Send it | 154 | os.Write(buffer, 0, strBuffer.Length); //Send it |
137 | m_log.InfoFormat("[REMOTE SIMULATION CONNECTOR]: Posted CreateAgent request to remote sim {0}, region {1}, x={2} y={3}", | 155 | m_log.InfoFormat("[REMOTE SIMULATION CONNECTOR]: Posted CreateAgent request to remote sim {0}, region {1}, x={2} y={3}", |
138 | uri, destination.RegionName, destination.RegionLocX, destination.RegionLocY); | 156 | uri, destination.RegionName, destination.RegionLocX, destination.RegionLocY); |
139 | } | 157 | } |
140 | //catch (WebException ex) | 158 | //catch (WebException ex) |
@@ -150,11 +168,18 @@ namespace OpenSim.Services.Connectors.Simulation | |||
150 | os.Close(); | 168 | os.Close(); |
151 | } | 169 | } |
152 | 170 | ||
171 | return true; | ||
172 | } | ||
173 | |||
174 | protected string GetResponse(HttpWebRequest AgentCreateRequest, out string reason) | ||
175 | { | ||
153 | // Let's wait for the response | 176 | // Let's wait for the response |
154 | //m_log.Info("[REMOTE SIMULATION CONNECTOR]: Waiting for a reply after DoCreateChildAgentCall"); | 177 | //m_log.Info("[REMOTE SIMULATION CONNECTOR]: Waiting for a reply after DoCreateChildAgentCall"); |
178 | reason = string.Empty; | ||
155 | 179 | ||
156 | WebResponse webResponse = null; | 180 | WebResponse webResponse = null; |
157 | StreamReader sr = null; | 181 | StreamReader sr = null; |
182 | string response = string.Empty; | ||
158 | try | 183 | try |
159 | { | 184 | { |
160 | webResponse = AgentCreateRequest.GetResponse(); | 185 | webResponse = AgentCreateRequest.GetResponse(); |
@@ -166,37 +191,15 @@ namespace OpenSim.Services.Connectors.Simulation | |||
166 | { | 191 | { |
167 | 192 | ||
168 | sr = new StreamReader(webResponse.GetResponseStream()); | 193 | sr = new StreamReader(webResponse.GetResponseStream()); |
169 | string response = sr.ReadToEnd().Trim(); | 194 | response = sr.ReadToEnd().Trim(); |
170 | m_log.InfoFormat("[REMOTE SIMULATION CONNECTOR]: DoCreateChildAgentCall reply was {0} ", response); | 195 | m_log.InfoFormat("[REMOTE SIMULATION CONNECTOR]: DoCreateChildAgentCall reply was {0} ", response); |
171 | |||
172 | if (!String.IsNullOrEmpty(response)) | ||
173 | { | ||
174 | try | ||
175 | { | ||
176 | // we assume we got an OSDMap back | ||
177 | OSDMap r = Util.GetOSDMap(response); | ||
178 | bool success = r["success"].AsBoolean(); | ||
179 | reason = r["reason"].AsString(); | ||
180 | return success; | ||
181 | } | ||
182 | catch (NullReferenceException e) | ||
183 | { | ||
184 | m_log.InfoFormat("[REMOTE SIMULATION CONNECTOR]: exception on reply of DoCreateChildAgentCall {0}", e.Message); | ||
185 | |||
186 | // check for old style response | ||
187 | if (response.ToLower().StartsWith("true")) | ||
188 | return true; | ||
189 | |||
190 | return false; | ||
191 | } | ||
192 | } | ||
193 | } | 196 | } |
194 | } | 197 | } |
195 | catch (WebException ex) | 198 | catch (WebException ex) |
196 | { | 199 | { |
197 | m_log.InfoFormat("[REMOTE SIMULATION CONNECTOR]: exception on reply of DoCreateChildAgentCall {0}", ex.Message); | 200 | m_log.InfoFormat("[REMOTE SIMULATION CONNECTOR]: exception on reply of DoCreateChildAgentCall {0}", ex.Message); |
198 | reason = "Destination did not reply"; | 201 | reason = "Destination did not reply"; |
199 | return false; | 202 | return string.Empty; |
200 | } | 203 | } |
201 | finally | 204 | finally |
202 | { | 205 | { |
@@ -204,7 +207,33 @@ namespace OpenSim.Services.Connectors.Simulation | |||
204 | sr.Close(); | 207 | sr.Close(); |
205 | } | 208 | } |
206 | 209 | ||
207 | return true; | 210 | return response; |
211 | } | ||
212 | |||
213 | protected void UnpackResponse(string response, out bool result, out string reason) | ||
214 | { | ||
215 | result = true; | ||
216 | reason = string.Empty; | ||
217 | if (!String.IsNullOrEmpty(response)) | ||
218 | { | ||
219 | try | ||
220 | { | ||
221 | // we assume we got an OSDMap back | ||
222 | OSDMap r = Util.GetOSDMap(response); | ||
223 | result = r["success"].AsBoolean(); | ||
224 | reason = r["reason"].AsString(); | ||
225 | } | ||
226 | catch (NullReferenceException e) | ||
227 | { | ||
228 | m_log.InfoFormat("[REMOTE SIMULATION CONNECTOR]: exception on reply of DoCreateChildAgentCall {0}", e.Message); | ||
229 | |||
230 | // check for old style response | ||
231 | if (response.ToLower().StartsWith("true")) | ||
232 | result = true; | ||
233 | |||
234 | result = false; | ||
235 | } | ||
236 | } | ||
208 | } | 237 | } |
209 | 238 | ||
210 | protected virtual OSDMap PackCreateAgentArguments(AgentCircuitData aCircuit, GridRegion destination, uint flags) | 239 | protected virtual OSDMap PackCreateAgentArguments(AgentCircuitData aCircuit, GridRegion destination, uint flags) |
diff --git a/OpenSim/Services/HypergridService/GatekeeperService.cs b/OpenSim/Services/HypergridService/GatekeeperService.cs index 6f041da..3f5c4f1 100644 --- a/OpenSim/Services/HypergridService/GatekeeperService.cs +++ b/OpenSim/Services/HypergridService/GatekeeperService.cs | |||
@@ -225,17 +225,23 @@ namespace OpenSim.Services.HypergridService | |||
225 | 225 | ||
226 | // May want to authorize | 226 | // May want to authorize |
227 | 227 | ||
228 | bool isFirstLogin = false; | ||
228 | // | 229 | // |
229 | // Login the presence | 230 | // Login the presence, if it's not there yet (by the login service) |
230 | // | 231 | // |
231 | if (!m_PresenceService.LoginAgent(aCircuit.AgentID.ToString(), aCircuit.SessionID, aCircuit.SecureSessionID)) | 232 | PresenceInfo presence = m_PresenceService.GetAgent(aCircuit.SessionID); |
232 | { | 233 | if (presence != null) // it has been placed there by the login service |
233 | reason = "Unable to login presence"; | 234 | isFirstLogin = true; |
234 | m_log.InfoFormat("[GATEKEEPER SERVICE]: Presence login failed for foreign agent {0} {1}. Refusing service.", | 235 | |
235 | aCircuit.firstname, aCircuit.lastname); | 236 | else |
236 | return false; | 237 | if (!m_PresenceService.LoginAgent(aCircuit.AgentID.ToString(), aCircuit.SessionID, aCircuit.SecureSessionID)) |
237 | } | 238 | { |
238 | m_log.DebugFormat("[GATEKEEPER SERVICE]: Login presence ok"); | 239 | reason = "Unable to login presence"; |
240 | m_log.InfoFormat("[GATEKEEPER SERVICE]: Presence login failed for foreign agent {0} {1}. Refusing service.", | ||
241 | aCircuit.firstname, aCircuit.lastname); | ||
242 | return false; | ||
243 | } | ||
244 | m_log.DebugFormat("[GATEKEEPER SERVICE]: Login presence ok"); | ||
239 | 245 | ||
240 | // | 246 | // |
241 | // Get the region | 247 | // Get the region |
@@ -274,7 +280,9 @@ namespace OpenSim.Services.HypergridService | |||
274 | // | 280 | // |
275 | // Finally launch the agent at the destination | 281 | // Finally launch the agent at the destination |
276 | // | 282 | // |
277 | return m_SimulationService.CreateAgent(destination, aCircuit, (uint)Constants.TeleportFlags.ViaLogin, out reason); | 283 | Constants.TeleportFlags loginFlag = isFirstLogin ? Constants.TeleportFlags.ViaLogin : Constants.TeleportFlags.ViaHGLogin; |
284 | m_log.DebugFormat("[GATEKEEPER SERVICE]: launching agent {0}", loginFlag); | ||
285 | return m_SimulationService.CreateAgent(destination, aCircuit, (uint)loginFlag, out reason); | ||
278 | } | 286 | } |
279 | 287 | ||
280 | protected bool Authenticate(AgentCircuitData aCircuit) | 288 | protected bool Authenticate(AgentCircuitData aCircuit) |
diff --git a/OpenSim/Services/HypergridService/UserAgentService.cs b/OpenSim/Services/HypergridService/UserAgentService.cs index 181d7f2..8c3be70 100644 --- a/OpenSim/Services/HypergridService/UserAgentService.cs +++ b/OpenSim/Services/HypergridService/UserAgentService.cs | |||
@@ -131,10 +131,11 @@ namespace OpenSim.Services.HypergridService | |||
131 | return home; | 131 | return home; |
132 | } | 132 | } |
133 | 133 | ||
134 | public bool LoginAgentToGrid(AgentCircuitData agentCircuit, GridRegion gatekeeper, GridRegion finalDestination, out string reason) | 134 | public bool LoginAgentToGrid(AgentCircuitData agentCircuit, GridRegion gatekeeper, GridRegion finalDestination, IPEndPoint clientIP, out string reason) |
135 | { | 135 | { |
136 | m_log.DebugFormat("[USER AGENT SERVICE]: Request to login user {0} {1} to grid {2}", | 136 | m_log.DebugFormat("[USER AGENT SERVICE]: Request to login user {0} {1} (@{2}) to grid {3}", |
137 | agentCircuit.firstname, agentCircuit.lastname, gatekeeper.ExternalHostName +":"+ gatekeeper.HttpPort); | 137 | agentCircuit.firstname, agentCircuit.lastname, ((clientIP == null) ? "stored IP" : clientIP.Address.ToString()), |
138 | gatekeeper.ExternalHostName +":"+ gatekeeper.HttpPort); | ||
138 | 139 | ||
139 | // Take the IP address + port of the gatekeeper (reg) plus the info of finalDestination | 140 | // Take the IP address + port of the gatekeeper (reg) plus the info of finalDestination |
140 | GridRegion region = new GridRegion(gatekeeper); | 141 | GridRegion region = new GridRegion(gatekeeper); |
@@ -149,11 +150,12 @@ namespace OpenSim.Services.HypergridService | |||
149 | 150 | ||
150 | //bool success = m_GatekeeperConnector.CreateAgent(region, agentCircuit, (uint)Constants.TeleportFlags.ViaLogin, out reason); | 151 | //bool success = m_GatekeeperConnector.CreateAgent(region, agentCircuit, (uint)Constants.TeleportFlags.ViaLogin, out reason); |
151 | bool success = false; | 152 | bool success = false; |
153 | string myExternalIP = string.Empty; | ||
152 | string gridName = "http://" + gatekeeper.ExternalHostName + ":" + gatekeeper.HttpPort; | 154 | string gridName = "http://" + gatekeeper.ExternalHostName + ":" + gatekeeper.HttpPort; |
153 | if (m_GridName == gridName) | 155 | if (m_GridName == gridName) |
154 | success = m_GatekeeperService.LoginAgent(agentCircuit, finalDestination, out reason); | 156 | success = m_GatekeeperService.LoginAgent(agentCircuit, finalDestination, out reason); |
155 | else | 157 | else |
156 | success = m_GatekeeperConnector.CreateAgent(region, agentCircuit, (uint)Constants.TeleportFlags.ViaLogin, out reason); | 158 | success = m_GatekeeperConnector.CreateAgent(region, agentCircuit, (uint)Constants.TeleportFlags.ViaLogin, out myExternalIP, out reason); |
157 | 159 | ||
158 | if (!success) | 160 | if (!success) |
159 | { | 161 | { |
@@ -167,15 +169,26 @@ namespace OpenSim.Services.HypergridService | |||
167 | return false; | 169 | return false; |
168 | } | 170 | } |
169 | 171 | ||
172 | m_log.DebugFormat("[USER AGENT SERVICE]: Gatekeeper sees me as {0}", myExternalIP); | ||
173 | // else set the IP addresses associated with this client | ||
174 | if (clientIP != null) | ||
175 | m_TravelingAgents[agentCircuit.SessionID].ClientIPAddress = clientIP.Address.ToString(); | ||
176 | m_TravelingAgents[agentCircuit.SessionID].MyIpAddress = myExternalIP; | ||
170 | return true; | 177 | return true; |
171 | } | 178 | } |
172 | 179 | ||
173 | public void SetClientToken(UUID sessionID, string token) | 180 | public bool LoginAgentToGrid(AgentCircuitData agentCircuit, GridRegion gatekeeper, GridRegion finalDestination, out string reason) |
181 | { | ||
182 | reason = string.Empty; | ||
183 | return LoginAgentToGrid(agentCircuit, gatekeeper, finalDestination, null, out reason); | ||
184 | } | ||
185 | |||
186 | private void SetClientIP(UUID sessionID, string ip) | ||
174 | { | 187 | { |
175 | if (m_TravelingAgents.ContainsKey(sessionID)) | 188 | if (m_TravelingAgents.ContainsKey(sessionID)) |
176 | { | 189 | { |
177 | m_log.DebugFormat("[USER AGENT SERVICE]: Setting token {0} for session {1}", token, sessionID); | 190 | m_log.DebugFormat("[USER AGENT SERVICE]: Setting IP {0} for session {1}", ip, sessionID); |
178 | m_TravelingAgents[sessionID].ClientToken = token; | 191 | m_TravelingAgents[sessionID].ClientIPAddress = ip; |
179 | } | 192 | } |
180 | } | 193 | } |
181 | 194 | ||
@@ -196,7 +209,7 @@ namespace OpenSim.Services.HypergridService | |||
196 | travel.GridExternalName = "http://" + region.ExternalHostName + ":" + region.HttpPort; | 209 | travel.GridExternalName = "http://" + region.ExternalHostName + ":" + region.HttpPort; |
197 | travel.ServiceToken = agentCircuit.ServiceSessionID; | 210 | travel.ServiceToken = agentCircuit.ServiceSessionID; |
198 | if (old != null) | 211 | if (old != null) |
199 | travel.ClientToken = old.ClientToken; | 212 | travel.ClientIPAddress = old.ClientIPAddress; |
200 | 213 | ||
201 | return old; | 214 | return old; |
202 | } | 215 | } |
@@ -233,15 +246,22 @@ namespace OpenSim.Services.HypergridService | |||
233 | return travel.GridExternalName == thisGridExternalName; | 246 | return travel.GridExternalName == thisGridExternalName; |
234 | } | 247 | } |
235 | 248 | ||
236 | public bool VerifyClient(UUID sessionID, string token) | 249 | public bool VerifyClient(UUID sessionID, string reportedIP) |
237 | { | 250 | { |
238 | if (m_BypassClientVerification) | 251 | if (m_BypassClientVerification) |
239 | return true; | 252 | return true; |
240 | 253 | ||
241 | m_log.DebugFormat("[USER AGENT SERVICE]: Verifying Client session {0} with token {1}", sessionID, token); | 254 | m_log.DebugFormat("[USER AGENT SERVICE]: Verifying Client session {0} with reported IP {1}.", |
255 | sessionID, reportedIP); | ||
242 | 256 | ||
243 | if (m_TravelingAgents.ContainsKey(sessionID)) | 257 | if (m_TravelingAgents.ContainsKey(sessionID)) |
244 | return m_TravelingAgents[sessionID].ClientToken == token; | 258 | { |
259 | m_log.DebugFormat("[USER AGENT SERVICE]: Comparing with login IP {0} and MyIP {1}", | ||
260 | m_TravelingAgents[sessionID].ClientIPAddress, m_TravelingAgents[sessionID].MyIpAddress); | ||
261 | |||
262 | return m_TravelingAgents[sessionID].ClientIPAddress == reportedIP || | ||
263 | m_TravelingAgents[sessionID].MyIpAddress == reportedIP; // NATed | ||
264 | } | ||
245 | 265 | ||
246 | return false; | 266 | return false; |
247 | } | 267 | } |
@@ -266,7 +286,8 @@ namespace OpenSim.Services.HypergridService | |||
266 | public UUID UserID; | 286 | public UUID UserID; |
267 | public string GridExternalName = string.Empty; | 287 | public string GridExternalName = string.Empty; |
268 | public string ServiceToken = string.Empty; | 288 | public string ServiceToken = string.Empty; |
269 | public string ClientToken = string.Empty; | 289 | public string ClientIPAddress = string.Empty; // as seen from this user agent service |
290 | public string MyIpAddress = string.Empty; // the user agent service's external IP, as seen from the next gatekeeper | ||
270 | } | 291 | } |
271 | 292 | ||
272 | } | 293 | } |
diff --git a/OpenSim/Services/Interfaces/IGatekeeperService.cs b/OpenSim/Services/Interfaces/IGatekeeperService.cs index 2d397bc..aac8293 100644 --- a/OpenSim/Services/Interfaces/IGatekeeperService.cs +++ b/OpenSim/Services/Interfaces/IGatekeeperService.cs | |||
@@ -48,13 +48,15 @@ namespace OpenSim.Services.Interfaces | |||
48 | /// </summary> | 48 | /// </summary> |
49 | public interface IUserAgentService | 49 | public interface IUserAgentService |
50 | { | 50 | { |
51 | // called by login service only | ||
52 | bool LoginAgentToGrid(AgentCircuitData agent, GridRegion gatekeeper, GridRegion finalDestination, IPEndPoint clientIP, out string reason); | ||
53 | // called by simulators | ||
51 | bool LoginAgentToGrid(AgentCircuitData agent, GridRegion gatekeeper, GridRegion finalDestination, out string reason); | 54 | bool LoginAgentToGrid(AgentCircuitData agent, GridRegion gatekeeper, GridRegion finalDestination, out string reason); |
52 | void SetClientToken(UUID sessionID, string token); | ||
53 | void LogoutAgent(UUID userID, UUID sessionID); | 55 | void LogoutAgent(UUID userID, UUID sessionID); |
54 | GridRegion GetHomeRegion(UUID userID, out Vector3 position, out Vector3 lookAt); | 56 | GridRegion GetHomeRegion(UUID userID, out Vector3 position, out Vector3 lookAt); |
55 | 57 | ||
56 | bool AgentIsComingHome(UUID sessionID, string thisGridExternalName); | 58 | bool AgentIsComingHome(UUID sessionID, string thisGridExternalName); |
57 | bool VerifyAgent(UUID sessionID, string token); | 59 | bool VerifyAgent(UUID sessionID, string token); |
58 | bool VerifyClient(UUID sessionID, string token); | 60 | bool VerifyClient(UUID sessionID, string reportedIP); |
59 | } | 61 | } |
60 | } | 62 | } |
diff --git a/OpenSim/Services/LLLoginService/LLLoginService.cs b/OpenSim/Services/LLLoginService/LLLoginService.cs index 4b7cb5d..b740297 100644 --- a/OpenSim/Services/LLLoginService/LLLoginService.cs +++ b/OpenSim/Services/LLLoginService/LLLoginService.cs | |||
@@ -755,12 +755,8 @@ namespace OpenSim.Services.LLLoginService | |||
755 | private bool LaunchAgentIndirectly(GridRegion gatekeeper, GridRegion destination, AgentCircuitData aCircuit, IPEndPoint clientIP, out string reason) | 755 | private bool LaunchAgentIndirectly(GridRegion gatekeeper, GridRegion destination, AgentCircuitData aCircuit, IPEndPoint clientIP, out string reason) |
756 | { | 756 | { |
757 | m_log.Debug("[LLOGIN SERVICE] Launching agent at " + destination.RegionName); | 757 | m_log.Debug("[LLOGIN SERVICE] Launching agent at " + destination.RegionName); |
758 | if (m_UserAgentService.LoginAgentToGrid(aCircuit, gatekeeper, destination, out reason)) | 758 | if (m_UserAgentService.LoginAgentToGrid(aCircuit, gatekeeper, destination, clientIP, out reason)) |
759 | { | ||
760 | IPAddress addr = NetworkUtil.GetExternalIPOf(clientIP.Address); | ||
761 | m_UserAgentService.SetClientToken(aCircuit.SessionID, addr.ToString() /* clientIP.Address.ToString() */); | ||
762 | return true; | 759 | return true; |
763 | } | ||
764 | return false; | 760 | return false; |
765 | } | 761 | } |
766 | 762 | ||