enabled a config option to inventory server to be able to stop it doing the SessionId lookup to the user server. As this ties a inventory server to one userserver/grid.

doing the look up is still enabled by default.
0.6.0-stable
MW 2008-07-25 17:59:34 +00:00
parent d954f46a0a
commit a7db55717b
3 changed files with 57 additions and 27 deletions

View File

@ -44,6 +44,7 @@ namespace OpenSim.Framework
public string UserRecvKey = String.Empty; public string UserRecvKey = String.Empty;
public string UserSendKey = String.Empty; public string UserSendKey = String.Empty;
public string UserServerURL = String.Empty; public string UserServerURL = String.Empty;
public bool SessionLookUp = true;
public InventoryConfig(string description, string filename) public InventoryConfig(string description, string filename)
{ {
@ -71,6 +72,8 @@ namespace OpenSim.Framework
"Database Connect String", "", false); "Database Connect String", "", false);
configMember.addConfigurationOption("http_port", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, configMember.addConfigurationOption("http_port", ConfigurationOption.ConfigurationTypes.TYPE_UINT32,
"Http Listener port", DefaultHttpPort.ToString(), false); "Http Listener port", DefaultHttpPort.ToString(), false);
configMember.addConfigurationOption("session_lookup", ConfigurationOption.ConfigurationTypes.TYPE_BOOLEAN,
"Enable Session lookup security", "True", false);
} }
public bool handleIncomingConfiguration(string configuration_key, object configuration_result) public bool handleIncomingConfiguration(string configuration_key, object configuration_result)
@ -98,6 +101,9 @@ namespace OpenSim.Framework
case "http_port": case "http_port":
HttpPort = (uint) configuration_result; HttpPort = (uint) configuration_result;
break; break;
case "session_lookup":
SessionLookUp = (bool)configuration_result;
break;
} }
return true; return true;

View File

@ -47,6 +47,13 @@ namespace OpenSim.Grid.InventoryServer
/// </summary> /// </summary>
public class GridInventoryService : InventoryServiceBase public class GridInventoryService : InventoryServiceBase
{ {
private bool m_doLookup = false;
public bool DoLookup
{
get { return m_doLookup; }
set { m_doLookup = value; }
}
private static readonly ILog m_log private static readonly ILog m_log
= LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private static readonly int INVENTORY_DEFAULT_SESSION_TIME = 30; // secs private static readonly int INVENTORY_DEFAULT_SESSION_TIME = 30; // secs
@ -61,48 +68,64 @@ namespace OpenSim.Grid.InventoryServer
public bool CheckTrustSource(IPEndPoint peer) public bool CheckTrustSource(IPEndPoint peer)
{ {
m_log.InfoFormat("[GRID AGENT INVENTORY]: checking trusted source {0}", peer.ToString()); if (m_doLookup)
UriBuilder ub = new UriBuilder(m_userserver_url); {
IPAddress[] uaddrs = Dns.GetHostAddresses(ub.Host); m_log.InfoFormat("[GRID AGENT INVENTORY]: checking trusted source {0}", peer.ToString());
foreach (IPAddress uaddr in uaddrs) { UriBuilder ub = new UriBuilder(m_userserver_url);
if (uaddr.Equals(peer.Address)) { IPAddress[] uaddrs = Dns.GetHostAddresses(ub.Host);
return true; foreach (IPAddress uaddr in uaddrs)
{
if (uaddr.Equals(peer.Address))
{
return true;
}
} }
return false;
}
else
{
return true;
} }
return false;
} }
public bool CheckAuthSession(string session_id, string avatar_id) public bool CheckAuthSession(string session_id, string avatar_id)
{ {
m_log.InfoFormat("[GRID AGENT INVENTORY]: checking authed session {0} {1}", session_id, avatar_id); if (m_doLookup)
if (m_session_cache.getCachedSession(session_id, avatar_id) == null)
{ {
// cache miss, ask userserver m_log.InfoFormat("[GRID AGENT INVENTORY]: checking authed session {0} {1}", session_id, avatar_id);
Hashtable requestData = new Hashtable(); if (m_session_cache.getCachedSession(session_id, avatar_id) == null)
requestData["avatar_uuid"] = avatar_id;
requestData["session_id"] = session_id;
ArrayList SendParams = new ArrayList();
SendParams.Add(requestData);
XmlRpcRequest UserReq = new XmlRpcRequest("check_auth_session", SendParams);
XmlRpcResponse UserResp = UserReq.Send(m_userserver_url, 3000);
Hashtable responseData = (Hashtable)UserResp.Value;
if (responseData.ContainsKey("auth_session") && responseData["auth_session"].ToString() == "TRUE")
{ {
m_log.Info("[GRID AGENT INVENTORY]: got authed session from userserver"); // cache miss, ask userserver
// add to cache; the session time will be automatically renewed Hashtable requestData = new Hashtable();
m_session_cache.Add(session_id, avatar_id); requestData["avatar_uuid"] = avatar_id;
requestData["session_id"] = session_id;
ArrayList SendParams = new ArrayList();
SendParams.Add(requestData);
XmlRpcRequest UserReq = new XmlRpcRequest("check_auth_session", SendParams);
XmlRpcResponse UserResp = UserReq.Send(m_userserver_url, 3000);
Hashtable responseData = (Hashtable)UserResp.Value;
if (responseData.ContainsKey("auth_session") && responseData["auth_session"].ToString() == "TRUE")
{
m_log.Info("[GRID AGENT INVENTORY]: got authed session from userserver");
// add to cache; the session time will be automatically renewed
m_session_cache.Add(session_id, avatar_id);
return true;
}
}
else
{
// cache hits
m_log.Info("[GRID AGENT INVENTORY]: got authed session from cache");
return true; return true;
} }
m_log.Info("[GRID AGENT INVENTORY]: unknown session_id, request rejected");
return false;
} }
else else
{ {
// cache hits
m_log.Info("[GRID AGENT INVENTORY]: got authed session from cache");
return true; return true;
} }
m_log.Info("[GRID AGENT INVENTORY]: unknown session_id, request rejected");
return false;
} }
public override void RequestInventoryForUser(LLUUID userID, InventoryReceiptCallback callback) public override void RequestInventoryForUser(LLUUID userID, InventoryReceiptCallback callback)

View File

@ -72,6 +72,7 @@ namespace OpenSim.Grid.InventoryServer
//m_inventoryService = new GridInventoryService(); //m_inventoryService = new GridInventoryService();
m_inventoryService = new GridInventoryService(m_config.UserServerURL); m_inventoryService = new GridInventoryService(m_config.UserServerURL);
m_inventoryService.DoLookup = m_config.SessionLookUp;
m_inventoryService.AddPlugin(m_config.DatabaseProvider, m_config.DatabaseConnect); m_inventoryService.AddPlugin(m_config.DatabaseProvider, m_config.DatabaseConnect);
m_log.Info("[" + LogName + "]: Starting HTTP server ..."); m_log.Info("[" + LogName + "]: Starting HTTP server ...");