From aee3f273f099c16a770ad4f3f4c9f1ee40227aef Mon Sep 17 00:00:00 2001 From: Mandarinka Tasty Date: Thu, 29 Dec 2016 23:20:33 +0100 Subject: [PATCH] Serving robots.txt from bin Idea of solution for http://opensimulator.org/mantis/view.php?id=7392 Signed-off-by: Mandarinka Tasty Signed-off-by: Melanie Thielker --- OpenSim/Region/Application/OpenSim.cs | 1 + OpenSim/Region/Application/OpenSimBase.cs | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs index 3cb999bee5..d9fdcde732 100644 --- a/OpenSim/Region/Application/OpenSim.cs +++ b/OpenSim/Region/Application/OpenSim.cs @@ -206,6 +206,7 @@ namespace OpenSim MainServer.Instance.AddStreamHandler(new OpenSim.XSimStatusHandler(this)); if (userStatsURI != String.Empty) MainServer.Instance.AddStreamHandler(new OpenSim.UXSimStatusHandler(this)); + MainServer.Instance.AddStreamHandler(new OpenSim.SimRobotsHandler()); if (managedStatsURI != String.Empty) { diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs index 52ded3d055..8499a90acd 100644 --- a/OpenSim/Region/Application/OpenSimBase.cs +++ b/OpenSim/Region/Application/OpenSimBase.cs @@ -876,6 +876,26 @@ namespace OpenSim } } + /// + /// handler to supply serving http://domainname:port/robots.txt + /// + public class SimRobotsHandler : BaseStreamHandler + { + public SimRobotsHandler() : base("GET", "/robots.txt", "SimRobots.txt", "Simulator Robots.txt") {} + + protected override byte[] ProcessRequest(string path, Stream request, + IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) + { + string robots = "# go away\nUser-agent: *\nDisallow: /\n"; + return Util.UTF8.GetBytes(robots); + } + + public override string ContentType + { + get { return "text/plain"; } + } + } + #endregion ///