Get the full viewer name even if it's (incorrectly) sent in the 'Channel' field

Recent versions of Firestorm and Singularity have started sending the viewer name in the 'Channel' field, leaving only their version number in the 'Viewer' field. So we need to search both of these fields for the viewer name.

This resolves http://opensimulator.org/mantis/view.php?id=6952
0.8.0.3
Oren Hurvitz 2013-12-08 16:50:24 +02:00
parent 6734b94761
commit 921f0052f4
6 changed files with 48 additions and 13 deletions

View File

@ -2288,6 +2288,38 @@ namespace OpenSim.Framework
{
return str.Replace("_", "\\_").Replace("%", "\\%");
}
/// <summary>
/// Returns the name of the user's viewer.
/// </summary>
/// <remarks>
/// This method handles two ways that viewers specify their name:
/// 1. Viewer = "Firestorm-Release 4.4.2.34167", Channel = "(don't care)" -> "Firestorm-Release 4.4.2.34167"
/// 2. Viewer = "4.5.1.38838", Channel = "Firestorm-Beta" -> "Firestorm-Beta 4.5.1.38838"
/// </remarks>
public static string GetViewerName(AgentCircuitData agent)
{
string name = agent.Viewer;
if (name == null)
name = "";
else
name = name.Trim();
// Check if 'Viewer' is just a version number. If it's *not*, then we
// assume that it contains the real viewer name, and we return it.
foreach (char c in name)
{
if (Char.IsLetter(c))
return name;
}
// The 'Viewer' string contains just a version number. If there's anything in
// 'Channel' then assume that it's the viewer name.
if ((agent.Channel != null) && (agent.Channel.Length > 0))
name = agent.Channel.Trim() + " " + name;
return name;
}
}
public class DoubleQueue<T> where T:class

View File

@ -982,7 +982,7 @@ namespace OpenSim
aCircuit.child ? "child" : "root",
aCircuit.circuitcode.ToString(),
aCircuit.IPAddress != null ? aCircuit.IPAddress.ToString() : "not set",
aCircuit.Viewer);
Util.GetViewerName(aCircuit));
});
MainConsole.Instance.Output(cdt.ToString());

View File

@ -3413,6 +3413,7 @@ namespace OpenSim.Region.Framework.Scenes
// TeleportFlags.ViaLandmark | TeleportFlags.ViaLocation | TeleportFlags.ViaLandmark | TeleportFlags.Default - Regular Teleport
// Don't disable this log message - it's too helpful
string curViewer = Util.GetViewerName(acd);
m_log.DebugFormat(
"[SCENE]: Region {0} told of incoming {1} agent {2} {3} {4} (circuit code {5}, IP {6}, viewer {7}, teleportflags ({8}), position {9})",
RegionInfo.RegionName,
@ -3422,7 +3423,7 @@ namespace OpenSim.Region.Framework.Scenes
acd.AgentID,
acd.circuitcode,
acd.IPAddress,
acd.Viewer,
curViewer,
((TPFlags)teleportFlags).ToString(),
acd.startpos
);
@ -3442,7 +3443,7 @@ namespace OpenSim.Region.Framework.Scenes
{
foreach (string viewer in m_AllowedViewers)
{
if (viewer == acd.Viewer.Substring(0, viewer.Length).Trim().ToLower())
if (viewer == curViewer.Substring(0, viewer.Length).Trim().ToLower())
{
ViewerDenied = false;
break;
@ -3459,7 +3460,7 @@ namespace OpenSim.Region.Framework.Scenes
{
foreach (string viewer in m_BannedViewers)
{
if (viewer == acd.Viewer.Substring(0, viewer.Length).Trim().ToLower())
if (viewer == curViewer.Substring(0, viewer.Length).Trim().ToLower())
{
ViewerDenied = true;
break;
@ -3471,7 +3472,7 @@ namespace OpenSim.Region.Framework.Scenes
{
m_log.DebugFormat(
"[SCENE]: Access denied for {0} {1} using {2}",
acd.firstname, acd.lastname, acd.Viewer);
acd.firstname, acd.lastname, curViewer);
reason = "Access denied, your viewer is banned by the region owner";
return false;
}

View File

@ -848,7 +848,7 @@ namespace OpenSim.Region.Framework.Scenes
public string Viewer
{
get { return m_scene.AuthenticateHandler.GetAgentCircuitData(ControllingClient.CircuitCode).Viewer; }
get { return Util.GetViewerName(m_scene.AuthenticateHandler.GetAgentCircuitData(ControllingClient.CircuitCode)); }
}
#endregion

View File

@ -669,7 +669,7 @@ namespace OpenSim.Region.OptionalModules.UDP.Linden
aCircuit = new AgentCircuitData();
if (!llClient.SceneAgent.IsChildAgent)
m_log.InfoFormat("[INFO]: {0} # {1} # {2}", llClient.Name, aCircuit.Viewer, aCircuit.Id0);
m_log.InfoFormat("[INFO]: {0} # {1} # {2}", llClient.Name, Util.GetViewerName(aCircuit), aCircuit.Id0);
int avg_reqs = cinfo.AsyncRequests.Values.Sum() + cinfo.GenericRequests.Values.Sum() + cinfo.SyncRequests.Values.Sum();
avg_reqs = avg_reqs / ((DateTime.Now - cinfo.StartedTime).Minutes + 1);
@ -706,4 +706,4 @@ namespace OpenSim.Region.OptionalModules.UDP.Linden
m_log.InfoFormat("[INFO]: {0,25} {1,-6}", "Total", sum);
}
}
}
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
@ -228,17 +228,19 @@ namespace OpenSim.Services.HypergridService
aCircuit.firstname, aCircuit.lastname, authURL, aCircuit.AgentID, destination.RegionName,
aCircuit.Viewer, aCircuit.Channel, aCircuit.IPAddress, aCircuit.Mac, aCircuit.Id0, aCircuit.teleportFlags.ToString());
string curViewer = Util.GetViewerName(aCircuit);
//
// Check client
//
if (m_AllowedClients != string.Empty)
{
Regex arx = new Regex(m_AllowedClients);
Match am = arx.Match(aCircuit.Viewer);
Match am = arx.Match(curViewer);
if (!am.Success)
{
m_log.InfoFormat("[GATEKEEPER SERVICE]: Login failed, reason: client {0} is not allowed", aCircuit.Viewer);
m_log.InfoFormat("[GATEKEEPER SERVICE]: Login failed, reason: client {0} is not allowed", curViewer);
return false;
}
}
@ -246,11 +248,11 @@ namespace OpenSim.Services.HypergridService
if (m_DeniedClients != string.Empty)
{
Regex drx = new Regex(m_DeniedClients);
Match dm = drx.Match(aCircuit.Viewer);
Match dm = drx.Match(curViewer);
if (dm.Success)
{
m_log.InfoFormat("[GATEKEEPER SERVICE]: Login failed, reason: client {0} is denied", aCircuit.Viewer);
m_log.InfoFormat("[GATEKEEPER SERVICE]: Login failed, reason: client {0} is denied", curViewer);
return false;
}
}