From 1e697a94a14b3a0404b4ff7599ae99fa696add70 Mon Sep 17 00:00:00 2001 From: Kiarash Date: Sun, 10 Mar 2019 17:18:20 +0100 Subject: [PATCH] Add Kesterl Settings into appsettings --- .../Configuration/SettingsModel.cs | 4 ++-- .../MQTTnet.Server/Mqtt/MqttServerService.cs | 22 +++++++++---------- Source/MQTTnet.Server/Program.cs | 2 ++ Source/MQTTnet.Server/appsettings.json | 14 ++++++++++-- 4 files changed, 27 insertions(+), 15 deletions(-) diff --git a/Source/MQTTnet.Server/Configuration/SettingsModel.cs b/Source/MQTTnet.Server/Configuration/SettingsModel.cs index 6b3c95c2..ca1ebb47 100644 --- a/Source/MQTTnet.Server/Configuration/SettingsModel.cs +++ b/Source/MQTTnet.Server/Configuration/SettingsModel.cs @@ -27,12 +27,12 @@ /// /// Listen Settings /// - public ListenModel Endpoint { get; set; } = new ListenModel(); + public ListenModel EndPoint { get; set; } = new ListenModel(); /// /// Encryption Listen Settings /// - public ListenModel EndpointEncryption { get; set; } = new ListenModel(); + public ListenModel EndPointEncryption { get; set; } = new ListenModel(); /// /// Set limit for max pending messages per client diff --git a/Source/MQTTnet.Server/Mqtt/MqttServerService.cs b/Source/MQTTnet.Server/Mqtt/MqttServerService.cs index bac16868..c17b2413 100644 --- a/Source/MQTTnet.Server/Mqtt/MqttServerService.cs +++ b/Source/MQTTnet.Server/Mqtt/MqttServerService.cs @@ -76,22 +76,22 @@ namespace MQTTnet.Server.Mqtt .WithSubscriptionInterceptor(_mqttSubscriptionInterceptor); // Configure unencrypted connections - if (_settings.Endpoint.Enabled) + if (_settings.EndPoint.Enabled) { options.WithDefaultEndpoint(); - if (_settings.Endpoint.TryReadIPv4(out var address4)) + if (_settings.EndPoint.TryReadIPv4(out var address4)) { options.WithDefaultEndpointBoundIPAddress(address4); } - if (_settings.Endpoint.TryReadIPv6(out var address6)) + if (_settings.EndPoint.TryReadIPv6(out var address6)) { options.WithDefaultEndpointBoundIPV6Address(address6); } - if (_settings.Endpoint.Port > 0) + if (_settings.EndPoint.Port > 0) { - options.WithDefaultEndpointPort(_settings.Endpoint.Port); + options.WithDefaultEndpointPort(_settings.EndPoint.Port); } } else @@ -100,26 +100,26 @@ namespace MQTTnet.Server.Mqtt } // Configure encrypted connections - if (_settings.EndpointEncryption.Enabled) + if (_settings.EndPointEncryption.Enabled) { options .WithEncryptedEndpoint() .WithEncryptionSslProtocol(System.Security.Authentication.SslProtocols.Tls12) - .WithEncryptionCertificate(_settings.EndpointEncryption.ReadCertificate()); + .WithEncryptionCertificate(_settings.EndPointEncryption.ReadCertificate()); - if (_settings.EndpointEncryption.TryReadIPv4(out var address4)) + if (_settings.EndPointEncryption.TryReadIPv4(out var address4)) { options.WithEncryptedEndpointBoundIPAddress(address4); } - if (_settings.EndpointEncryption.TryReadIPv6(out var address6)) + if (_settings.EndPointEncryption.TryReadIPv6(out var address6)) { options.WithEncryptedEndpointBoundIPV6Address(address6); } - if (_settings.Endpoint.Port > 0) + if (_settings.EndPoint.Port > 0) { - options.WithEncryptedEndpointPort(_settings.EndpointEncryption.Port); + options.WithEncryptedEndpointPort(_settings.EndPointEncryption.Port); } } else diff --git a/Source/MQTTnet.Server/Program.cs b/Source/MQTTnet.Server/Program.cs index 221f48c9..9161f166 100644 --- a/Source/MQTTnet.Server/Program.cs +++ b/Source/MQTTnet.Server/Program.cs @@ -29,6 +29,7 @@ namespace MQTTnet.Server private static void PrintLogo() { + Console.ResetColor(); Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(@" __ __ ____ _______ _______ _ _____ @@ -60,6 +61,7 @@ namespace MQTTnet.Server Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(" ! THIS IS AN ALPHA VERSION! IT IS NOT RECOMMENDED TO USE IT FOR ANY DIFFERENT PURPOSE THAN TESTING OR EVALUATING!"); Console.WriteLine(); + Console.ResetColor(); } } } \ No newline at end of file diff --git a/Source/MQTTnet.Server/appsettings.json b/Source/MQTTnet.Server/appsettings.json index 09251354..c913f388 100644 --- a/Source/MQTTnet.Server/appsettings.json +++ b/Source/MQTTnet.Server/appsettings.json @@ -1,4 +1,14 @@ { + "Kestrel": { + "EndPoints": { + "Http": { + "Url": "http://localhost:80" + }, + "Https": { + "Url": "http://localhost:443" + } + } + }, "MQTT": { /* Wildcard Addresses: @@ -6,13 +16,13 @@ localhost - Localhost only disable - Skip address assignment */ - "Endpoint": { + "EndPoint": { "Enabled": true, "IPv4": "localhost", "IPv6": "localhost", "Port": 1883 }, - "EndpointEncryption": { + "EndPointEncryption": { "Enabled": false, "IPv4": "localhost", "IPv6": "localhost",