Merge branch 'master' into careminster-presence-refactor

This commit is contained in:
Melanie
2010-08-21 00:32:26 +01:00
24 changed files with 675 additions and 550 deletions

View File

@@ -308,8 +308,13 @@ namespace OpenSim
"Persist objects to the database now", RunCommand);
m_console.Commands.AddCommand("region", false, "create region",
"create region",
"Create a new region", HandleCreateRegion);
"create region [\"region name\"] <region_file.ini>",
"Create a new region.",
"The settings for \"region name\" are read from <region_file.ini>."
+ " If \"region name\" does not exist in <region_file.ini>, it will be added." + Environment.NewLine
+ "Without \"region name\", the first region found in <region_file.ini> will be created." + Environment.NewLine
+ "If <region_file.ini> does not exist, it will be created.",
HandleCreateRegion);
m_console.Commands.AddCommand("region", false, "restart",
"restart",
@@ -513,47 +518,47 @@ namespace OpenSim
/// Creates a new region based on the parameters specified. This will ask the user questions on the console
/// </summary>
/// <param name="module"></param>
/// <param name="cmd">0,1,region name, region XML file</param>
/// <param name="cmd">0,1,region name, region ini or XML file</param>
private void HandleCreateRegion(string module, string[] cmd)
{
if (cmd.Length < 4)
string regionName = string.Empty;
string regionFile = string.Empty;
if (cmd.Length == 3)
{
MainConsole.Instance.Output("Usage: create region <region name> <region_file.ini>");
regionFile = cmd[2];
}
else if (cmd.Length > 3)
{
regionName = cmd[2];
regionFile = cmd[3];
}
string extension = Path.GetExtension(regionFile).ToLower();
bool isXml = extension.Equals(".xml");
bool isIni = extension.Equals(".ini");
if (!isXml && !isIni)
{
MainConsole.Instance.Output("Usage: create region [\"region name\"] <region_file.ini>");
return;
}
if (cmd[3].EndsWith(".xml"))
if (!Path.IsPathRooted(regionFile))
{
string regionsDir = ConfigSource.Source.Configs["Startup"].GetString("regionload_regionsdir", "Regions").Trim();
string regionFile = String.Format("{0}/{1}", regionsDir, cmd[3]);
// Allow absolute and relative specifiers
if (cmd[3].StartsWith("/") || cmd[3].StartsWith("\\") || cmd[3].StartsWith(".."))
regionFile = cmd[3];
IScene scene;
RegionInfo regInfo = new RegionInfo(cmd[2], regionFile, false, ConfigSource.Source);
PopulateRegionEstateInfo(regInfo);
CreateRegion(regInfo, true, out scene);
regInfo.EstateSettings.Save();
regionFile = Path.Combine(regionsDir, regionFile);
}
else if (cmd[3].EndsWith(".ini"))
{
string regionsDir = ConfigSource.Source.Configs["Startup"].GetString("regionload_regionsdir", "Regions").Trim();
string regionFile = String.Format("{0}/{1}", regionsDir, cmd[3]);
// Allow absolute and relative specifiers
if (cmd[3].StartsWith("/") || cmd[3].StartsWith("\\") || cmd[3].StartsWith(".."))
regionFile = cmd[3];
IScene scene;
RegionInfo regInfo = new RegionInfo(cmd[2], regionFile, false, ConfigSource.Source, cmd[2]);
PopulateRegionEstateInfo(regInfo);
CreateRegion(regInfo, true, out scene);
regInfo.EstateSettings.Save();
RegionInfo regInfo;
if (isXml)
{
regInfo = new RegionInfo(regionName, regionFile, false, ConfigSource.Source);
}
else
{
MainConsole.Instance.Output("Usage: create region <region name> <region_file.ini>");
return;
regInfo = new RegionInfo(regionName, regionFile, false, ConfigSource.Source, regionName);
}
IScene scene;
PopulateRegionEstateInfo(regInfo);
CreateRegion(regInfo, true, out scene);
regInfo.EstateSettings.Save();
}
/// <summary>

View File

@@ -109,9 +109,9 @@ namespace OpenSim.Region.CoreModules.Agent.Capabilities
Caps caps
= new Caps(m_scene,
m_scene.AssetService, MainServer.Instance, m_scene.RegionInfo.ExternalHostName,
MainServer.Instance.Port,
(MainServer.Instance == null) ? 0: MainServer.Instance.Port,
capsObjectPath, agentId, m_scene.DumpAssetsToFile, m_scene.RegionInfo.RegionName);
caps.RegisterHandlers();
m_scene.EventManager.TriggerOnRegisterCaps(agentId, caps);
@@ -121,7 +121,7 @@ namespace OpenSim.Region.CoreModules.Agent.Capabilities
caps.TaskScriptUpdatedCall = m_scene.CapsUpdateTaskInventoryScriptAsset;
caps.CAPSFetchInventoryDescendents = m_scene.HandleFetchInventoryDescendentsCAPS;
caps.GetClient = m_scene.SceneContents.GetControllingClient;
m_capsHandlers[agentId] = caps;
}

View File

@@ -1,223 +1,242 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSimulator Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.Collections.Generic;
using System.Reflection;
using log4net;
using Nini.Config;
using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Services.Interfaces;
namespace OpenSim.Region.CoreModules.Avatar.Dialog
{
public class DialogModule : IRegionModule, IDialogModule
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
protected Scene m_scene;
public void Initialise(Scene scene, IConfigSource source)
{
m_scene = scene;
m_scene.RegisterModuleInterface<IDialogModule>(this);
m_scene.AddCommand(
this, "alert", "alert <first> <last> <message>", "Send an alert to a user", HandleAlertConsoleCommand);
m_scene.AddCommand(
this, "alert general", "alert general <message>", "Send an alert to everyone", HandleAlertConsoleCommand);
m_scene.AddCommand(
this, "alert dialog", "alert dialog <message>", "Send a dialog alert to everyone", HandleAlertConsoleCommand);
}
public void PostInitialise() {}
public void Close() {}
public string Name { get { return "Dialog Module"; } }
public bool IsSharedModule { get { return false; } }
public void SendAlertToUser(IClientAPI client, string message)
{
SendAlertToUser(client, message, false);
}
public void SendAlertToUser(IClientAPI client, string message, bool modal)
{
client.SendAgentAlertMessage(message, modal);
}
public void SendAlertToUser(UUID agentID, string message)
{
SendAlertToUser(agentID, message, false);
}
public void SendAlertToUser(UUID agentID, string message, bool modal)
{
ScenePresence sp = m_scene.GetScenePresence(agentID);
if (sp != null)
sp.ControllingClient.SendAgentAlertMessage(message, modal);
}
public void SendAlertToUser(string firstName, string lastName, string message, bool modal)
{
ScenePresence presence = m_scene.GetScenePresence(firstName, lastName);
if (presence != null)
presence.ControllingClient.SendAgentAlertMessage(message, modal);
}
public void SendGeneralAlert(string message)
{
m_scene.ForEachScenePresence(delegate(ScenePresence presence)
{
if (!presence.IsChildAgent)
{
presence.ControllingClient.SendAlertMessage(message);
}
});
}
public void SendDialogToUser(
UUID avatarID, string objectName, UUID objectID, UUID ownerID,
string message, UUID textureID, int ch, string[] buttonlabels)
{
UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, ownerID);
string ownerFirstName, ownerLastName;
if (account != null)
{
ownerFirstName = account.FirstName;
ownerLastName = account.LastName;
}
else
{
ownerFirstName = "(unknown";
ownerLastName = "user)";
}
ScenePresence sp = m_scene.GetScenePresence(avatarID);
if (sp != null)
sp.ControllingClient.SendDialog(objectName, objectID, ownerFirstName, ownerLastName, message, textureID, ch, buttonlabels);
}
public void SendUrlToUser(
UUID avatarID, string objectName, UUID objectID, UUID ownerID, bool groupOwned, string message, string url)
{
ScenePresence sp = m_scene.GetScenePresence(avatarID);
if (sp != null)
sp.ControllingClient.SendLoadURL(objectName, objectID, ownerID, groupOwned, message, url);
}
public void SendTextBoxToUser(UUID avatarid, string message, int chatChannel, string name, UUID objectid, UUID ownerid)
{
UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, ownerid);
string ownerFirstName, ownerLastName;
if (account != null)
{
ownerFirstName = account.FirstName;
ownerLastName = account.LastName;
}
else
{
ownerFirstName = "(unknown";
ownerLastName = "user)";
}
ScenePresence sp = m_scene.GetScenePresence(avatarid);
if (sp != null)
sp.ControllingClient.SendTextBoxRequest(message, chatChannel, name, ownerFirstName, ownerLastName, objectid);
}
public void SendNotificationToUsersInRegion(
UUID fromAvatarID, string fromAvatarName, string message)
{
m_scene.ForEachScenePresence(delegate(ScenePresence presence)
{
if (!presence.IsChildAgent)
presence.ControllingClient.SendBlueBoxMessage(fromAvatarID, fromAvatarName, message);
});
}
/// <summary>
/// Handle an alert command from the console.
/// </summary>
/// <param name="module"></param>
/// <param name="cmdparams"></param>
public void HandleAlertConsoleCommand(string module, string[] cmdparams)
{
if (m_scene.ConsoleScene() != null && m_scene.ConsoleScene() != m_scene)
return;
if (cmdparams[1] == "general")
{
string message = CombineParams(cmdparams, 2);
m_log.InfoFormat(
"[DIALOG]: Sending general alert in region {0} with message {1}", m_scene.RegionInfo.RegionName, message);
SendGeneralAlert(message);
}
else if (cmdparams[1] == "dialog")
{
string message = CombineParams(cmdparams, 2);
m_log.InfoFormat(
"[DIALOG]: Sending dialog alert in region {0} with message {1}", m_scene.RegionInfo.RegionName, message);
SendNotificationToUsersInRegion(UUID.Zero, "System", message);
}
else
{
string firstName = cmdparams[1];
string lastName = cmdparams[2];
string message = CombineParams(cmdparams, 3);
m_log.InfoFormat(
"[DIALOG]: Sending alert in region {0} to {1} {2} with message {3}",
m_scene.RegionInfo.RegionName, firstName, lastName, message);
SendAlertToUser(firstName, lastName, message, false);
}
}
private string CombineParams(string[] commandParams, int pos)
{
string result = string.Empty;
for (int i = pos; i < commandParams.Length; i++)
{
result += commandParams[i] + " ";
}
return result;
}
}
}
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSimulator Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.Collections.Generic;
using System.Reflection;
using log4net;
using Nini.Config;
using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Services.Interfaces;
namespace OpenSim.Region.CoreModules.Avatar.Dialog
{
public class DialogModule : IRegionModule, IDialogModule
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
protected Scene m_scene;
public void Initialise(Scene scene, IConfigSource source)
{
m_scene = scene;
m_scene.RegisterModuleInterface<IDialogModule>(this);
m_scene.AddCommand(
this, "alert", "alert <first> <last> <message>",
"Send an alert to a user",
HandleAlertConsoleCommand);
m_scene.AddCommand(
this, "alert general", "alert [general] <message>",
"Send an alert to everyone",
"If keyword 'general' is omitted, then <message> must be surrounded by quotation marks.",
HandleAlertConsoleCommand);
}
public void PostInitialise() {}
public void Close() {}
public string Name { get { return "Dialog Module"; } }
public bool IsSharedModule { get { return false; } }
public void SendAlertToUser(IClientAPI client, string message)
{
SendAlertToUser(client, message, false);
}
public void SendAlertToUser(IClientAPI client, string message, bool modal)
{
client.SendAgentAlertMessage(message, modal);
}
public void SendAlertToUser(UUID agentID, string message)
{
SendAlertToUser(agentID, message, false);
}
public void SendAlertToUser(UUID agentID, string message, bool modal)
{
ScenePresence sp = m_scene.GetScenePresence(agentID);
if (sp != null)
sp.ControllingClient.SendAgentAlertMessage(message, modal);
}
public void SendAlertToUser(string firstName, string lastName, string message, bool modal)
{
ScenePresence presence = m_scene.GetScenePresence(firstName, lastName);
if (presence != null)
presence.ControllingClient.SendAgentAlertMessage(message, modal);
}
public void SendGeneralAlert(string message)
{
m_scene.ForEachScenePresence(delegate(ScenePresence presence)
{
if (!presence.IsChildAgent)
presence.ControllingClient.SendAlertMessage(message);
});
}
public void SendDialogToUser(
UUID avatarID, string objectName, UUID objectID, UUID ownerID,
string message, UUID textureID, int ch, string[] buttonlabels)
{
UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, ownerID);
string ownerFirstName, ownerLastName;
if (account != null)
{
ownerFirstName = account.FirstName;
ownerLastName = account.LastName;
}
else
{
ownerFirstName = "(unknown";
ownerLastName = "user)";
}
ScenePresence sp = m_scene.GetScenePresence(avatarID);
if (sp != null)
sp.ControllingClient.SendDialog(objectName, objectID, ownerFirstName, ownerLastName, message, textureID, ch, buttonlabels);
}
public void SendUrlToUser(
UUID avatarID, string objectName, UUID objectID, UUID ownerID, bool groupOwned, string message, string url)
{
ScenePresence sp = m_scene.GetScenePresence(avatarID);
if (sp != null)
sp.ControllingClient.SendLoadURL(objectName, objectID, ownerID, groupOwned, message, url);
}
public void SendTextBoxToUser(UUID avatarid, string message, int chatChannel, string name, UUID objectid, UUID ownerid)
{
UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, ownerid);
string ownerFirstName, ownerLastName;
if (account != null)
{
ownerFirstName = account.FirstName;
ownerLastName = account.LastName;
}
else
{
ownerFirstName = "(unknown";
ownerLastName = "user)";
}
ScenePresence sp = m_scene.GetScenePresence(avatarid);
if (sp != null)
sp.ControllingClient.SendTextBoxRequest(message, chatChannel, name, ownerFirstName, ownerLastName, objectid);
}
public void SendNotificationToUsersInRegion(
UUID fromAvatarID, string fromAvatarName, string message)
{
m_scene.ForEachScenePresence(delegate(ScenePresence presence)
{
if (!presence.IsChildAgent)
presence.ControllingClient.SendBlueBoxMessage(fromAvatarID, fromAvatarName, message);
});
}
/// <summary>
/// Handle an alert command from the console.
/// </summary>
/// <param name="module"></param>
/// <param name="cmdparams"></param>
public void HandleAlertConsoleCommand(string module, string[] cmdparams)
{
if (m_scene.ConsoleScene() != null && m_scene.ConsoleScene() != m_scene)
return;
bool isGeneral = false;
string firstName = string.Empty;
string lastName = string.Empty;
string message = string.Empty;
if (cmdparams.Length > 1)
{
firstName = cmdparams[1];
isGeneral = firstName.ToLower().Equals("general");
}
if (cmdparams.Length == 2 && !isGeneral)
{
// alert "message"
message = cmdparams[1];
isGeneral = true;
}
else if (cmdparams.Length > 2 && isGeneral)
{
// alert general <message>
message = CombineParams(cmdparams, 2);
}
else if (cmdparams.Length > 3)
{
// alert <first> <last> <message>
lastName = cmdparams[2];
message = CombineParams(cmdparams, 3);
}
else
{
OpenSim.Framework.Console.MainConsole.Instance.Output(
"Usage: alert \"message\" | alert general <message> | alert <first> <last> <message>");
return;
}
if (isGeneral)
{
m_log.InfoFormat(
"[DIALOG]: Sending general alert in region {0} with message {1}",
m_scene.RegionInfo.RegionName, message);
SendGeneralAlert(message);
}
else
{
m_log.InfoFormat(
"[DIALOG]: Sending alert in region {0} to {1} {2} with message {3}",
m_scene.RegionInfo.RegionName, firstName, lastName, message);
SendAlertToUser(firstName, lastName, message, false);
}
}
private string CombineParams(string[] commandParams, int pos)
{
string result = string.Empty;
for (int i = pos; i < commandParams.Length; i++)
{
result += commandParams[i] + " ";
}
return result;
}
}
}

View File

@@ -100,7 +100,7 @@ namespace OpenSim.Region.CoreModules.InterGrid
bool enabled = false;
IConfig cfg = null;
IConfig httpcfg = null;
IConfig startupcfg = null;
// IConfig startupcfg = null;
try
{
cfg = config.Configs["OpenGridProtocol"];
@@ -117,14 +117,14 @@ namespace OpenSim.Region.CoreModules.InterGrid
{
}
try
{
startupcfg = config.Configs["Startup"];
}
catch (NullReferenceException)
{
}
// try
// {
// startupcfg = config.Configs["Startup"];
// }
// catch (NullReferenceException)
// {
//
// }
// if (startupcfg != null)
// {

View File

@@ -2584,18 +2584,25 @@ namespace OpenSim.Region.Framework.Scenes
/// <param name="client"></param>
public override void AddNewClient(IClientAPI client)
{
AgentCircuitData aCircuit = m_authenticateHandler.GetAgentCircuitData(client.CircuitCode);
bool vialogin = false;
m_clientManager.Add(client);
if (aCircuit == null) // no good, didn't pass NewUserConnection successfully
return;
vialogin = (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0 ||
(aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0;
CheckHeartbeat();
SubscribeToClientEvents(client);
ScenePresence presence;
if (m_restorePresences.ContainsKey(client.AgentId))
{
m_log.DebugFormat("[SCENE]: Restoring agent {0} {1} in {2}", client.Name, client.AgentId, RegionInfo.RegionName);
m_clientManager.Add(client);
SubscribeToClientEvents(client);
presence = m_restorePresences[client.AgentId];
m_restorePresences.Remove(client.AgentId);
@@ -2618,49 +2625,35 @@ namespace OpenSim.Region.Framework.Scenes
}
else
{
AgentCircuitData aCircuit = m_authenticateHandler.GetAgentCircuitData(client.CircuitCode);
// Do the verification here
System.Net.IPEndPoint ep = (System.Net.IPEndPoint)client.GetClientEP();
if (aCircuit != null)
if (GetScenePresence(client.AgentId) == null) // ensure there is no SP here
{
if (!VerifyClient(aCircuit, ep, out vialogin))
m_log.Debug("[SCENE]: Adding new agent " + client.Name + " to scene " + RegionInfo.RegionName);
m_clientManager.Add(client);
SubscribeToClientEvents(client);
ScenePresence sp = CreateAndAddScenePresence(client);
if (aCircuit != null)
sp.Appearance = aCircuit.Appearance;
// HERE!!! Do the initial attachments right here
// first agent upon login is a root agent by design.
// All other AddNewClient calls find aCircuit.child to be true
if (aCircuit == null || (aCircuit != null && aCircuit.child == false))
{
// uh-oh, this is fishy
m_log.WarnFormat("[SCENE]: Agent {0} with session {1} connecting with unidentified end point {2}. Refusing service.",
client.AgentId, client.SessionId, ep.ToString());
try
{
client.Close();
}
catch (Exception e)
{
m_log.DebugFormat("[SCENE]: Exception while closing aborted client: {0}", e.StackTrace);
}
return;
sp.IsChildAgent = false;
Util.FireAndForget(delegate(object o) { sp.RezAttachments(); });
}
}
m_log.Debug("[SCENE]: Adding new agent " + client.Name + " to scene " + RegionInfo.RegionName);
ScenePresence sp = CreateAndAddScenePresence(client);
if (aCircuit != null)
sp.Appearance = aCircuit.Appearance;
// HERE!!! Do the initial attachments right here
// first agent upon login is a root agent by design.
// All other AddNewClient calls find aCircuit.child to be true
if (aCircuit == null || (aCircuit != null && aCircuit.child == false))
{
sp.IsChildAgent = false;
Util.FireAndForget(delegate(object o) { sp.RezAttachments(); });
}
}
m_LastLogin = Util.EnvironmentTickCount();
EventManager.TriggerOnNewClient(client);
if (vialogin)
EventManager.TriggerOnClientLogin(client);
if (GetScenePresence(client.AgentId) != null)
{
m_LastLogin = Util.EnvironmentTickCount();
EventManager.TriggerOnNewClient(client);
if (vialogin)
EventManager.TriggerOnClientLogin(client);
}
}
private bool VerifyClient(AgentCircuitData aCircuit, System.Net.IPEndPoint ep, out bool vialogin)
@@ -2668,16 +2661,14 @@ namespace OpenSim.Region.Framework.Scenes
vialogin = false;
// Do the verification here
if ((aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0)
if ((aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0)
{
m_log.DebugFormat("[SCENE]: Incoming client {0} {1} in region {2} via Login", aCircuit.firstname, aCircuit.lastname, RegionInfo.RegionName);
m_log.DebugFormat("[SCENE]: Incoming client {0} {1} in region {2} via HG login", aCircuit.firstname, aCircuit.lastname, RegionInfo.RegionName);
vialogin = true;
IUserAgentVerificationModule userVerification = RequestModuleInterface<IUserAgentVerificationModule>();
if (userVerification != null && ep != null)
{
System.Net.IPAddress addr = NetworkUtil.GetExternalIPOf(ep.Address);
if (!userVerification.VerifyClient(aCircuit, /*ep.Address.ToString() */ addr.ToString()))
if (!userVerification.VerifyClient(aCircuit, ep.Address.ToString()))
{
// uh-oh, this is fishy
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
}
}
else if ((aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0)
{
m_log.DebugFormat("[SCENE]: Incoming client {0} {1} in region {2} via regular login. Client IP verification not performed.",
aCircuit.firstname, aCircuit.lastname, RegionInfo.RegionName);
vialogin = true;
}
return true;
}
@@ -3343,7 +3341,8 @@ namespace OpenSim.Region.Framework.Scenes
/// also return a reason.</returns>
public bool NewUserConnection(AgentCircuitData agent, uint teleportFlags, out string reason)
{
TeleportFlags tp = (TeleportFlags)teleportFlags;
bool vialogin = ((teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0 ||
(teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0);
reason = String.Empty;
//Teleport flags:
@@ -3380,7 +3379,7 @@ namespace OpenSim.Region.Framework.Scenes
ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y);
//On login test land permisions
if (tp == TeleportFlags.ViaLogin)
if (vialogin)
{
if (land != null && !TestLandRestrictions(agent, land, out reason))
{
@@ -3440,7 +3439,7 @@ namespace OpenSim.Region.Framework.Scenes
agent.teleportFlags = teleportFlags;
m_authenticateHandler.AddNewCircuit(agent.circuitcode, agent);
if (tp == TeleportFlags.ViaLogin)
if (vialogin)
{
if (TestBorderCross(agent.startpos, Cardinals.E))
{
@@ -3561,7 +3560,7 @@ namespace OpenSim.Region.Framework.Scenes
IPresenceService presence = RequestModuleInterface<IPresenceService>();
if (presence == null)
{
reason = String.Format("Failed to verify user {0} {1} in region {2}. Presence service does not exist.", agent.firstname, agent.lastname, RegionInfo.RegionName);
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);
return false;
}
@@ -3569,7 +3568,7 @@ namespace OpenSim.Region.Framework.Scenes
if (pinfo == null)
{
reason = String.Format("Failed to verify user {0} {1}, access denied to region {2}.", agent.firstname, agent.lastname, RegionInfo.RegionName);
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);
return false;
}

View File

@@ -130,11 +130,11 @@ namespace OpenSim.Region.Framework.Scenes.Tests
{
TestHelper.InMethod();
//log4net.Config.XmlConfigurator.Configure();
UUID agentId = UUID.Parse("00000000-0000-0000-0000-000000000001");
TestScene scene = SceneSetupHelpers.SetupScene();
// Turn off the timer on the async sog deleter - we'll crank it by hand for this test.
AsyncSceneObjectGroupDeleter sogd = scene.SceneObjectGroupDeleter;
sogd.Enabled = false;
@@ -147,7 +147,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
SceneObjectPart retrievedPart = scene.GetSceneObjectPart(part.LocalId);
Assert.That(retrievedPart, Is.Not.Null);
sogd.InventoryDeQueueAndDelete();
SceneObjectPart retrievedPart2 = scene.GetSceneObjectPart(part.LocalId);

View File

@@ -104,8 +104,8 @@ namespace OpenSim.Region.Framework.Scenes.Tests
agent.AgentID = agent1;
agent.firstname = firstName;
agent.lastname = "testlastname";
agent.SessionID = UUID.Zero;
agent.SecureSessionID = UUID.Zero;
agent.SessionID = UUID.Random();
agent.SecureSessionID = UUID.Random();
agent.circuitcode = 123;
agent.BaseFolder = UUID.Zero;
agent.InventoryFolder = UUID.Zero;
@@ -114,6 +114,11 @@ namespace OpenSim.Region.Framework.Scenes.Tests
agent.ChildrenCapSeeds = new Dictionary<ulong, string>();
agent.child = true;
if (scene.PresenceService == null)
Console.WriteLine("Presence Service is null");
scene.PresenceService.LoginAgent(agent.AgentID.ToString(), agent.SessionID, agent.SecureSessionID);
string reason;
scene.NewUserConnection(agent, (uint)TeleportFlags.ViaLogin, out reason);
testclient = new TestClient(agent, scene);