Bug fix and cosmetics

Fix: UserAgentServiceConnector return null if the destination is under TLS/SSL.
Refractor: DataSnapshot to use http> UnSecureInstance as @UbitUmarov recommaded. Personally, i prefer it to be under HTTPS as well.
This commit is contained in:
Adil El Farissi
2026-06-04 00:41:25 +00:00
parent ad1d137c2e
commit 9c2cc2d1af
3 changed files with 47 additions and 26 deletions

View File

@@ -120,23 +120,32 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
string[] names = words[0].Split(Util.SplitDotArray);
if (names.Length >= 2)
{
string uriStr = "http://" + words[1];
string uriStr = "http://" + words[1].ToLower();
string SSLuriStr = "https://" + words[1].ToLower();
// Let's check that the last name is a valid address
try
if(!Uri.TryCreate(uriStr, UriKind.Absolute, out _))
{
new Uri(uriStr);
}
catch (UriFormatException)
{
m_log.DebugFormat("[USER MANAGEMENT MODULE]: Malformed address {0}", uriStr);
m_log.DebugFormat("[USER MANAGEMENT MODULE]: Malformed address {0}", words[1].ToLower());
return;
}
}
UUID userID = UUID.Zero;
uriStr = uriStr.ToLower();
if(!WebUtil.GlobalExpiringBadURLs.ContainsKey(uriStr))
if(!WebUtil.GlobalExpiringBadURLs.ContainsKey(uriStr) || !WebUtil.GlobalExpiringBadURLs.ContainsKey(SSLuriStr))
{
UserAgentServiceConnector uasConn = new UserAgentServiceConnector(uriStr);
UserAgentServiceConnector uasConn = new(uriStr);
// If fail to connect with http... try with https...
if (uasConn is null)
{
uasConn = new UserAgentServiceConnector(SSLuriStr);
if (uasConn is null)
{
m_log.DebugFormat("[USER MANAGEMENT MODULE]: UserAgentServiceConnector failed to connect to {0}", words[1].ToLower());
return;
}
uriStr = SSLuriStr;
}
try
{
userID = uasConn.GetUUID(names[0], names[1]);
@@ -149,10 +158,12 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
if (!userID.Equals(UUID.Zero))
{
UserData ud = new UserData();
ud.Id = userID;
ud.FirstName = words[0];
ud.LastName = "@" + words[1];
UserData ud = new()
{
Id = userID,
FirstName = words[0],
LastName = "@" + words[1]
};
users.Add(ud);
AddUser(userID, names[0], names[1], uriStr);
m_log.DebugFormat("[USER MANAGEMENT MODULE]: User {0}@{1} found", words[0], words[1]);

View File

@@ -52,9 +52,9 @@ namespace OpenSim.Region.DataSnapshot
m_externalData = externalData;
//Register HTTP handler
MainServer.Instance.AddGloblaMethodHandler("collector", OnGetSnapshot);
MainServer.UnSecureInstance.AddGloblaMethodHandler("collector", OnGetSnapshot);
// Register validation callback handler
MainServer.Instance.AddGloblaMethodHandler("validate", OnValidate);
MainServer.UnSecureInstance.AddGloblaMethodHandler("validate", OnValidate);
m_log.Info("[DATASNAPSHOT]: Set up snapshot service");
}

View File

@@ -316,22 +316,32 @@ namespace OpenSim.Services.HypergridService
if (parts.Length != 2)
return;
string uriStr = "http://" + parts[1];
try
{
new Uri(uriStr);
}
catch (UriFormatException)
string uriStr = "http://" + parts[1].ToLower();
string SSLuriStr = "https://" + parts[1].ToLower();
if(!Uri.TryCreate(uriStr, UriKind.Absolute, out _))
{
m_log.DebugFormat("[HGFRIENDS SERVICE]: Malformed address {0}", parts[1].ToLower());
return;
}
UserAgentServiceConnector uasConn = new UserAgentServiceConnector(uriStr);
UserAgentServiceConnector uasConn = new(uriStr);
// If fail to connect with http... try with https...
if (uasConn is null)
{
uasConn = new UserAgentServiceConnector(SSLuriStr);
if (uasConn is null)
{
m_log.DebugFormat("[HGFRIENDS SERVICE]: UserAgentServiceConnector failed to connect to {0}", parts[1].ToLower());
return;
}
uriStr = SSLuriStr;
}
Dictionary<string, object> servers = uasConn.GetServerURLs(fromID);
if (!servers.ContainsKey("FriendsServerURI"))
if (!servers.TryGetValue("FriendsServerURI", out object friendsServerURI))
return;
HGFriendsServicesConnector friendsConn = new HGFriendsServicesConnector(servers["FriendsServerURI"].ToString());
HGFriendsServicesConnector friendsConn = new(friendsServerURI.ToString());
if (!friendsConn.ValidateFriendshipOffered(fromID, toID))
{
m_log.WarnFormat("[HGFRIENDS SERVICE]: Friendship request from {0} to {1} is invalid. Impersonations?", fromID, toID);