Bladeren bron

Add support for disabling server endpoints (ipv4 or ipv6)

release/3.x.x
Christian Kratky 6 jaren geleden
bovenliggende
commit
2b420b8e66
1 gewijzigde bestanden met toevoegingen van 28 en 21 verwijderingen
  1. +28
    -21
      Source/MQTTnet/Implementations/MqttTcpServerAdapter.cs

+ 28
- 21
Source/MQTTnet/Implementations/MqttTcpServerAdapter.cs Bestand weergeven

@@ -1,6 +1,7 @@
#if !WINDOWS_UWP
using System;
using System.Collections.Generic;
using System.Net;
using System.Net.Sockets;
using System.Security.Cryptography.X509Certificates;
using System.Threading;
@@ -79,27 +80,33 @@ namespace MQTTnet.Implementations

private void RegisterListeners(MqttServerTcpEndpointBaseOptions options, X509Certificate2 tlsCertificate)
{
var listenerV4 = new MqttTcpServerListener(
AddressFamily.InterNetwork,
options,
tlsCertificate,
_cancellationTokenSource.Token,
_logger);

listenerV4.ClientAccepted += OnClientAccepted;
listenerV4.Start();
_listeners.Add(listenerV4);

var listenerV6 = new MqttTcpServerListener(
AddressFamily.InterNetworkV6,
options,
tlsCertificate,
_cancellationTokenSource.Token,
_logger);

listenerV6.ClientAccepted += OnClientAccepted;
listenerV6.Start();
_listeners.Add(listenerV6);
if (!options.BoundInterNetworkAddress.Equals(IPAddress.None))
{
var listenerV4 = new MqttTcpServerListener(
AddressFamily.InterNetwork,
options,
tlsCertificate,
_cancellationTokenSource.Token,
_logger);

listenerV4.ClientAccepted += OnClientAccepted;
listenerV4.Start();
_listeners.Add(listenerV4);
}

if (!options.BoundInterNetworkV6Address.Equals(IPAddress.None))
{
var listenerV6 = new MqttTcpServerListener(
AddressFamily.InterNetworkV6,
options,
tlsCertificate,
_cancellationTokenSource.Token,
_logger);

listenerV6.ClientAccepted += OnClientAccepted;
listenerV6.Start();
_listeners.Add(listenerV6);
}
}

private void OnClientAccepted(object sender, MqttServerAdapterClientAcceptedEventArgs e)


Laden…
Annuleren
Opslaan