mirror of
https://github.com/dotnet/MQTTnet.git
synced 2026-10-16 17:23:04 +08:00
Add Kesterl Settings into appsettings
This commit is contained in:
@@ -27,12 +27,12 @@
|
||||
/// <summary>
|
||||
/// Listen Settings
|
||||
/// </summary>
|
||||
public ListenModel Endpoint { get; set; } = new ListenModel();
|
||||
public ListenModel EndPoint { get; set; } = new ListenModel();
|
||||
|
||||
/// <summary>
|
||||
/// Encryption Listen Settings
|
||||
/// </summary>
|
||||
public ListenModel EndpointEncryption { get; set; } = new ListenModel();
|
||||
public ListenModel EndPointEncryption { get; set; } = new ListenModel();
|
||||
|
||||
/// <summary>
|
||||
/// Set limit for max pending messages per client
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user