From 3359c752e065898f8ccf756882f2a3f9b66c6e8c Mon Sep 17 00:00:00 2001 From: Brian Holmgreen Date: Sun, 17 Oct 2021 00:49:49 +0200 Subject: [PATCH] nu med basic http listner --- .vs/csgo-network-log-parser/v16/.suo | Bin 53248 -> 67072 bytes src/Properties/launchSettings.json | 1 + src/controllers/LogController.cs | 51 +++++++++++++++++++++++++++ 3 files changed, 52 insertions(+) create mode 100644 src/controllers/LogController.cs diff --git a/.vs/csgo-network-log-parser/v16/.suo b/.vs/csgo-network-log-parser/v16/.suo index 3f49ba55e1744f3c089243b768fc0608b06ef9dc..01a834f1716804914378845d18910ff3f400d187 100644 GIT binary patch delta 7708 zcmd^D3v^Re7JauQ^rbDOrC(ZVKNKjmDKF_u^3sMjX~M5mQobSlYT?o2d&Me0@eiqEgupo2JYZBs6pv?GNYi`!b zJ@3AI@4I)ObN0FKb==>tW4&Ti0eoc|kQ&EvS8*KI59OTS@5hQ`D2ZTE4Sj0fdgh6! zWU-JPk*T_W{kr%QuYSPP;O^hfQsET-KLzf7cAf?(P+*0WH()g?c_>t(fhiK&2cnjP z5`%(|@LwOO6R^%eiABjmq32T>g*w%dSf9nZf8d&CEePo8SZAWpm?W%~C@CnD18r$o z4@VioaZ|aGs0=_Eijs;_g)$d~9+Hi<5YXvbgSr-FL|B_1bt!Od#JUtT$^`hFj{{y6 z!_IAe8ML7 z0ps>?jC?oL0~q;)G-}3OWK8jyM4nM4XVNIR|5n^R&y5 zQv(%(yhro<1CWOhr}iM?!9G#gzc<9iz&vE73lI-`hTjjR%Kkql{82n~N5w&ElsR!L zKIkr#-=SliJ^%*!_IEkk~ ziVyT)w}5-JT^>ZVjlk2&AZcD#8OAnMCb3g1RRLxTr3LQ!aC?k8P0S_j)TFRqu?$0_+hjJ#7X%CDqld2X%g5pCQqqs zC6)v3QaevvOOZzXA|B`9AEj554VfL>Wz!V2YIz3QDhHghdIXd*!!M4bAQD{pO*gPquKn|M?A?k**(dl zdKQpuhu0!Ba5CAhV&r?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4a1 100644 --- a/src/Properties/launchSettings.json +++ b/src/Properties/launchSettings.json @@ -22,6 +22,7 @@ "CSGO_ServersToReactTo": "", "CSGO_ApiEndpointsToCall": "http://127.0.0.1/webhook?action=%%ServerAction%%&Token=123;http://127.0.0.1/wow?action=%%ServerAction%%&Token=123", "CSGO_UDP_PORT": "9000", + "ASPNETCORE_URLS": "http://+:5000", "CSGO_DebugMode": "true", "ASPNETCORE_ENVIRONMENT": "Development" }, diff --git a/src/controllers/LogController.cs b/src/controllers/LogController.cs new file mode 100644 index 0000000..39c4664 --- /dev/null +++ b/src/controllers/LogController.cs @@ -0,0 +1,51 @@ +using System.IO; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; + +namespace CSGO_DataLogger.controllers +{ + [ApiController] + [Route("Log")] + public class LogController : ControllerBase + { + private readonly ILogger _logger; + private readonly ConfigCache _configCache; + private readonly LogManager _logManager; + + public LogController(ILogger logger,ConfigCache configCache, LogManager logManager) + { + _logger = logger; + _configCache = configCache; + _logManager = logManager; + } + + [HttpPost] + [Route("Log")] + //[ReadableBodyStream] + public async Task Log(CancellationToken cancellationToken) + { + string lines = await StreamToStringAsync(Request); + foreach (string line in lines.Split('\n')) + { + if (_configCache.Debug) + { + _logger.LogInformation($"Recieved: {line}"); + Task.Run(() => _logManager.ParseLog(Request.HttpContext.Connection.RemoteIpAddress?.ToString() ?? "Unknown", line, cancellationToken)); + } + } + } + + private async Task StreamToStringAsync(HttpRequest request) + { + using (var sr = new StreamReader(request.Body)) + { + return await sr.ReadToEndAsync(); + } + } + } +} \ No newline at end of file