Datasnapshot: added "secret" to the registration/deregistration query so that data providers can verify authenticity if they want.
parent
881740d702
commit
3e88fc8aad
|
@ -46,8 +46,6 @@ namespace OpenSim.Region.DataSnapshot
|
||||||
private DataSnapshotManager m_externalData = null;
|
private DataSnapshotManager m_externalData = null;
|
||||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
|
||||||
private readonly string m_discoveryPath = "DS0001/";
|
|
||||||
|
|
||||||
public DataRequestHandler(Scene scene, DataSnapshotManager externalData)
|
public DataRequestHandler(Scene scene, DataSnapshotManager externalData)
|
||||||
{
|
{
|
||||||
m_scene = scene;
|
m_scene = scene;
|
||||||
|
@ -58,37 +56,9 @@ namespace OpenSim.Region.DataSnapshot
|
||||||
{
|
{
|
||||||
m_log.Info("[DATASNAPSHOT]: Set up snapshot service");
|
m_log.Info("[DATASNAPSHOT]: Set up snapshot service");
|
||||||
}
|
}
|
||||||
|
// Register validation callback handler
|
||||||
|
MainServer.Instance.AddHTTPHandler("validate", OnValidate);
|
||||||
|
|
||||||
//Register CAPS handler event
|
|
||||||
m_scene.EventManager.OnRegisterCaps += OnRegisterCaps;
|
|
||||||
|
|
||||||
//harbl
|
|
||||||
}
|
|
||||||
|
|
||||||
public void OnRegisterCaps(UUID agentID, Caps caps)
|
|
||||||
{
|
|
||||||
// m_log.InfoFormat("[DATASNAPSHOT]: Registering service discovery capability for {0}", agentID);
|
|
||||||
string capsBase = "/CAPS/" + caps.CapsObjectPath;
|
|
||||||
caps.RegisterHandler("PublicSnapshotDataInfo",
|
|
||||||
new RestStreamHandler("POST", capsBase + m_discoveryPath, OnDiscoveryAttempt));
|
|
||||||
}
|
|
||||||
|
|
||||||
public string OnDiscoveryAttempt(string request, string path, string param,
|
|
||||||
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
|
|
||||||
{
|
|
||||||
//Very static for now, flexible enough to add new formats
|
|
||||||
LLSDDiscoveryResponse llsd_response = new LLSDDiscoveryResponse();
|
|
||||||
llsd_response.snapshot_resources = new OSDArray();
|
|
||||||
|
|
||||||
LLSDDiscoveryDataURL llsd_dataurl = new LLSDDiscoveryDataURL();
|
|
||||||
llsd_dataurl.snapshot_format = "os-datasnapshot-v1";
|
|
||||||
llsd_dataurl.snapshot_url = "http://" + m_externalData.m_hostname + ":" + m_externalData.m_listener_port + "/?method=collector";
|
|
||||||
|
|
||||||
llsd_response.snapshot_resources.Array.Add(llsd_dataurl);
|
|
||||||
|
|
||||||
string response = LLSDHelpers.SerialiseLLSDReply(llsd_response);
|
|
||||||
|
|
||||||
return response;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Hashtable OnGetSnapshot(Hashtable keysvals)
|
public Hashtable OnGetSnapshot(Hashtable keysvals)
|
||||||
|
@ -107,5 +77,23 @@ namespace OpenSim.Region.DataSnapshot
|
||||||
|
|
||||||
return reply;
|
return reply;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Hashtable OnValidate(Hashtable keysvals)
|
||||||
|
{
|
||||||
|
m_log.Info("[DATASNAPSHOT] Received validation request");
|
||||||
|
Hashtable reply = new Hashtable();
|
||||||
|
int statuscode = 200;
|
||||||
|
|
||||||
|
string secret = (string)keysvals["secret"];
|
||||||
|
if (secret == m_externalData.Secret.ToString())
|
||||||
|
statuscode = 403;
|
||||||
|
|
||||||
|
reply["str_response_string"] = string.Empty;
|
||||||
|
reply["int_response_code"] = statuscode;
|
||||||
|
reply["content_type"] = "text/plain";
|
||||||
|
|
||||||
|
return reply;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,6 +66,7 @@ namespace OpenSim.Region.DataSnapshot
|
||||||
private string m_dataServices = "noservices";
|
private string m_dataServices = "noservices";
|
||||||
public string m_listener_port = ConfigSettings.DefaultRegionHttpPort.ToString();
|
public string m_listener_port = ConfigSettings.DefaultRegionHttpPort.ToString();
|
||||||
public string m_hostname = "127.0.0.1";
|
public string m_hostname = "127.0.0.1";
|
||||||
|
private UUID m_Secret = UUID.Random();
|
||||||
|
|
||||||
//Update timers
|
//Update timers
|
||||||
private int m_period = 20; // in seconds
|
private int m_period = 20; // in seconds
|
||||||
|
@ -85,6 +86,11 @@ namespace OpenSim.Region.DataSnapshot
|
||||||
get { return m_exposure_level; }
|
get { return m_exposure_level; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public UUID Secret
|
||||||
|
{
|
||||||
|
get { return m_Secret; }
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region IRegionModule
|
#region IRegionModule
|
||||||
|
@ -315,6 +321,7 @@ namespace OpenSim.Region.DataSnapshot
|
||||||
cli.AddQueryParameter("service", serviceName);
|
cli.AddQueryParameter("service", serviceName);
|
||||||
cli.AddQueryParameter("host", m_hostname);
|
cli.AddQueryParameter("host", m_hostname);
|
||||||
cli.AddQueryParameter("port", m_listener_port);
|
cli.AddQueryParameter("port", m_listener_port);
|
||||||
|
cli.AddQueryParameter("secret", m_Secret.ToString());
|
||||||
cli.RequestMethod = "GET";
|
cli.RequestMethod = "GET";
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -341,7 +348,7 @@ namespace OpenSim.Region.DataSnapshot
|
||||||
}
|
}
|
||||||
// This is not quite working, so...
|
// This is not quite working, so...
|
||||||
// string responseStr = Util.UTF8.GetString(response);
|
// string responseStr = Util.UTF8.GetString(response);
|
||||||
m_log.Info("[DATASNAPSHOT]: data service notified: " + url);
|
m_log.Info("[DATASNAPSHOT]: data service " + url + " notified. Secret: " + m_Secret);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue