diff options
Diffstat (limited to 'OpenSim')
21 files changed, 585 insertions, 470 deletions
diff --git a/OpenSim/Framework/Capabilities/Caps.cs b/OpenSim/Framework/Capabilities/Caps.cs index da953bb..0db7bb9 100644 --- a/OpenSim/Framework/Capabilities/Caps.cs +++ b/OpenSim/Framework/Capabilities/Caps.cs | |||
@@ -142,7 +142,7 @@ namespace OpenSim.Framework.Capabilities | |||
142 | 142 | ||
143 | m_httpListenPort = httpPort; | 143 | m_httpListenPort = httpPort; |
144 | 144 | ||
145 | if (httpServer.UseSSL) | 145 | if (httpServer != null && httpServer.UseSSL) |
146 | { | 146 | { |
147 | m_httpListenPort = httpServer.SSLPort; | 147 | m_httpListenPort = httpServer.SSLPort; |
148 | httpListen = httpServer.SSLCommonName; | 148 | httpListen = httpServer.SSLCommonName; |
@@ -151,7 +151,7 @@ namespace OpenSim.Framework.Capabilities | |||
151 | 151 | ||
152 | m_agentID = agent; | 152 | m_agentID = agent; |
153 | m_dumpAssetsToFile = dumpAssetsToFile; | 153 | m_dumpAssetsToFile = dumpAssetsToFile; |
154 | m_capsHandlers = new CapsHandlers(httpServer, httpListen, httpPort, httpServer.UseSSL); | 154 | m_capsHandlers = new CapsHandlers(httpServer, httpListen, httpPort, (httpServer == null) ? false : httpServer.UseSSL); |
155 | m_regionName = regionName; | 155 | m_regionName = regionName; |
156 | } | 156 | } |
157 | 157 | ||
diff --git a/OpenSim/Framework/Capabilities/CapsHandlers.cs b/OpenSim/Framework/Capabilities/CapsHandlers.cs index f000aed..864e6dd 100644 --- a/OpenSim/Framework/Capabilities/CapsHandlers.cs +++ b/OpenSim/Framework/Capabilities/CapsHandlers.cs | |||
@@ -74,7 +74,7 @@ namespace OpenSim.Framework.Capabilities | |||
74 | m_httpListenerHostName = httpListenerHostname; | 74 | m_httpListenerHostName = httpListenerHostname; |
75 | m_httpListenerPort = httpListenerPort; | 75 | m_httpListenerPort = httpListenerPort; |
76 | m_useSSL = https; | 76 | m_useSSL = https; |
77 | if (m_useSSL) | 77 | if (httpListener != null && m_useSSL) |
78 | { | 78 | { |
79 | m_httpListenerHostName = httpListener.SSLCommonName; | 79 | m_httpListenerHostName = httpListener.SSLCommonName; |
80 | m_httpListenerPort = httpListener.SSLPort; | 80 | m_httpListenerPort = httpListener.SSLPort; |
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/Framework/RegionInfo.cs b/OpenSim/Framework/RegionInfo.cs index 2a74e79..ec25118 100644 --- a/OpenSim/Framework/RegionInfo.cs +++ b/OpenSim/Framework/RegionInfo.cs | |||
@@ -394,7 +394,7 @@ namespace OpenSim.Framework | |||
394 | if (!File.Exists(filename)) // New region config request | 394 | if (!File.Exists(filename)) // New region config request |
395 | { | 395 | { |
396 | IniConfigSource newFile = new IniConfigSource(); | 396 | IniConfigSource newFile = new IniConfigSource(); |
397 | ReadNiniConfig(newFile, String.Empty); | 397 | ReadNiniConfig(newFile, configName); |
398 | 398 | ||
399 | newFile.Save(filename); | 399 | newFile.Save(filename); |
400 | 400 | ||
diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs index bbc42e6..072e4d3 100644 --- a/OpenSim/Region/Application/OpenSim.cs +++ b/OpenSim/Region/Application/OpenSim.cs | |||
@@ -308,8 +308,13 @@ namespace OpenSim | |||
308 | "Persist objects to the database now", RunCommand); | 308 | "Persist objects to the database now", RunCommand); |
309 | 309 | ||
310 | m_console.Commands.AddCommand("region", false, "create region", | 310 | m_console.Commands.AddCommand("region", false, "create region", |
311 | "create region", | 311 | "create region [\"region name\"] <region_file.ini>", |
312 | "Create a new region", HandleCreateRegion); | 312 | "Create a new region.", |
313 | "The settings for \"region name\" are read from <region_file.ini>." | ||
314 | + " If \"region name\" does not exist in <region_file.ini>, it will be added." + Environment.NewLine | ||
315 | + "Without \"region name\", the first region found in <region_file.ini> will be created." + Environment.NewLine | ||
316 | + "If <region_file.ini> does not exist, it will be created.", | ||
317 | HandleCreateRegion); | ||
313 | 318 | ||
314 | m_console.Commands.AddCommand("region", false, "restart", | 319 | m_console.Commands.AddCommand("region", false, "restart", |
315 | "restart", | 320 | "restart", |
@@ -513,47 +518,47 @@ namespace OpenSim | |||
513 | /// Creates a new region based on the parameters specified. This will ask the user questions on the console | 518 | /// Creates a new region based on the parameters specified. This will ask the user questions on the console |
514 | /// </summary> | 519 | /// </summary> |
515 | /// <param name="module"></param> | 520 | /// <param name="module"></param> |
516 | /// <param name="cmd">0,1,region name, region XML file</param> | 521 | /// <param name="cmd">0,1,region name, region ini or XML file</param> |
517 | private void HandleCreateRegion(string module, string[] cmd) | 522 | private void HandleCreateRegion(string module, string[] cmd) |
518 | { | 523 | { |
519 | if (cmd.Length < 4) | 524 | string regionName = string.Empty; |
525 | string regionFile = string.Empty; | ||
526 | if (cmd.Length == 3) | ||
520 | { | 527 | { |
521 | MainConsole.Instance.Output("Usage: create region <region name> <region_file.ini>"); | 528 | regionFile = cmd[2]; |
529 | } | ||
530 | else if (cmd.Length > 3) | ||
531 | { | ||
532 | regionName = cmd[2]; | ||
533 | regionFile = cmd[3]; | ||
534 | } | ||
535 | string extension = Path.GetExtension(regionFile).ToLower(); | ||
536 | bool isXml = extension.Equals(".xml"); | ||
537 | bool isIni = extension.Equals(".ini"); | ||
538 | if (!isXml && !isIni) | ||
539 | { | ||
540 | MainConsole.Instance.Output("Usage: create region [\"region name\"] <region_file.ini>"); | ||
522 | return; | 541 | return; |
523 | } | 542 | } |
524 | if (cmd[3].EndsWith(".xml")) | 543 | if (!Path.IsPathRooted(regionFile)) |
525 | { | 544 | { |
526 | string regionsDir = ConfigSource.Source.Configs["Startup"].GetString("regionload_regionsdir", "Regions").Trim(); | 545 | string regionsDir = ConfigSource.Source.Configs["Startup"].GetString("regionload_regionsdir", "Regions").Trim(); |
527 | string regionFile = String.Format("{0}/{1}", regionsDir, cmd[3]); | 546 | regionFile = Path.Combine(regionsDir, regionFile); |
528 | // Allow absolute and relative specifiers | ||
529 | if (cmd[3].StartsWith("/") || cmd[3].StartsWith("\\") || cmd[3].StartsWith("..")) | ||
530 | regionFile = cmd[3]; | ||
531 | |||
532 | IScene scene; | ||
533 | RegionInfo regInfo = new RegionInfo(cmd[2], regionFile, false, ConfigSource.Source); | ||
534 | PopulateRegionEstateInfo(regInfo); | ||
535 | CreateRegion(regInfo, true, out scene); | ||
536 | regInfo.EstateSettings.Save(); | ||
537 | } | 547 | } |
538 | else if (cmd[3].EndsWith(".ini")) | 548 | |
549 | RegionInfo regInfo; | ||
550 | if (isXml) | ||
539 | { | 551 | { |
540 | string regionsDir = ConfigSource.Source.Configs["Startup"].GetString("regionload_regionsdir", "Regions").Trim(); | 552 | regInfo = new RegionInfo(regionName, regionFile, false, ConfigSource.Source); |
541 | string regionFile = String.Format("{0}/{1}", regionsDir, cmd[3]); | ||
542 | // Allow absolute and relative specifiers | ||
543 | if (cmd[3].StartsWith("/") || cmd[3].StartsWith("\\") || cmd[3].StartsWith("..")) | ||
544 | regionFile = cmd[3]; | ||
545 | |||
546 | IScene scene; | ||
547 | RegionInfo regInfo = new RegionInfo(cmd[2], regionFile, false, ConfigSource.Source, cmd[2]); | ||
548 | PopulateRegionEstateInfo(regInfo); | ||
549 | CreateRegion(regInfo, true, out scene); | ||
550 | regInfo.EstateSettings.Save(); | ||
551 | } | 553 | } |
552 | else | 554 | else |
553 | { | 555 | { |
554 | MainConsole.Instance.Output("Usage: create region <region name> <region_file.ini>"); | 556 | regInfo = new RegionInfo(regionName, regionFile, false, ConfigSource.Source, regionName); |
555 | return; | ||
556 | } | 557 | } |
558 | IScene scene; | ||
559 | PopulateRegionEstateInfo(regInfo); | ||
560 | CreateRegion(regInfo, true, out scene); | ||
561 | regInfo.EstateSettings.Save(); | ||
557 | } | 562 | } |
558 | 563 | ||
559 | /// <summary> | 564 | /// <summary> |
diff --git a/OpenSim/Region/CoreModules/Agent/Capabilities/CapabilitiesModule.cs b/OpenSim/Region/CoreModules/Agent/Capabilities/CapabilitiesModule.cs index a6f5d97..c023a6f 100644 --- a/OpenSim/Region/CoreModules/Agent/Capabilities/CapabilitiesModule.cs +++ b/OpenSim/Region/CoreModules/Agent/Capabilities/CapabilitiesModule.cs | |||
@@ -109,9 +109,9 @@ namespace OpenSim.Region.CoreModules.Agent.Capabilities | |||
109 | Caps caps | 109 | Caps caps |
110 | = new Caps(m_scene, | 110 | = new Caps(m_scene, |
111 | m_scene.AssetService, MainServer.Instance, m_scene.RegionInfo.ExternalHostName, | 111 | m_scene.AssetService, MainServer.Instance, m_scene.RegionInfo.ExternalHostName, |
112 | MainServer.Instance.Port, | 112 | (MainServer.Instance == null) ? 0: MainServer.Instance.Port, |
113 | capsObjectPath, agentId, m_scene.DumpAssetsToFile, m_scene.RegionInfo.RegionName); | 113 | capsObjectPath, agentId, m_scene.DumpAssetsToFile, m_scene.RegionInfo.RegionName); |
114 | 114 | ||
115 | caps.RegisterHandlers(); | 115 | caps.RegisterHandlers(); |
116 | 116 | ||
117 | m_scene.EventManager.TriggerOnRegisterCaps(agentId, caps); | 117 | m_scene.EventManager.TriggerOnRegisterCaps(agentId, caps); |
@@ -121,7 +121,7 @@ namespace OpenSim.Region.CoreModules.Agent.Capabilities | |||
121 | caps.TaskScriptUpdatedCall = m_scene.CapsUpdateTaskInventoryScriptAsset; | 121 | caps.TaskScriptUpdatedCall = m_scene.CapsUpdateTaskInventoryScriptAsset; |
122 | caps.CAPSFetchInventoryDescendents = m_scene.HandleFetchInventoryDescendentsCAPS; | 122 | caps.CAPSFetchInventoryDescendents = m_scene.HandleFetchInventoryDescendentsCAPS; |
123 | caps.GetClient = m_scene.SceneContents.GetControllingClient; | 123 | caps.GetClient = m_scene.SceneContents.GetControllingClient; |
124 | 124 | ||
125 | m_capsHandlers[agentId] = caps; | 125 | m_capsHandlers[agentId] = caps; |
126 | } | 126 | } |
127 | 127 | ||
diff --git a/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs b/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs index 1498dba..a514a83 100644 --- a/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs | |||
@@ -1,223 +1,242 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSimulator Project nor the | 12 | * * Neither the name of the OpenSimulator Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 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 | 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 | 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 | 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. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Reflection; | 30 | using System.Reflection; |
31 | using log4net; | 31 | using log4net; |
32 | using Nini.Config; | 32 | using Nini.Config; |
33 | using OpenMetaverse; | 33 | using OpenMetaverse; |
34 | using OpenSim.Framework; | 34 | using OpenSim.Framework; |
35 | 35 | ||
36 | using OpenSim.Region.Framework.Interfaces; | 36 | using OpenSim.Region.Framework.Interfaces; |
37 | using OpenSim.Region.Framework.Scenes; | 37 | using OpenSim.Region.Framework.Scenes; |
38 | using OpenSim.Services.Interfaces; | 38 | using OpenSim.Services.Interfaces; |
39 | 39 | ||
40 | namespace OpenSim.Region.CoreModules.Avatar.Dialog | 40 | namespace OpenSim.Region.CoreModules.Avatar.Dialog |
41 | { | 41 | { |
42 | public class DialogModule : IRegionModule, IDialogModule | 42 | public class DialogModule : IRegionModule, IDialogModule |
43 | { | 43 | { |
44 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 44 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
45 | 45 | ||
46 | protected Scene m_scene; | 46 | protected Scene m_scene; |
47 | 47 | ||
48 | public void Initialise(Scene scene, IConfigSource source) | 48 | public void Initialise(Scene scene, IConfigSource source) |
49 | { | 49 | { |
50 | m_scene = scene; | 50 | m_scene = scene; |
51 | m_scene.RegisterModuleInterface<IDialogModule>(this); | 51 | m_scene.RegisterModuleInterface<IDialogModule>(this); |
52 | 52 | ||
53 | m_scene.AddCommand( | 53 | m_scene.AddCommand( |
54 | this, "alert", "alert <first> <last> <message>", "Send an alert to a user", HandleAlertConsoleCommand); | 54 | this, "alert", "alert <first> <last> <message>", |
55 | 55 | "Send an alert to a user", | |
56 | m_scene.AddCommand( | 56 | HandleAlertConsoleCommand); |
57 | this, "alert general", "alert general <message>", "Send an alert to everyone", HandleAlertConsoleCommand); | 57 | |
58 | 58 | m_scene.AddCommand( | |
59 | m_scene.AddCommand( | 59 | this, "alert general", "alert [general] <message>", |
60 | this, "alert dialog", "alert dialog <message>", "Send a dialog alert to everyone", HandleAlertConsoleCommand); | 60 | "Send an alert to everyone", |
61 | 61 | "If keyword 'general' is omitted, then <message> must be surrounded by quotation marks.", | |
62 | 62 | HandleAlertConsoleCommand); | |
63 | } | 63 | } |
64 | 64 | ||
65 | public void PostInitialise() {} | 65 | public void PostInitialise() {} |
66 | public void Close() {} | 66 | public void Close() {} |
67 | public string Name { get { return "Dialog Module"; } } | 67 | public string Name { get { return "Dialog Module"; } } |
68 | public bool IsSharedModule { get { return false; } } | 68 | public bool IsSharedModule { get { return false; } } |
69 | 69 | ||
70 | public void SendAlertToUser(IClientAPI client, string message) | 70 | public void SendAlertToUser(IClientAPI client, string message) |
71 | { | 71 | { |
72 | SendAlertToUser(client, message, false); | 72 | SendAlertToUser(client, message, false); |
73 | } | 73 | } |
74 | 74 | ||
75 | public void SendAlertToUser(IClientAPI client, string message, bool modal) | 75 | public void SendAlertToUser(IClientAPI client, string message, bool modal) |
76 | { | 76 | { |
77 | client.SendAgentAlertMessage(message, modal); | 77 | client.SendAgentAlertMessage(message, modal); |
78 | } | 78 | } |
79 | 79 | ||
80 | public void SendAlertToUser(UUID agentID, string message) | 80 | public void SendAlertToUser(UUID agentID, string message) |
81 | { | 81 | { |
82 | SendAlertToUser(agentID, message, false); | 82 | SendAlertToUser(agentID, message, false); |
83 | } | 83 | } |
84 | 84 | ||
85 | public void SendAlertToUser(UUID agentID, string message, bool modal) | 85 | public void SendAlertToUser(UUID agentID, string message, bool modal) |
86 | { | 86 | { |
87 | ScenePresence sp = m_scene.GetScenePresence(agentID); | 87 | ScenePresence sp = m_scene.GetScenePresence(agentID); |
88 | 88 | ||
89 | if (sp != null) | 89 | if (sp != null) |
90 | sp.ControllingClient.SendAgentAlertMessage(message, modal); | 90 | sp.ControllingClient.SendAgentAlertMessage(message, modal); |
91 | } | 91 | } |
92 | 92 | ||
93 | public void SendAlertToUser(string firstName, string lastName, string message, bool modal) | 93 | public void SendAlertToUser(string firstName, string lastName, string message, bool modal) |
94 | { | 94 | { |
95 | ScenePresence presence = m_scene.GetScenePresence(firstName, lastName); | 95 | ScenePresence presence = m_scene.GetScenePresence(firstName, lastName); |
96 | if (presence != null) | 96 | if (presence != null) |
97 | presence.ControllingClient.SendAgentAlertMessage(message, modal); | 97 | presence.ControllingClient.SendAgentAlertMessage(message, modal); |
98 | } | 98 | } |
99 | 99 | ||
100 | public void SendGeneralAlert(string message) | 100 | public void SendGeneralAlert(string message) |
101 | { | 101 | { |
102 | m_scene.ForEachScenePresence(delegate(ScenePresence presence) | 102 | m_scene.ForEachScenePresence(delegate(ScenePresence presence) |
103 | { | 103 | { |
104 | if (!presence.IsChildAgent) | 104 | if (!presence.IsChildAgent) |
105 | { | 105 | presence.ControllingClient.SendAlertMessage(message); |
106 | presence.ControllingClient.SendAlertMessage(message); | 106 | }); |
107 | } | 107 | } |
108 | }); | 108 | |
109 | } | 109 | public void SendDialogToUser( |
110 | 110 | UUID avatarID, string objectName, UUID objectID, UUID ownerID, | |
111 | public void SendDialogToUser( | 111 | string message, UUID textureID, int ch, string[] buttonlabels) |
112 | UUID avatarID, string objectName, UUID objectID, UUID ownerID, | 112 | { |
113 | string message, UUID textureID, int ch, string[] buttonlabels) | 113 | UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, ownerID); |
114 | { | 114 | string ownerFirstName, ownerLastName; |
115 | UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, ownerID); | 115 | if (account != null) |
116 | string ownerFirstName, ownerLastName; | 116 | { |
117 | if (account != null) | 117 | ownerFirstName = account.FirstName; |
118 | { | 118 | ownerLastName = account.LastName; |
119 | ownerFirstName = account.FirstName; | 119 | } |
120 | ownerLastName = account.LastName; | 120 | else |
121 | } | 121 | { |
122 | else | 122 | ownerFirstName = "(unknown"; |
123 | { | 123 | ownerLastName = "user)"; |
124 | ownerFirstName = "(unknown"; | 124 | } |
125 | ownerLastName = "user)"; | 125 | |
126 | } | 126 | ScenePresence sp = m_scene.GetScenePresence(avatarID); |
127 | 127 | if (sp != null) | |
128 | ScenePresence sp = m_scene.GetScenePresence(avatarID); | 128 | sp.ControllingClient.SendDialog(objectName, objectID, ownerFirstName, ownerLastName, message, textureID, ch, buttonlabels); |
129 | if (sp != null) | 129 | } |
130 | sp.ControllingClient.SendDialog(objectName, objectID, ownerFirstName, ownerLastName, message, textureID, ch, buttonlabels); | 130 | |
131 | } | 131 | public void SendUrlToUser( |
132 | 132 | UUID avatarID, string objectName, UUID objectID, UUID ownerID, bool groupOwned, string message, string url) | |
133 | public void SendUrlToUser( | 133 | { |
134 | UUID avatarID, string objectName, UUID objectID, UUID ownerID, bool groupOwned, string message, string url) | 134 | ScenePresence sp = m_scene.GetScenePresence(avatarID); |
135 | { | 135 | |
136 | ScenePresence sp = m_scene.GetScenePresence(avatarID); | 136 | if (sp != null) |
137 | 137 | sp.ControllingClient.SendLoadURL(objectName, objectID, ownerID, groupOwned, message, url); | |
138 | if (sp != null) | 138 | } |
139 | sp.ControllingClient.SendLoadURL(objectName, objectID, ownerID, groupOwned, message, url); | 139 | |
140 | } | 140 | public void SendTextBoxToUser(UUID avatarid, string message, int chatChannel, string name, UUID objectid, UUID ownerid) |
141 | 141 | { | |
142 | public void SendTextBoxToUser(UUID avatarid, string message, int chatChannel, string name, UUID objectid, UUID ownerid) | 142 | UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, ownerid); |
143 | { | 143 | string ownerFirstName, ownerLastName; |
144 | UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, ownerid); | 144 | if (account != null) |
145 | string ownerFirstName, ownerLastName; | 145 | { |
146 | if (account != null) | 146 | ownerFirstName = account.FirstName; |
147 | { | 147 | ownerLastName = account.LastName; |
148 | ownerFirstName = account.FirstName; | 148 | } |
149 | ownerLastName = account.LastName; | 149 | else |
150 | } | 150 | { |
151 | else | 151 | ownerFirstName = "(unknown"; |
152 | { | 152 | ownerLastName = "user)"; |
153 | ownerFirstName = "(unknown"; | 153 | } |
154 | ownerLastName = "user)"; | 154 | |
155 | } | 155 | ScenePresence sp = m_scene.GetScenePresence(avatarid); |
156 | 156 | ||
157 | ScenePresence sp = m_scene.GetScenePresence(avatarid); | 157 | if (sp != null) |
158 | 158 | sp.ControllingClient.SendTextBoxRequest(message, chatChannel, name, ownerFirstName, ownerLastName, objectid); | |
159 | if (sp != null) | 159 | } |
160 | sp.ControllingClient.SendTextBoxRequest(message, chatChannel, name, ownerFirstName, ownerLastName, objectid); | 160 | |
161 | } | 161 | public void SendNotificationToUsersInRegion( |
162 | 162 | UUID fromAvatarID, string fromAvatarName, string message) | |
163 | public void SendNotificationToUsersInRegion( | 163 | { |
164 | UUID fromAvatarID, string fromAvatarName, string message) | 164 | m_scene.ForEachScenePresence(delegate(ScenePresence presence) |
165 | { | 165 | { |
166 | m_scene.ForEachScenePresence(delegate(ScenePresence presence) | 166 | if (!presence.IsChildAgent) |
167 | { | 167 | presence.ControllingClient.SendBlueBoxMessage(fromAvatarID, fromAvatarName, message); |
168 | if (!presence.IsChildAgent) | 168 | }); |
169 | presence.ControllingClient.SendBlueBoxMessage(fromAvatarID, fromAvatarName, message); | 169 | } |
170 | }); | 170 | |
171 | } | 171 | /// <summary> |
172 | 172 | /// Handle an alert command from the console. | |
173 | /// <summary> | 173 | /// </summary> |
174 | /// Handle an alert command from the console. | 174 | /// <param name="module"></param> |
175 | /// </summary> | 175 | /// <param name="cmdparams"></param> |
176 | /// <param name="module"></param> | 176 | public void HandleAlertConsoleCommand(string module, string[] cmdparams) |
177 | /// <param name="cmdparams"></param> | 177 | { |
178 | public void HandleAlertConsoleCommand(string module, string[] cmdparams) | 178 | if (m_scene.ConsoleScene() != null && m_scene.ConsoleScene() != m_scene) |
179 | { | 179 | return; |
180 | if (m_scene.ConsoleScene() != null && m_scene.ConsoleScene() != m_scene) | 180 | |
181 | return; | 181 | bool isGeneral = false; |
182 | 182 | string firstName = string.Empty; | |
183 | if (cmdparams[1] == "general") | 183 | string lastName = string.Empty; |
184 | { | 184 | string message = string.Empty; |
185 | string message = CombineParams(cmdparams, 2); | 185 | |
186 | 186 | if (cmdparams.Length > 1) | |
187 | m_log.InfoFormat( | 187 | { |
188 | "[DIALOG]: Sending general alert in region {0} with message {1}", m_scene.RegionInfo.RegionName, message); | 188 | firstName = cmdparams[1]; |
189 | SendGeneralAlert(message); | 189 | isGeneral = firstName.ToLower().Equals("general"); |
190 | } | 190 | } |
191 | else if (cmdparams[1] == "dialog") | 191 | if (cmdparams.Length == 2 && !isGeneral) |
192 | { | 192 | { |
193 | string message = CombineParams(cmdparams, 2); | 193 | // alert "message" |
194 | 194 | message = cmdparams[1]; | |
195 | m_log.InfoFormat( | 195 | isGeneral = true; |
196 | "[DIALOG]: Sending dialog alert in region {0} with message {1}", m_scene.RegionInfo.RegionName, message); | 196 | } |
197 | SendNotificationToUsersInRegion(UUID.Zero, "System", message); | 197 | else if (cmdparams.Length > 2 && isGeneral) |
198 | } | 198 | { |
199 | else | 199 | // alert general <message> |
200 | { | 200 | message = CombineParams(cmdparams, 2); |
201 | string firstName = cmdparams[1]; | 201 | } |
202 | string lastName = cmdparams[2]; | 202 | else if (cmdparams.Length > 3) |
203 | string message = CombineParams(cmdparams, 3); | 203 | { |
204 | 204 | // alert <first> <last> <message> | |
205 | m_log.InfoFormat( | 205 | lastName = cmdparams[2]; |
206 | "[DIALOG]: Sending alert in region {0} to {1} {2} with message {3}", | 206 | message = CombineParams(cmdparams, 3); |
207 | m_scene.RegionInfo.RegionName, firstName, lastName, message); | 207 | } |
208 | SendAlertToUser(firstName, lastName, message, false); | 208 | else |
209 | } | 209 | { |
210 | } | 210 | OpenSim.Framework.Console.MainConsole.Instance.Output( |
211 | 211 | "Usage: alert \"message\" | alert general <message> | alert <first> <last> <message>"); | |
212 | private string CombineParams(string[] commandParams, int pos) | 212 | return; |
213 | { | 213 | } |
214 | string result = string.Empty; | 214 | |
215 | for (int i = pos; i < commandParams.Length; i++) | 215 | if (isGeneral) |
216 | { | 216 | { |
217 | result += commandParams[i] + " "; | 217 | m_log.InfoFormat( |
218 | } | 218 | "[DIALOG]: Sending general alert in region {0} with message {1}", |
219 | 219 | m_scene.RegionInfo.RegionName, message); | |
220 | return result; | 220 | SendGeneralAlert(message); |
221 | } | 221 | } |
222 | } | 222 | else |
223 | } | 223 | { |
224 | m_log.InfoFormat( | ||
225 | "[DIALOG]: Sending alert in region {0} to {1} {2} with message {3}", | ||
226 | m_scene.RegionInfo.RegionName, firstName, lastName, message); | ||
227 | SendAlertToUser(firstName, lastName, message, false); | ||
228 | } | ||
229 | } | ||
230 | |||
231 | private string CombineParams(string[] commandParams, int pos) | ||
232 | { | ||
233 | string result = string.Empty; | ||
234 | for (int i = pos; i < commandParams.Length; i++) | ||
235 | { | ||
236 | result += commandParams[i] + " "; | ||
237 | } | ||
238 | |||
239 | return result; | ||
240 | } | ||
241 | } | ||
242 | } | ||
diff --git a/OpenSim/Region/CoreModules/InterGrid/OpenGridProtocolModule.cs b/OpenSim/Region/CoreModules/InterGrid/OpenGridProtocolModule.cs index 87a0a8d..fd0e879 100644 --- a/OpenSim/Region/CoreModules/InterGrid/OpenGridProtocolModule.cs +++ b/OpenSim/Region/CoreModules/InterGrid/OpenGridProtocolModule.cs | |||
@@ -100,7 +100,7 @@ namespace OpenSim.Region.CoreModules.InterGrid | |||
100 | bool enabled = false; | 100 | bool enabled = false; |
101 | IConfig cfg = null; | 101 | IConfig cfg = null; |
102 | IConfig httpcfg = null; | 102 | IConfig httpcfg = null; |
103 | IConfig startupcfg = null; | 103 | // IConfig startupcfg = null; |
104 | try | 104 | try |
105 | { | 105 | { |
106 | cfg = config.Configs["OpenGridProtocol"]; | 106 | cfg = config.Configs["OpenGridProtocol"]; |
@@ -117,14 +117,14 @@ namespace OpenSim.Region.CoreModules.InterGrid | |||
117 | { | 117 | { |
118 | 118 | ||
119 | } | 119 | } |
120 | try | 120 | // try |
121 | { | 121 | // { |
122 | startupcfg = config.Configs["Startup"]; | 122 | // startupcfg = config.Configs["Startup"]; |
123 | } | 123 | // } |
124 | catch (NullReferenceException) | 124 | // catch (NullReferenceException) |
125 | { | 125 | // { |
126 | 126 | // | |
127 | } | 127 | // } |
128 | 128 | ||
129 | // if (startupcfg != null) | 129 | // if (startupcfg != null) |
130 | // { | 130 | // { |
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 98c46bd..32211c4 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -2584,18 +2584,25 @@ namespace OpenSim.Region.Framework.Scenes | |||
2584 | /// <param name="client"></param> | 2584 | /// <param name="client"></param> |
2585 | public override void AddNewClient(IClientAPI client) | 2585 | public override void AddNewClient(IClientAPI client) |
2586 | { | 2586 | { |
2587 | AgentCircuitData aCircuit = m_authenticateHandler.GetAgentCircuitData(client.CircuitCode); | ||
2587 | bool vialogin = false; | 2588 | bool vialogin = false; |
2588 | 2589 | ||
2589 | m_clientManager.Add(client); | 2590 | if (aCircuit == null) // no good, didn't pass NewUserConnection successfully |
2591 | return; | ||
2592 | |||
2593 | vialogin = (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0 || | ||
2594 | (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; | ||
2590 | 2595 | ||
2591 | CheckHeartbeat(); | 2596 | CheckHeartbeat(); |
2592 | SubscribeToClientEvents(client); | ||
2593 | ScenePresence presence; | 2597 | ScenePresence presence; |
2594 | 2598 | ||
2595 | if (m_restorePresences.ContainsKey(client.AgentId)) | 2599 | if (m_restorePresences.ContainsKey(client.AgentId)) |
2596 | { | 2600 | { |
2597 | m_log.DebugFormat("[SCENE]: Restoring agent {0} {1} in {2}", client.Name, client.AgentId, RegionInfo.RegionName); | 2601 | m_log.DebugFormat("[SCENE]: Restoring agent {0} {1} in {2}", client.Name, client.AgentId, RegionInfo.RegionName); |
2598 | 2602 | ||
2603 | m_clientManager.Add(client); | ||
2604 | SubscribeToClientEvents(client); | ||
2605 | |||
2599 | presence = m_restorePresences[client.AgentId]; | 2606 | presence = m_restorePresences[client.AgentId]; |
2600 | m_restorePresences.Remove(client.AgentId); | 2607 | m_restorePresences.Remove(client.AgentId); |
2601 | 2608 | ||
@@ -2618,49 +2625,35 @@ namespace OpenSim.Region.Framework.Scenes | |||
2618 | } | 2625 | } |
2619 | else | 2626 | else |
2620 | { | 2627 | { |
2621 | AgentCircuitData aCircuit = m_authenticateHandler.GetAgentCircuitData(client.CircuitCode); | 2628 | if (GetScenePresence(client.AgentId) == null) // ensure there is no SP here |
2622 | |||
2623 | // Do the verification here | ||
2624 | System.Net.IPEndPoint ep = (System.Net.IPEndPoint)client.GetClientEP(); | ||
2625 | if (aCircuit != null) | ||
2626 | { | 2629 | { |
2627 | if (!VerifyClient(aCircuit, ep, out vialogin)) | 2630 | m_log.Debug("[SCENE]: Adding new agent " + client.Name + " to scene " + RegionInfo.RegionName); |
2628 | { | ||
2629 | // uh-oh, this is fishy | ||
2630 | m_log.WarnFormat("[SCENE]: Agent {0} with session {1} connecting with unidentified end point {2}. Refusing service.", | ||
2631 | client.AgentId, client.SessionId, ep.ToString()); | ||
2632 | try | ||
2633 | { | ||
2634 | client.Close(); | ||
2635 | } | ||
2636 | catch (Exception e) | ||
2637 | { | ||
2638 | m_log.DebugFormat("[SCENE]: Exception while closing aborted client: {0}", e.StackTrace); | ||
2639 | } | ||
2640 | return; | ||
2641 | } | ||
2642 | } | ||
2643 | 2631 | ||
2644 | m_log.Debug("[SCENE]: Adding new agent " + client.Name + " to scene " + RegionInfo.RegionName); | 2632 | m_clientManager.Add(client); |
2633 | SubscribeToClientEvents(client); | ||
2645 | 2634 | ||
2646 | ScenePresence sp = CreateAndAddScenePresence(client); | 2635 | ScenePresence sp = CreateAndAddScenePresence(client); |
2647 | if (aCircuit != null) | 2636 | if (aCircuit != null) |
2648 | sp.Appearance = aCircuit.Appearance; | 2637 | sp.Appearance = aCircuit.Appearance; |
2649 | 2638 | ||
2650 | // HERE!!! Do the initial attachments right here | 2639 | // HERE!!! Do the initial attachments right here |
2651 | // first agent upon login is a root agent by design. | 2640 | // first agent upon login is a root agent by design. |
2652 | // All other AddNewClient calls find aCircuit.child to be true | 2641 | // All other AddNewClient calls find aCircuit.child to be true |
2653 | if (aCircuit == null || (aCircuit != null && aCircuit.child == false)) | 2642 | if (aCircuit == null || (aCircuit != null && aCircuit.child == false)) |
2654 | { | 2643 | { |
2655 | sp.IsChildAgent = false; | 2644 | sp.IsChildAgent = false; |
2656 | Util.FireAndForget(delegate(object o) { sp.RezAttachments(); }); | 2645 | Util.FireAndForget(delegate(object o) { sp.RezAttachments(); }); |
2646 | } | ||
2657 | } | 2647 | } |
2658 | } | 2648 | } |
2659 | 2649 | ||
2660 | m_LastLogin = Util.EnvironmentTickCount(); | 2650 | if (GetScenePresence(client.AgentId) != null) |
2661 | EventManager.TriggerOnNewClient(client); | 2651 | { |
2662 | if (vialogin) | 2652 | m_LastLogin = Util.EnvironmentTickCount(); |
2663 | EventManager.TriggerOnClientLogin(client); | 2653 | EventManager.TriggerOnNewClient(client); |
2654 | if (vialogin) | ||
2655 | EventManager.TriggerOnClientLogin(client); | ||
2656 | } | ||
2664 | } | 2657 | } |
2665 | 2658 | ||
2666 | private bool VerifyClient(AgentCircuitData aCircuit, System.Net.IPEndPoint ep, out bool vialogin) | 2659 | private bool VerifyClient(AgentCircuitData aCircuit, System.Net.IPEndPoint ep, out bool vialogin) |
@@ -2668,16 +2661,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
2668 | vialogin = false; | 2661 | vialogin = false; |
2669 | 2662 | ||
2670 | // Do the verification here | 2663 | // Do the verification here |
2671 | if ((aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0) | 2664 | if ((aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0) |
2672 | { | 2665 | { |
2673 | m_log.DebugFormat("[SCENE]: Incoming client {0} {1} in region {2} via Login", aCircuit.firstname, aCircuit.lastname, RegionInfo.RegionName); | 2666 | m_log.DebugFormat("[SCENE]: Incoming client {0} {1} in region {2} via HG login", aCircuit.firstname, aCircuit.lastname, RegionInfo.RegionName); |
2674 | vialogin = true; | 2667 | vialogin = true; |
2675 | IUserAgentVerificationModule userVerification = RequestModuleInterface<IUserAgentVerificationModule>(); | 2668 | IUserAgentVerificationModule userVerification = RequestModuleInterface<IUserAgentVerificationModule>(); |
2676 | if (userVerification != null && ep != null) | 2669 | if (userVerification != null && ep != null) |
2677 | { | 2670 | { |
2678 | System.Net.IPAddress addr = NetworkUtil.GetExternalIPOf(ep.Address); | 2671 | if (!userVerification.VerifyClient(aCircuit, ep.Address.ToString())) |
2679 | |||
2680 | if (!userVerification.VerifyClient(aCircuit, /*ep.Address.ToString() */ addr.ToString())) | ||
2681 | { | 2672 | { |
2682 | // uh-oh, this is fishy | 2673 | // uh-oh, this is fishy |
2683 | m_log.DebugFormat("[SCENE]: User Client Verification for {0} {1} in {2} returned false", aCircuit.firstname, aCircuit.lastname, RegionInfo.RegionName); | 2674 | m_log.DebugFormat("[SCENE]: User Client Verification for {0} {1} in {2} returned false", aCircuit.firstname, aCircuit.lastname, RegionInfo.RegionName); |
@@ -2688,6 +2679,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
2688 | } | 2679 | } |
2689 | } | 2680 | } |
2690 | 2681 | ||
2682 | else if ((aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0) | ||
2683 | { | ||
2684 | m_log.DebugFormat("[SCENE]: Incoming client {0} {1} in region {2} via regular login. Client IP verification not performed.", | ||
2685 | aCircuit.firstname, aCircuit.lastname, RegionInfo.RegionName); | ||
2686 | vialogin = true; | ||
2687 | } | ||
2688 | |||
2691 | return true; | 2689 | return true; |
2692 | } | 2690 | } |
2693 | 2691 | ||
@@ -3343,7 +3341,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3343 | /// also return a reason.</returns> | 3341 | /// also return a reason.</returns> |
3344 | public bool NewUserConnection(AgentCircuitData agent, uint teleportFlags, out string reason) | 3342 | public bool NewUserConnection(AgentCircuitData agent, uint teleportFlags, out string reason) |
3345 | { | 3343 | { |
3346 | TeleportFlags tp = (TeleportFlags)teleportFlags; | 3344 | bool vialogin = ((teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0 || |
3345 | (teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0); | ||
3347 | reason = String.Empty; | 3346 | reason = String.Empty; |
3348 | 3347 | ||
3349 | //Teleport flags: | 3348 | //Teleport flags: |
@@ -3380,7 +3379,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3380 | ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y); | 3379 | ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y); |
3381 | 3380 | ||
3382 | //On login test land permisions | 3381 | //On login test land permisions |
3383 | if (tp == TeleportFlags.ViaLogin) | 3382 | if (vialogin) |
3384 | { | 3383 | { |
3385 | if (land != null && !TestLandRestrictions(agent, land, out reason)) | 3384 | if (land != null && !TestLandRestrictions(agent, land, out reason)) |
3386 | { | 3385 | { |
@@ -3440,7 +3439,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3440 | agent.teleportFlags = teleportFlags; | 3439 | agent.teleportFlags = teleportFlags; |
3441 | m_authenticateHandler.AddNewCircuit(agent.circuitcode, agent); | 3440 | m_authenticateHandler.AddNewCircuit(agent.circuitcode, agent); |
3442 | 3441 | ||
3443 | if (tp == TeleportFlags.ViaLogin) | 3442 | if (vialogin) |
3444 | { | 3443 | { |
3445 | if (TestBorderCross(agent.startpos, Cardinals.E)) | 3444 | if (TestBorderCross(agent.startpos, Cardinals.E)) |
3446 | { | 3445 | { |
@@ -3561,7 +3560,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3561 | IPresenceService presence = RequestModuleInterface<IPresenceService>(); | 3560 | IPresenceService presence = RequestModuleInterface<IPresenceService>(); |
3562 | if (presence == null) | 3561 | if (presence == null) |
3563 | { | 3562 | { |
3564 | reason = String.Format("Failed to verify user {0} {1} in region {2}. Presence service does not exist.", agent.firstname, agent.lastname, RegionInfo.RegionName); | 3563 | reason = String.Format("Failed to verify user presence in the grid for {0} {1} in region {2}. Presence service does not exist.", agent.firstname, agent.lastname, RegionInfo.RegionName); |
3565 | return false; | 3564 | return false; |
3566 | } | 3565 | } |
3567 | 3566 | ||
@@ -3569,7 +3568,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3569 | 3568 | ||
3570 | if (pinfo == null) | 3569 | if (pinfo == null) |
3571 | { | 3570 | { |
3572 | reason = String.Format("Failed to verify user {0} {1}, access denied to region {2}.", agent.firstname, agent.lastname, RegionInfo.RegionName); | 3571 | reason = String.Format("Failed to verify user presence in the grid for {0} {1}, access denied to region {2}.", agent.firstname, agent.lastname, RegionInfo.RegionName); |
3573 | return false; | 3572 | return false; |
3574 | } | 3573 | } |
3575 | 3574 | ||
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs index d4f9f18..54b3260 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs | |||
@@ -130,11 +130,11 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
130 | { | 130 | { |
131 | TestHelper.InMethod(); | 131 | TestHelper.InMethod(); |
132 | //log4net.Config.XmlConfigurator.Configure(); | 132 | //log4net.Config.XmlConfigurator.Configure(); |
133 | 133 | ||
134 | UUID agentId = UUID.Parse("00000000-0000-0000-0000-000000000001"); | 134 | UUID agentId = UUID.Parse("00000000-0000-0000-0000-000000000001"); |
135 | 135 | ||
136 | TestScene scene = SceneSetupHelpers.SetupScene(); | 136 | TestScene scene = SceneSetupHelpers.SetupScene(); |
137 | 137 | ||
138 | // Turn off the timer on the async sog deleter - we'll crank it by hand for this test. | 138 | // Turn off the timer on the async sog deleter - we'll crank it by hand for this test. |
139 | AsyncSceneObjectGroupDeleter sogd = scene.SceneObjectGroupDeleter; | 139 | AsyncSceneObjectGroupDeleter sogd = scene.SceneObjectGroupDeleter; |
140 | sogd.Enabled = false; | 140 | sogd.Enabled = false; |
@@ -147,7 +147,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
147 | SceneObjectPart retrievedPart = scene.GetSceneObjectPart(part.LocalId); | 147 | SceneObjectPart retrievedPart = scene.GetSceneObjectPart(part.LocalId); |
148 | 148 | ||
149 | Assert.That(retrievedPart, Is.Not.Null); | 149 | Assert.That(retrievedPart, Is.Not.Null); |
150 | 150 | ||
151 | sogd.InventoryDeQueueAndDelete(); | 151 | sogd.InventoryDeQueueAndDelete(); |
152 | 152 | ||
153 | SceneObjectPart retrievedPart2 = scene.GetSceneObjectPart(part.LocalId); | 153 | SceneObjectPart retrievedPart2 = scene.GetSceneObjectPart(part.LocalId); |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs index 501207e..e39a362 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs | |||
@@ -104,8 +104,8 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
104 | agent.AgentID = agent1; | 104 | agent.AgentID = agent1; |
105 | agent.firstname = firstName; | 105 | agent.firstname = firstName; |
106 | agent.lastname = "testlastname"; | 106 | agent.lastname = "testlastname"; |
107 | agent.SessionID = UUID.Zero; | 107 | agent.SessionID = UUID.Random(); |
108 | agent.SecureSessionID = UUID.Zero; | 108 | agent.SecureSessionID = UUID.Random(); |
109 | agent.circuitcode = 123; | 109 | agent.circuitcode = 123; |
110 | agent.BaseFolder = UUID.Zero; | 110 | agent.BaseFolder = UUID.Zero; |
111 | agent.InventoryFolder = UUID.Zero; | 111 | agent.InventoryFolder = UUID.Zero; |
@@ -114,6 +114,11 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
114 | agent.ChildrenCapSeeds = new Dictionary<ulong, string>(); | 114 | agent.ChildrenCapSeeds = new Dictionary<ulong, string>(); |
115 | agent.child = true; | 115 | agent.child = true; |
116 | 116 | ||
117 | if (scene.PresenceService == null) | ||
118 | Console.WriteLine("Presence Service is null"); | ||
119 | |||
120 | scene.PresenceService.LoginAgent(agent.AgentID.ToString(), agent.SessionID, agent.SecureSessionID); | ||
121 | |||
117 | string reason; | 122 | string reason; |
118 | scene.NewUserConnection(agent, (uint)TeleportFlags.ViaLogin, out reason); | 123 | scene.NewUserConnection(agent, (uint)TeleportFlags.ViaLogin, out reason); |
119 | testclient = new TestClient(agent, scene); | 124 | testclient = new TestClient(agent, scene); |
diff --git a/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs b/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs index 9739e5a..05b00e5 100644 --- a/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs +++ b/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs | |||
@@ -183,6 +183,8 @@ namespace OpenSim.Server.Handlers.Simulation | |||
183 | 183 | ||
184 | resp["reason"] = OSD.FromString(reason); | 184 | resp["reason"] = OSD.FromString(reason); |
185 | resp["success"] = OSD.FromBoolean(result); | 185 | resp["success"] = OSD.FromBoolean(result); |
186 | // Let's also send out the IP address of the caller back to the caller (HG 1.5) | ||
187 | resp["your_ip"] = OSD.FromString(GetCallerIP(request)); | ||
186 | 188 | ||
187 | // TODO: add reason if not String.Empty? | 189 | // TODO: add reason if not String.Empty? |
188 | responsedata["int_response_code"] = HttpStatusCode.OK; | 190 | responsedata["int_response_code"] = HttpStatusCode.OK; |
@@ -375,6 +377,24 @@ namespace OpenSim.Server.Handlers.Simulation | |||
375 | { | 377 | { |
376 | m_SimulationService.ReleaseAgent(regionID, id, ""); | 378 | m_SimulationService.ReleaseAgent(regionID, id, ""); |
377 | } | 379 | } |
380 | |||
381 | private string GetCallerIP(Hashtable req) | ||
382 | { | ||
383 | if (req.ContainsKey("headers")) | ||
384 | { | ||
385 | try | ||
386 | { | ||
387 | Hashtable headers = (Hashtable)req["headers"]; | ||
388 | if (headers.ContainsKey("remote_addr") && headers["remote_addr"] != null) | ||
389 | return headers["remote_addr"].ToString(); | ||
390 | } | ||
391 | catch (Exception e) | ||
392 | { | ||
393 | m_log.WarnFormat("[AGENT HANDLER]: exception in GetCallerIP: {0}", e.Message); | ||
394 | } | ||
395 | } | ||
396 | return string.Empty; | ||
397 | } | ||
378 | } | 398 | } |
379 | 399 | ||
380 | } | 400 | } |
diff --git a/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs index 6f159a0..cabee4c 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 | ||
@@ -278,5 +279,48 @@ namespace OpenSim.Services.Connectors.Hypergrid | |||
278 | return null; | 279 | return null; |
279 | } | 280 | } |
280 | 281 | ||
282 | public bool CreateAgent(GridRegion destination, AgentCircuitData aCircuit, uint flags, out string myipaddress, out string reason) | ||
283 | { | ||
284 | HttpWebRequest AgentCreateRequest = null; | ||
285 | myipaddress = String.Empty; | ||
286 | reason = String.Empty; | ||
287 | |||
288 | if (SendRequest(destination, aCircuit, flags, out reason, out AgentCreateRequest)) | ||
289 | { | ||
290 | string response = GetResponse(AgentCreateRequest, out reason); | ||
291 | bool success = true; | ||
292 | UnpackResponse(response, out success, out reason, out myipaddress); | ||
293 | return success; | ||
294 | } | ||
295 | |||
296 | return false; | ||
297 | } | ||
298 | |||
299 | protected void UnpackResponse(string response, out bool result, out string reason, out string ipaddress) | ||
300 | { | ||
301 | result = true; | ||
302 | reason = string.Empty; | ||
303 | ipaddress = string.Empty; | ||
304 | |||
305 | if (!String.IsNullOrEmpty(response)) | ||
306 | { | ||
307 | try | ||
308 | { | ||
309 | // we assume we got an OSDMap back | ||
310 | OSDMap r = Util.GetOSDMap(response); | ||
311 | result = r["success"].AsBoolean(); | ||
312 | reason = r["reason"].AsString(); | ||
313 | ipaddress = r["your_ip"].AsString(); | ||
314 | } | ||
315 | catch (NullReferenceException e) | ||
316 | { | ||
317 | m_log.InfoFormat("[GATEKEEPER SERVICE CONNECTOR]: exception on UnpackResponse of DoCreateChildAgentCall {0}", e.Message); | ||
318 | reason = "Internal error"; | ||
319 | result = false; | ||
320 | } | ||
321 | } | ||
322 | } | ||
323 | |||
324 | |||
281 | } | 325 | } |
282 | } | 326 | } |
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 957df35..9e30044 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 0bf75b0..09be4a2 100644 --- a/OpenSim/Services/LLLoginService/LLLoginService.cs +++ b/OpenSim/Services/LLLoginService/LLLoginService.cs | |||
@@ -761,12 +761,8 @@ namespace OpenSim.Services.LLLoginService | |||
761 | private bool LaunchAgentIndirectly(GridRegion gatekeeper, GridRegion destination, AgentCircuitData aCircuit, IPEndPoint clientIP, out string reason) | 761 | private bool LaunchAgentIndirectly(GridRegion gatekeeper, GridRegion destination, AgentCircuitData aCircuit, IPEndPoint clientIP, out string reason) |
762 | { | 762 | { |
763 | m_log.Debug("[LLOGIN SERVICE] Launching agent at " + destination.RegionName); | 763 | m_log.Debug("[LLOGIN SERVICE] Launching agent at " + destination.RegionName); |
764 | if (m_UserAgentService.LoginAgentToGrid(aCircuit, gatekeeper, destination, out reason)) | 764 | if (m_UserAgentService.LoginAgentToGrid(aCircuit, gatekeeper, destination, clientIP, out reason)) |
765 | { | ||
766 | IPAddress addr = NetworkUtil.GetExternalIPOf(clientIP.Address); | ||
767 | m_UserAgentService.SetClientToken(aCircuit.SessionID, addr.ToString() /* clientIP.Address.ToString() */); | ||
768 | return true; | 765 | return true; |
769 | } | ||
770 | return false; | 766 | return false; |
771 | } | 767 | } |
772 | 768 | ||
diff --git a/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs b/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs index 4a356e2..eaa0d33 100644 --- a/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs +++ b/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs | |||
@@ -46,6 +46,7 @@ using OpenSim.Region.CoreModules.ServiceConnectorsOut.Authentication; | |||
46 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory; | 46 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory; |
47 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid; | 47 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid; |
48 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts; | 48 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts; |
49 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence; | ||
49 | using OpenSim.Services.Interfaces; | 50 | using OpenSim.Services.Interfaces; |
50 | using OpenSim.Tests.Common.Mock; | 51 | using OpenSim.Tests.Common.Mock; |
51 | 52 | ||
@@ -63,6 +64,7 @@ namespace OpenSim.Tests.Common.Setup | |||
63 | private static ISharedRegionModule m_inventoryService = null; | 64 | private static ISharedRegionModule m_inventoryService = null; |
64 | private static ISharedRegionModule m_gridService = null; | 65 | private static ISharedRegionModule m_gridService = null; |
65 | private static ISharedRegionModule m_userAccountService = null; | 66 | private static ISharedRegionModule m_userAccountService = null; |
67 | private static ISharedRegionModule m_presenceService = null; | ||
66 | 68 | ||
67 | /// <summary> | 69 | /// <summary> |
68 | /// Set up a test scene | 70 | /// Set up a test scene |
@@ -180,7 +182,7 @@ namespace OpenSim.Tests.Common.Setup | |||
180 | else | 182 | else |
181 | StartAssetService(testScene, false); | 183 | StartAssetService(testScene, false); |
182 | 184 | ||
183 | // For now, always started a 'real' authenication service | 185 | // For now, always started a 'real' authentication service |
184 | StartAuthenticationService(testScene, true); | 186 | StartAuthenticationService(testScene, true); |
185 | 187 | ||
186 | if (realServices.Contains("inventory")) | 188 | if (realServices.Contains("inventory")) |
@@ -188,10 +190,9 @@ namespace OpenSim.Tests.Common.Setup | |||
188 | else | 190 | else |
189 | StartInventoryService(testScene, false); | 191 | StartInventoryService(testScene, false); |
190 | 192 | ||
191 | if (realServices.Contains("grid")) | 193 | StartGridService(testScene, true); |
192 | StartGridService(testScene, true); | ||
193 | |||
194 | StartUserAccountService(testScene); | 194 | StartUserAccountService(testScene); |
195 | StartPresenceService(testScene); | ||
195 | } | 196 | } |
196 | // If not, make sure the shared module gets references to this new scene | 197 | // If not, make sure the shared module gets references to this new scene |
197 | else | 198 | else |
@@ -202,11 +203,15 @@ namespace OpenSim.Tests.Common.Setup | |||
202 | m_inventoryService.RegionLoaded(testScene); | 203 | m_inventoryService.RegionLoaded(testScene); |
203 | m_userAccountService.AddRegion(testScene); | 204 | m_userAccountService.AddRegion(testScene); |
204 | m_userAccountService.RegionLoaded(testScene); | 205 | m_userAccountService.RegionLoaded(testScene); |
206 | m_presenceService.AddRegion(testScene); | ||
207 | m_presenceService.RegionLoaded(testScene); | ||
208 | |||
205 | } | 209 | } |
206 | 210 | ||
207 | m_inventoryService.PostInitialise(); | 211 | m_inventoryService.PostInitialise(); |
208 | m_assetService.PostInitialise(); | 212 | m_assetService.PostInitialise(); |
209 | m_userAccountService.PostInitialise(); | 213 | m_userAccountService.PostInitialise(); |
214 | m_presenceService.PostInitialise(); | ||
210 | testScene.RegionInfo.EstateSettings.EstateOwner = UUID.Random(); | 215 | testScene.RegionInfo.EstateSettings.EstateOwner = UUID.Random(); |
211 | testScene.SetModuleInterfaces(); | 216 | testScene.SetModuleInterfaces(); |
212 | 217 | ||
@@ -225,7 +230,11 @@ namespace OpenSim.Tests.Common.Setup | |||
225 | m_inventoryService = null; | 230 | m_inventoryService = null; |
226 | m_gridService = null; | 231 | m_gridService = null; |
227 | m_userAccountService = null; | 232 | m_userAccountService = null; |
228 | 233 | m_presenceService = null; | |
234 | |||
235 | testScene.RegionInfo.EstateSettings = new EstateSettings(); | ||
236 | testScene.LoginsDisabled = false; | ||
237 | |||
229 | return testScene; | 238 | return testScene; |
230 | } | 239 | } |
231 | 240 | ||
@@ -337,6 +346,32 @@ namespace OpenSim.Tests.Common.Setup | |||
337 | } | 346 | } |
338 | 347 | ||
339 | /// <summary> | 348 | /// <summary> |
349 | /// Start a presence service | ||
350 | /// </summary> | ||
351 | /// <param name="testScene"></param> | ||
352 | private static void StartPresenceService(Scene testScene) | ||
353 | { | ||
354 | IConfigSource config = new IniConfigSource(); | ||
355 | config.AddConfig("Modules"); | ||
356 | config.AddConfig("PresenceService"); | ||
357 | config.Configs["Modules"].Set("PresenceServices", "LocalPresenceServicesConnector"); | ||
358 | config.Configs["PresenceService"].Set("StorageProvider", "OpenSim.Data.Null.dll"); | ||
359 | config.Configs["PresenceService"].Set( | ||
360 | "LocalServiceModule", "OpenSim.Services.PresenceService.dll:PresenceService"); | ||
361 | |||
362 | if (m_presenceService == null) | ||
363 | { | ||
364 | ISharedRegionModule presenceService = new LocalPresenceServicesConnector(); | ||
365 | presenceService.Initialise(config); | ||
366 | m_presenceService = presenceService; | ||
367 | } | ||
368 | |||
369 | m_presenceService.AddRegion(testScene); | ||
370 | m_presenceService.RegionLoaded(testScene); | ||
371 | testScene.AddRegionModule(m_presenceService.Name, m_presenceService); | ||
372 | } | ||
373 | |||
374 | /// <summary> | ||
340 | /// Setup modules for a scene using their default settings. | 375 | /// Setup modules for a scene using their default settings. |
341 | /// </summary> | 376 | /// </summary> |
342 | /// <param name="scene"></param> | 377 | /// <param name="scene"></param> |
@@ -446,9 +481,14 @@ namespace OpenSim.Tests.Common.Setup | |||
446 | { | 481 | { |
447 | string reason; | 482 | string reason; |
448 | 483 | ||
449 | // We emulate the proper login sequence here by doing things in three stages | 484 | // We emulate the proper login sequence here by doing things in four stages |
485 | |||
486 | // Stage 0: log the presence | ||
487 | scene.PresenceService.LoginAgent(agentData.AgentID.ToString(), agentData.SessionID, agentData.SecureSessionID); | ||
488 | |||
450 | // Stage 1: simulate login by telling the scene to expect a new user connection | 489 | // Stage 1: simulate login by telling the scene to expect a new user connection |
451 | scene.NewUserConnection(agentData, (uint)TeleportFlags.ViaLogin, out reason); | 490 | if (!scene.NewUserConnection(agentData, (uint)TeleportFlags.ViaLogin, out reason)) |
491 | Console.WriteLine("NewUserConnection failed: " + reason); | ||
452 | 492 | ||
453 | // Stage 2: add the new client as a child agent to the scene | 493 | // Stage 2: add the new client as a child agent to the scene |
454 | TestClient client = new TestClient(agentData, scene); | 494 | TestClient client = new TestClient(agentData, scene); |
@@ -459,7 +499,7 @@ namespace OpenSim.Tests.Common.Setup | |||
459 | //scene.AgentCrossing(agentData.AgentID, new Vector3(90, 90, 90), false); OBSOLETE | 499 | //scene.AgentCrossing(agentData.AgentID, new Vector3(90, 90, 90), false); OBSOLETE |
460 | 500 | ||
461 | ScenePresence scp = scene.GetScenePresence(agentData.AgentID); | 501 | ScenePresence scp = scene.GetScenePresence(agentData.AgentID); |
462 | scp.MakeRootAgent(new Vector3(90,90,90), true); | 502 | scp.MakeRootAgent(new Vector3(90, 90, 90), true); |
463 | 503 | ||
464 | return client; | 504 | return client; |
465 | } | 505 | } |