public void RegisterPollHandler(string capName, PollServiceEventArgs pollServiceHandler) { // m_log.DebugFormat( // "[CAPS]: Registering handler with name {0}, url {1} for {2}", // capName, pollServiceHandler.Url, m_agentID, m_regionName); if (!m_pollServiceHandlers.TryAdd(capName, pollServiceHandler)) { m_log.ErrorFormat( "[CAPS]: Handler with name {0} already registered (ulr {1}, agent {2}, region {3}", capName, pollServiceHandler.Url, m_agentID, m_regionName); return; } m_httpListener.AddPollServiceHTTPHandler(pollServiceHandler); // uint port = (MainServer.Instance == null) ? 0 : MainServer.Instance.Port; // string protocol = "http"; // string hostName = m_httpListenerHostName; // // if (MainServer.Instance.UseSSL) // { // hostName = MainServer.Instance.SSLCommonName; // port = MainServer.Instance.SSLPort; // protocol = "https"; // } // RegisterHandler( // capName, String.Format("{0}://{1}:{2}{3}", protocol, hostName, port, pollServiceHandler.Url)); }
public UUID RequestSecureURL(IScriptModule engine, SceneObjectPart host, UUID itemID, Hashtable options) { UUID urlcode = UUID.Random(); if (!m_enabled) { engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_DENIED", m_ErrorStr }); return(urlcode); } if (m_HttpsServer == null) { engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_DENIED", "" }); return(urlcode); } lock (m_UrlMap) { if (m_UrlMap.Count >= TotalUrls) { engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_DENIED", "Too many URLs already open" }); return(urlcode); } string url = "https://" + ExternalHostNameForLSL + ":" + m_HttpsServer.Port.ToString() + "/lslhttps/" + urlcode.ToString() + "/"; UrlData urlData = new UrlData(); urlData.hostID = host.UUID; urlData.itemID = itemID; urlData.engine = engine; urlData.url = url; urlData.urlcode = urlcode; urlData.isSsl = true; urlData.requests = new Dictionary <UUID, RequestData>(); urlData.allowXss = false; if (options != null && options["allowXss"] != null) { urlData.allowXss = true; } m_UrlMap[url] = urlData; string uri = "/lslhttps/" + urlcode.ToString(); PollServiceEventArgs args = new PollServiceEventArgs(HttpRequestHandler, uri, HasEvents, GetEvents, NoEvents, Drop, urlcode, 25000); //args.Type = PollServiceEventArgs.EventType.LslHttp; m_HttpsServer.AddPollServiceHTTPHandler(args); // m_log.DebugFormat( // "[URL MODULE]: Set up incoming secure request url {0} for {1} in {2} {3}", // uri, itemID, host.Name, host.LocalId); engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_GRANTED", url }); } return(urlcode); }
private void BuildDetailedStatsByCapReport(StringBuilder sb, string capName) { sb.AppendFormat("Capability name {0}\n", capName); ConsoleDisplayTable cdt = new ConsoleDisplayTable(); cdt.AddColumn("User Name", 34); cdt.AddColumn("Req Received", 12); cdt.AddColumn("Req Handled", 12); cdt.Indent = 2; Dictionary <string, int> receivedStats = new Dictionary <string, int>(); Dictionary <string, int> handledStats = new Dictionary <string, int>(); m_scene.ForEachScenePresence( sp => { Caps caps = m_scene.CapsModule.GetCapsForUser(sp.UUID); if (caps == null) { return; } Dictionary <string, IRequestHandler> capsHandlers = caps.CapsHandlers.GetCapsHandlers(); IRequestHandler reqHandler; if (capsHandlers.TryGetValue(capName, out reqHandler)) { receivedStats[sp.Name] = reqHandler.RequestsReceived; handledStats[sp.Name] = reqHandler.RequestsHandled; } else { PollServiceEventArgs pollHandler = null; if (caps.TryGetPollHandler(capName, out pollHandler)) { receivedStats[sp.Name] = pollHandler.RequestsReceived; handledStats[sp.Name] = pollHandler.RequestsHandled; } } } ); foreach (KeyValuePair <string, int> kvp in receivedStats.OrderByDescending(kp => kp.Value)) { cdt.AddRow(kvp.Key, kvp.Value, handledStats[kvp.Key]); } sb.Append(cdt.ToString()); }
public UUID RequestSecureURL(IScriptModule engine, SceneObjectPart host, UUID itemID) { UUID urlcode = UUID.Random(); if (m_HttpsServer == null) { engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_DENIED", "" }); return(urlcode); } lock (m_UrlMap) /* this lock here is for preventing concurrency when checking for Url amount */ { if (m_UrlMap.Count >= TotalUrls) { engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_DENIED", "" }); return(urlcode); } string url = "https://" + ExternalHostNameForLSL + ":" + m_HttpsServer.Port.ToString() + "/lslhttps/" + urlcode.ToString() + "/"; UrlData urlData = new UrlData(); urlData.hostID = host.UUID; urlData.itemID = itemID; urlData.engine = engine; urlData.url = url; urlData.urlcode = urlcode; urlData.requests = new ThreadedClasses.RwLockedDictionary <UUID, RequestData>(); m_UrlMap[url] = urlData; string uri = "/lslhttps/" + urlcode.ToString() + "/"; PollServiceEventArgs args = new PollServiceEventArgs(HttpRequestHandler, uri, HasEvents, GetEvents, NoEvents, urlcode, 25000); args.Type = PollServiceEventArgs.EventType.LslHttp; m_HttpsServer.AddPollServiceHTTPHandler(uri, args); m_log.DebugFormat( "[URL MODULE]: Set up incoming secure request url {0} for {1} in {2} {3}", uri, itemID, host.Name, host.LocalId); engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_GRANTED", url }); } return(urlcode); }
public void RegisterPollHandler(string capName, PollServiceEventArgs pollServiceHandler) { m_pollServiceHandlers.Add(capName, pollServiceHandler); m_httpListener.AddPollServiceHTTPHandler(pollServiceHandler.Url, pollServiceHandler); // uint port = (MainServer.Instance == null) ? 0 : MainServer.Instance.Port; // string protocol = "http"; // string hostName = m_httpListenerHostName; // // if (MainServer.Instance.UseSSL) // { // hostName = MainServer.Instance.SSLCommonName; // port = MainServer.Instance.SSLPort; // protocol = "https"; // } // RegisterHandler( // capName, String.Format("{0}://{1}:{2}{3}", protocol, hostName, port, pollServiceHandler.Url)); }
public UUID RequestURL(IScriptModule engine, SceneObjectPart host, UUID itemID) { UUID urlcode = UUID.Random(); lock (m_UrlMap) { if (m_UrlMap.Count >= TotalUrls) { engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_DENIED", "" }); return(urlcode); } string url = "http://" + ExternalHostNameForLSL + ":" + m_HttpServer.Port.ToString() + "/lslhttp/" + urlcode.ToString() + "/"; UrlData urlData = new UrlData(); urlData.hostID = host.UUID; urlData.itemID = itemID; urlData.engine = engine; urlData.url = url; urlData.urlcode = urlcode; urlData.isSsl = false; urlData.requests = new Dictionary <UUID, RequestData>(); urlData.scene = host.ParentGroup.Scene; m_UrlMap[url] = urlData; string uri = "/lslhttp/" + urlcode.ToString() + "/"; PollServiceEventArgs args = new PollServiceEventArgs(HttpRequestHandler, uri, HasEvents, GetEvents, NoEvents, urlcode, 25000); args.Type = PollServiceEventArgs.EventType.LslHttp; m_HttpServer.AddPollServiceHTTPHandler(uri, args); // m_log.DebugFormat( // "[URL MODULE]: Set up incoming request url {0} for {1} in {2} {3}", // uri, itemID, host.Name, host.LocalId); engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_GRANTED", url }); } return(urlcode); }
public bool TryGetPollHandler(string name, out PollServiceEventArgs pollHandler) { return(m_pollServiceHandlers.TryGetValue(name, out pollHandler)); }
public UUID RequestURL(IScriptModule engine, SceneObjectPart host, UUID itemID, Hashtable options) { UUID urlcode = UUID.Random(); if (!m_enabled) { engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_DENIED", m_ErrorStr }); return(urlcode); } lock (m_UrlMap) { if (m_UrlMap.Count >= TotalUrls) { engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_DENIED", "Too many URLs already open" }); return(urlcode); } string url = "http://" + ExternalHostNameForLSL + ":" + m_HttpServer.Port.ToString() + "/lslhttp/" + urlcode.ToString(); UUID groupID = host.ParentGroup.UUID; UrlData urlData = new UrlData(); urlData.hostID = host.UUID; urlData.groupID = groupID; urlData.itemID = itemID; urlData.engine = engine; urlData.url = url; urlData.urlcode = urlcode; urlData.isSsl = false; urlData.requests = new Dictionary <UUID, RequestData>(); urlData.scene = host.ParentGroup.Scene; urlData.allowXss = false; if (options != null && options["allowXss"] != null) { urlData.allowXss = true; } m_UrlMap[url] = urlData; if (m_countsPerSOG.TryGetValue(groupID, out int urlcount)) { m_countsPerSOG[groupID] = ++urlcount; } else { m_countsPerSOG[groupID] = 1; } string uri = "/lslhttp/" + urlcode.ToString(); PollServiceEventArgs args = new PollServiceEventArgs(HttpRequestHandler, uri, HasEvents, GetEvents, NoEvents, Drop, urlcode, 25000); m_HttpServer.AddPollServiceHTTPHandlerVarPath(args); //m_log.DebugFormat( // "[URL MODULE]: Set up incoming request url {0} for {1} in {2} {3}", // uri, itemID, host.Name, host.LocalId); engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_GRANTED", url + "/" }); } return(urlcode); }
private void BuildSummaryStatsByCapReport(StringBuilder sb) { ConsoleDisplayTable cdt = new ConsoleDisplayTable(); cdt.AddColumn("Name", 34); cdt.AddColumn("Req Received", 12); cdt.AddColumn("Req Handled", 12); cdt.Indent = 2; Dictionary <string, int> receivedStats = new Dictionary <string, int>(); Dictionary <string, int> handledStats = new Dictionary <string, int>(); m_scene.ForEachScenePresence( sp => { Caps caps = m_scene.CapsModule.GetCapsForUser(sp.UUID); if (caps == null) { return; } foreach (IRequestHandler reqHandler in caps.CapsHandlers.GetCapsHandlers().Values) { string reqName = reqHandler.Name ?? ""; if (!receivedStats.ContainsKey(reqName)) { receivedStats[reqName] = reqHandler.RequestsReceived; handledStats[reqName] = reqHandler.RequestsHandled; } else { receivedStats[reqName] += reqHandler.RequestsReceived; handledStats[reqName] += reqHandler.RequestsHandled; } } foreach (KeyValuePair <string, PollServiceEventArgs> kvp in caps.GetPollHandlers()) { string name = kvp.Key; PollServiceEventArgs pollHandler = kvp.Value; if (!receivedStats.ContainsKey(name)) { receivedStats[name] = pollHandler.RequestsReceived; handledStats[name] = pollHandler.RequestsHandled; } else { receivedStats[name] += pollHandler.RequestsReceived; handledStats[name] += pollHandler.RequestsHandled; } } } ); foreach (KeyValuePair <string, int> kvp in receivedStats.OrderByDescending(kp => kp.Value)) { cdt.AddRow(kvp.Key, kvp.Value, handledStats[kvp.Key]); } sb.Append(cdt.ToString()); }