aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/DataSnapshot/DataRequestHandler.cs52
-rw-r--r--OpenSim/Region/DataSnapshot/DataSnapshotManager.cs9
2 files changed, 28 insertions, 33 deletions
diff --git a/OpenSim/Region/DataSnapshot/DataRequestHandler.cs b/OpenSim/Region/DataSnapshot/DataRequestHandler.cs
index 93648d6..2f2b3e6 100644
--- a/OpenSim/Region/DataSnapshot/DataRequestHandler.cs
+++ b/OpenSim/Region/DataSnapshot/DataRequestHandler.cs
@@ -46,8 +46,6 @@ namespace OpenSim.Region.DataSnapshot
46 private DataSnapshotManager m_externalData = null; 46 private DataSnapshotManager m_externalData = null;
47 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 47 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
48 48
49 private readonly string m_discoveryPath = "DS0001/";
50
51 public DataRequestHandler(Scene scene, DataSnapshotManager externalData) 49 public DataRequestHandler(Scene scene, DataSnapshotManager externalData)
52 { 50 {
53 m_scene = scene; 51 m_scene = scene;
@@ -58,37 +56,9 @@ namespace OpenSim.Region.DataSnapshot
58 { 56 {
59 m_log.Info("[DATASNAPSHOT]: Set up snapshot service"); 57 m_log.Info("[DATASNAPSHOT]: Set up snapshot service");
60 } 58 }
59 // Register validation callback handler
60 MainServer.Instance.AddHTTPHandler("validate", OnValidate);
61 61
62 //Register CAPS handler event
63 m_scene.EventManager.OnRegisterCaps += OnRegisterCaps;
64
65 //harbl
66 }
67
68 public void OnRegisterCaps(UUID agentID, Caps caps)
69 {
70// m_log.InfoFormat("[DATASNAPSHOT]: Registering service discovery capability for {0}", agentID);
71 string capsBase = "/CAPS/" + caps.CapsObjectPath;
72 caps.RegisterHandler("PublicSnapshotDataInfo",
73 new RestStreamHandler("POST", capsBase + m_discoveryPath, OnDiscoveryAttempt));
74 }
75
76 public string OnDiscoveryAttempt(string request, string path, string param,
77 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
78 {
79 //Very static for now, flexible enough to add new formats
80 LLSDDiscoveryResponse llsd_response = new LLSDDiscoveryResponse();
81 llsd_response.snapshot_resources = new OSDArray();
82
83 LLSDDiscoveryDataURL llsd_dataurl = new LLSDDiscoveryDataURL();
84 llsd_dataurl.snapshot_format = "os-datasnapshot-v1";
85 llsd_dataurl.snapshot_url = "http://" + m_externalData.m_hostname + ":" + m_externalData.m_listener_port + "/?method=collector";
86
87 llsd_response.snapshot_resources.Array.Add(llsd_dataurl);
88
89 string response = LLSDHelpers.SerialiseLLSDReply(llsd_response);
90
91 return response;
92 } 62 }
93 63
94 public Hashtable OnGetSnapshot(Hashtable keysvals) 64 public Hashtable OnGetSnapshot(Hashtable keysvals)
@@ -107,5 +77,23 @@ namespace OpenSim.Region.DataSnapshot
107 77
108 return reply; 78 return reply;
109 } 79 }
80
81 public Hashtable OnValidate(Hashtable keysvals)
82 {
83 m_log.Info("[DATASNAPSHOT] Received validation request");
84 Hashtable reply = new Hashtable();
85 int statuscode = 200;
86
87 string secret = (string)keysvals["secret"];
88 if (secret == m_externalData.Secret.ToString())
89 statuscode = 403;
90
91 reply["str_response_string"] = string.Empty;
92 reply["int_response_code"] = statuscode;
93 reply["content_type"] = "text/plain";
94
95 return reply;
96 }
97
110 } 98 }
111} 99}
diff --git a/OpenSim/Region/DataSnapshot/DataSnapshotManager.cs b/OpenSim/Region/DataSnapshot/DataSnapshotManager.cs
index 209fb52..5540656 100644
--- a/OpenSim/Region/DataSnapshot/DataSnapshotManager.cs
+++ b/OpenSim/Region/DataSnapshot/DataSnapshotManager.cs
@@ -66,6 +66,7 @@ namespace OpenSim.Region.DataSnapshot
66 private string m_dataServices = "noservices"; 66 private string m_dataServices = "noservices";
67 public string m_listener_port = ConfigSettings.DefaultRegionHttpPort.ToString(); 67 public string m_listener_port = ConfigSettings.DefaultRegionHttpPort.ToString();
68 public string m_hostname = "127.0.0.1"; 68 public string m_hostname = "127.0.0.1";
69 private UUID m_Secret = UUID.Random();
69 70
70 //Update timers 71 //Update timers
71 private int m_period = 20; // in seconds 72 private int m_period = 20; // in seconds
@@ -85,6 +86,11 @@ namespace OpenSim.Region.DataSnapshot
85 get { return m_exposure_level; } 86 get { return m_exposure_level; }
86 } 87 }
87 88
89 public UUID Secret
90 {
91 get { return m_Secret; }
92 }
93
88 #endregion 94 #endregion
89 95
90 #region IRegionModule 96 #region IRegionModule
@@ -315,6 +321,7 @@ namespace OpenSim.Region.DataSnapshot
315 cli.AddQueryParameter("service", serviceName); 321 cli.AddQueryParameter("service", serviceName);
316 cli.AddQueryParameter("host", m_hostname); 322 cli.AddQueryParameter("host", m_hostname);
317 cli.AddQueryParameter("port", m_listener_port); 323 cli.AddQueryParameter("port", m_listener_port);
324 cli.AddQueryParameter("secret", m_Secret.ToString());
318 cli.RequestMethod = "GET"; 325 cli.RequestMethod = "GET";
319 try 326 try
320 { 327 {
@@ -341,7 +348,7 @@ namespace OpenSim.Region.DataSnapshot
341 } 348 }
342 // This is not quite working, so... 349 // This is not quite working, so...
343 // string responseStr = Util.UTF8.GetString(response); 350 // string responseStr = Util.UTF8.GetString(response);
344 m_log.Info("[DATASNAPSHOT]: data service notified: " + url); 351 m_log.Info("[DATASNAPSHOT]: data service " + url + " notified. Secret: " + m_Secret);
345 } 352 }
346 353
347 } 354 }