Improve connection disposal.

This commit is contained in:
Christian Kratky
2019-04-22 10:50:47 +02:00
parent 5c903e6fbf
commit 6399172582
20 changed files with 179 additions and 165 deletions
@@ -45,6 +45,9 @@
/// </summary>
public RetainedApplicationMessagesModel RetainedApplicationMessages { get; set; } = new RetainedApplicationMessagesModel();
/// <summary>
/// Enables or disables the MQTTnet internal logging.
/// </summary>
public bool EnableDebugLogging { get; set; } = false;
}
}
@@ -60,13 +60,13 @@ namespace MQTTnet.Server.Configuration
{
if (IPv4 == "*")
{
address = IPAddress.Parse("0.0.0.0");
address = IPAddress.Any;
return true;
}
if (IPv4 == "localhost")
{
address = IPAddress.Parse("127.0.0.1");
address = IPAddress.Loopback;
return true;
}
@@ -81,10 +81,8 @@ namespace MQTTnet.Server.Configuration
address = ip;
return true;
}
else
{
throw new System.Exception($"Could not parse IPv4 address: {IPv4}");
}
throw new System.Exception($"Could not parse IPv4 address: {IPv4}");
}
/// <summary>
@@ -95,13 +93,13 @@ namespace MQTTnet.Server.Configuration
{
if (IPv6 == "*")
{
address = IPAddress.Parse("::");
address = IPAddress.IPv6Any;
return true;
}
if (IPv6 == "localhost")
{
address = IPAddress.Parse("::1");
address = IPAddress.IPv6Loopback;
return true;
}
@@ -116,10 +114,8 @@ namespace MQTTnet.Server.Configuration
address = ip;
return true;
}
else
{
throw new System.Exception($"Could not parse IPv6 address: {IPv6}");
}
throw new System.Exception($"Could not parse IPv6 address: {IPv6}");
}
}
}
@@ -152,6 +152,7 @@ namespace MQTTnet.Server.Mqtt
if (_settings.TcpEndPoint.Enabled)
{
options.WithDefaultEndpoint();
if (_settings.TcpEndPoint.TryReadIPv4(out var address4))
{
options.WithDefaultEndpointBoundIPAddress(address4);
+5 -5
View File
@@ -18,14 +18,14 @@
*/
"TcpEndPoint": {
"Enabled": true,
"IPv4": "localhost",
"IPv6": "localhost",
"IPv4": "*",
"IPv6": "*",
"Port": 1883
},
"EncryptedTcpEndPoint": {
"Enabled": false,
"IPv4": "localhost",
"IPv6": "localhost",
"IPv4": "*",
"IPv6": "*",
"Port": 8883,
"CertificatePath": "/absolute/path/to/pfx"
},
@@ -45,7 +45,7 @@
"Filename": "RetainedApplicationMessages.json",
"WriteInterval": 10 // In seconds.
},
"EnableDebugLogging": false
"EnableDebugLogging": true
},
"Logging": {
"LogLevel": {