BosMon Webserver first Running Version

This commit is contained in:
BlubbFish 2018-11-27 15:14:36 +00:00
parent bc959288f7
commit 621794f0b3
4 changed files with 14 additions and 13 deletions

View File

@ -5,6 +5,7 @@ using System.Net;
using System.Text; using System.Text;
using System.Threading; using System.Threading;
using System.Web; using System.Web;
using BlubbFish.Utils;
namespace BlubbFish.BosMon.Webserver { namespace BlubbFish.BosMon.Webserver {
internal class XMLWebserver { internal class XMLWebserver {
@ -25,26 +26,25 @@ namespace BlubbFish.BosMon.Webserver {
try { try {
while (this._listener.IsListening) { while (this._listener.IsListening) {
ThreadPool.QueueUserWorkItem((c) => { ThreadPool.QueueUserWorkItem((c) => {
HttpListenerContext ctx = c as HttpListenerContext; try {
if (ctx.Request.RawUrl == "/telegramin/" + this.config["upload_path"] + "/input.xml") { HttpListenerContext ctx = c as HttpListenerContext;
try { if (ctx.Request.RawUrl == "/telegramin/" + this.config["upload_path"] + "/input.xml") {
this.ParseInput(ctx); this.ParseInput(ctx);
} catch { } finally { ctx.Response.OutputStream.Close(); } } else if (ctx.Request.RawUrl == "/telegramio/" + this.config["download_path"] + "/index.xml?loop=true") {
} else if(ctx.Request.RawUrl == "/telegramio/" + this.config["download_path"] + "/index.xml?loop=true") {
try {
this.SendResponse(ctx); this.SendResponse(ctx);
} catch { } finally { } else {
Console.WriteLine("Output Connection Closed!"); ctx.Response.StatusCode = 404;
ctx.Response.OutputStream.Close();
} }
} else {
ctx.Response.StatusCode = 404;
ctx.Response.OutputStream.Close(); ctx.Response.OutputStream.Close();
ctx.Response.Close(); ctx.Response.Close();
} catch(Exception e) {
Helper.WriteError("Context Exception: " + e.Message +""+e.Source+ "\n\n" + e.StackTrace);
} }
}, this._listener.GetContext()); }, this._listener.GetContext());
} }
} catch { }; } catch(Exception e) {
Helper.WriteError("Webserver Exception: " + e.Message);
};
}); });
} }
@ -106,6 +106,7 @@ namespace BlubbFish.BosMon.Webserver {
} }
} }
request.Response.StatusCode = 200; request.Response.StatusCode = 200;
return;
} }
request.Response.StatusCode = 403; request.Response.StatusCode = 403;
} }

View File

@ -3,7 +3,7 @@ Version: x.x-x
Section: base Section: base
Priority: optional Priority: optional
Architecture: any Architecture: any
Depends: mono-runtime (>= 5.16.0) Depends: mono-runtime (>= 5.16.0), libmono-system-web4.0-cil (>= 5.16.0)
Maintainer: BlubbFish <dev@blubbfish.net> Maintainer: BlubbFish <dev@blubbfish.net>
Description: Bosmon-Webserver Description: Bosmon-Webserver
A Webserver for Bosmon Telegrafs A Webserver for Bosmon Telegrafs