From 5598ba9d232d40cbd0e02e3478b267fa99592ebe Mon Sep 17 00:00:00 2001 From: Pietro di Caprio Date: Fri, 14 Oct 2022 23:33:26 +0200 Subject: [PATCH] Move RabbitMQ config to appsettins.json --- Unifiedban.Terminal/Utils/ConfigTools.cs | 15 ++++++++------- Unifiedban.Terminal/appsettings.example.json | 7 +++++++ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/Unifiedban.Terminal/Utils/ConfigTools.cs b/Unifiedban.Terminal/Utils/ConfigTools.cs index 70219d1..063918c 100644 --- a/Unifiedban.Terminal/Utils/ConfigTools.cs +++ b/Unifiedban.Terminal/Utils/ConfigTools.cs @@ -1,4 +1,4 @@ - /* This Source Code Form is subject to the terms of the Mozilla Public + /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ @@ -277,9 +277,10 @@ private static void ConnectToHub() Date = DateTime.Now, Function = "connectToHub()", Level = Models.SystemLog.Levels.Info, - Message = "Connecting and autenticating to Hub Server", + Message = "Connecting and authenticating to Hub Server", UserId = -1 }); + _connection.StartAsync().Wait(); _connection.InvokeAsync("Identification", CacheData.Configuration["HubServerToken"]); @@ -428,11 +429,11 @@ static void LoadRabbitMQManager() UserId = -1 }); var factory = new ConnectionFactory(); - factory.UserName = "fabs"; - factory.Password = ""; - factory.VirtualHost = "/"; - factory.HostName = "10.0.0.4"; - factory.Port = 5672; + factory.HostName = CacheData.Configuration?["RabbitMQ:HostName"]; + factory.Port = int.Parse(CacheData.Configuration?["RabbitMQ:Port"] ?? string.Empty); + factory.VirtualHost = CacheData.Configuration?["RabbitMQ:VirtualHost"]; + factory.UserName = CacheData.Configuration?["RabbitMQ:Username"]; + factory.Password = CacheData.Configuration?["RabbitMQ:Password"]; factory.DispatchConsumersAsync = true; Data.Utils.Logging.AddLog(new Models.SystemLog() diff --git a/Unifiedban.Terminal/appsettings.example.json b/Unifiedban.Terminal/appsettings.example.json index 6b75d70..39c7c54 100644 --- a/Unifiedban.Terminal/appsettings.example.json +++ b/Unifiedban.Terminal/appsettings.example.json @@ -19,6 +19,13 @@ "URL": "", "Seconds": 30 }, + "RabbitMQ": { + "HostName": "10.0.0.0", + "Port": 5672, + "VirtualHost": "/", + "Username": "", + "Password": "" + }, "PastHoursToSkip": 12, "ThrowPendingUpdates": false }