mirror of
https://github.com/dotnet/MQTTnet.git
synced 2026-10-21 12:16:02 +08:00
Add Kesterl Settings into appsettings
This commit is contained in:
@@ -27,12 +27,12 @@
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Listen Settings
|
/// Listen Settings
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public ListenModel Endpoint { get; set; } = new ListenModel();
|
public ListenModel EndPoint { get; set; } = new ListenModel();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Encryption Listen Settings
|
/// Encryption Listen Settings
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public ListenModel EndpointEncryption { get; set; } = new ListenModel();
|
public ListenModel EndPointEncryption { get; set; } = new ListenModel();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Set limit for max pending messages per client
|
/// Set limit for max pending messages per client
|
||||||
|
|||||||
@@ -76,22 +76,22 @@ namespace MQTTnet.Server.Mqtt
|
|||||||
.WithSubscriptionInterceptor(_mqttSubscriptionInterceptor);
|
.WithSubscriptionInterceptor(_mqttSubscriptionInterceptor);
|
||||||
|
|
||||||
// Configure unencrypted connections
|
// Configure unencrypted connections
|
||||||
if (_settings.Endpoint.Enabled)
|
if (_settings.EndPoint.Enabled)
|
||||||
{
|
{
|
||||||
options.WithDefaultEndpoint();
|
options.WithDefaultEndpoint();
|
||||||
if (_settings.Endpoint.TryReadIPv4(out var address4))
|
if (_settings.EndPoint.TryReadIPv4(out var address4))
|
||||||
{
|
{
|
||||||
options.WithDefaultEndpointBoundIPAddress(address4);
|
options.WithDefaultEndpointBoundIPAddress(address4);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_settings.Endpoint.TryReadIPv6(out var address6))
|
if (_settings.EndPoint.TryReadIPv6(out var address6))
|
||||||
{
|
{
|
||||||
options.WithDefaultEndpointBoundIPV6Address(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
|
else
|
||||||
@@ -100,26 +100,26 @@ namespace MQTTnet.Server.Mqtt
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Configure encrypted connections
|
// Configure encrypted connections
|
||||||
if (_settings.EndpointEncryption.Enabled)
|
if (_settings.EndPointEncryption.Enabled)
|
||||||
{
|
{
|
||||||
options
|
options
|
||||||
.WithEncryptedEndpoint()
|
.WithEncryptedEndpoint()
|
||||||
.WithEncryptionSslProtocol(System.Security.Authentication.SslProtocols.Tls12)
|
.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);
|
options.WithEncryptedEndpointBoundIPAddress(address4);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_settings.EndpointEncryption.TryReadIPv6(out var address6))
|
if (_settings.EndPointEncryption.TryReadIPv6(out var address6))
|
||||||
{
|
{
|
||||||
options.WithEncryptedEndpointBoundIPV6Address(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
|
else
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ namespace MQTTnet.Server
|
|||||||
|
|
||||||
private static void PrintLogo()
|
private static void PrintLogo()
|
||||||
{
|
{
|
||||||
|
Console.ResetColor();
|
||||||
Console.ForegroundColor = ConsoleColor.Red;
|
Console.ForegroundColor = ConsoleColor.Red;
|
||||||
Console.WriteLine(@"
|
Console.WriteLine(@"
|
||||||
__ __ ____ _______ _______ _ _____
|
__ __ ____ _______ _______ _ _____
|
||||||
@@ -60,6 +61,7 @@ namespace MQTTnet.Server
|
|||||||
Console.ForegroundColor = ConsoleColor.Red;
|
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(" ! THIS IS AN ALPHA VERSION! IT IS NOT RECOMMENDED TO USE IT FOR ANY DIFFERENT PURPOSE THAN TESTING OR EVALUATING!");
|
||||||
Console.WriteLine();
|
Console.WriteLine();
|
||||||
|
Console.ResetColor();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,14 @@
|
|||||||
{
|
{
|
||||||
|
"Kestrel": {
|
||||||
|
"EndPoints": {
|
||||||
|
"Http": {
|
||||||
|
"Url": "http://localhost:80"
|
||||||
|
},
|
||||||
|
"Https": {
|
||||||
|
"Url": "http://localhost:443"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"MQTT": {
|
"MQTT": {
|
||||||
/*
|
/*
|
||||||
Wildcard Addresses:
|
Wildcard Addresses:
|
||||||
@@ -6,13 +16,13 @@
|
|||||||
localhost - Localhost only
|
localhost - Localhost only
|
||||||
disable - Skip address assignment
|
disable - Skip address assignment
|
||||||
*/
|
*/
|
||||||
"Endpoint": {
|
"EndPoint": {
|
||||||
"Enabled": true,
|
"Enabled": true,
|
||||||
"IPv4": "localhost",
|
"IPv4": "localhost",
|
||||||
"IPv6": "localhost",
|
"IPv6": "localhost",
|
||||||
"Port": 1883
|
"Port": 1883
|
||||||
},
|
},
|
||||||
"EndpointEncryption": {
|
"EndPointEncryption": {
|
||||||
"Enabled": false,
|
"Enabled": false,
|
||||||
"IPv4": "localhost",
|
"IPv4": "localhost",
|
||||||
"IPv6": "localhost",
|
"IPv6": "localhost",
|
||||||
|
|||||||
Reference in New Issue
Block a user