Skip to content

Commit

Permalink
Seperated message handling and transportion in code as first step of …
Browse files Browse the repository at this point in the history
…implementing additional transport mode like DoT or DoH.
  • Loading branch information
alexreinert committed Dec 18, 2022
1 parent ca59b49 commit 38ce926
Show file tree
Hide file tree
Showing 118 changed files with 3,224 additions and 1,570 deletions.
2 changes: 1 addition & 1 deletion ARSoft.Tools.Net/ARSoft.Tools.Net.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<PackageLicenseUrl>https://github.com/alexreinert/ARSoft.Tools.Net/blob/master/LICENSE</PackageLicenseUrl>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<Copyright>Copyright 2010..2022 Alexander Reinert</Copyright>
<VersionPrefix>3.0.0</VersionPrefix>
<VersionPrefix>3.1.0</VersionPrefix>
</PropertyGroup>

<ItemGroup>
Expand Down
16 changes: 11 additions & 5 deletions ARSoft.Tools.Net/Dns/ClientConnectedEventArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,30 @@ namespace ARSoft.Tools.Net.Dns
public class ClientConnectedEventArgs : EventArgs
{
/// <summary>
/// Protocol used by the client
/// Protocol which is used by the client
/// </summary>
public ProtocolType ProtocolType { get; private set; }
public TransportProtocol TransportProtocol { get; }

/// <summary>
/// Remote endpoint of the client
/// </summary>
public IPEndPoint RemoteEndpoint { get; private set; }
public IPEndPoint RemoteEndpoint { get; }

/// <summary>
/// Local endpoint to which the client is connected
/// </summary>
public IPEndPoint LocalEndpoint { get; }

/// <summary>
/// If true, the client connection will be refused
/// </summary>
public bool RefuseConnect { get; set; }

internal ClientConnectedEventArgs(ProtocolType protocolType, IPEndPoint remoteEndpoint)
internal ClientConnectedEventArgs(TransportProtocol transportType, IPEndPoint remoteEndpoint, IPEndPoint localEndPoint)
{
ProtocolType = protocolType;
TransportProtocol = transportType;
RemoteEndpoint = remoteEndpoint;
LocalEndpoint = localEndPoint;
}
}
}
39 changes: 14 additions & 25 deletions ARSoft.Tools.Net/Dns/DnsClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,24 +42,6 @@ public class DnsClient : DnsClientBase
/// </summary>
public static DnsClient Default { get; private set; }

/// <summary>
/// Gets or sets a value indicationg whether queries can be sent using UDP.
/// </summary>
public new bool IsUdpEnabled
{
get { return base.IsUdpEnabled; }
set { base.IsUdpEnabled = value; }
}

/// <summary>
/// Gets or sets a value indicationg whether queries can be sent using TCP.
/// </summary>
public new bool IsTcpEnabled
{
get { return base.IsTcpEnabled; }
set { base.IsTcpEnabled = value; }
}

static DnsClient()
{
Default = new DnsClient(GetLocalConfiguredDnsServers(), 10000) { IsResponseValidationEnabled = true };
Expand All @@ -78,14 +60,21 @@ public DnsClient(IPAddress dnsServer, int queryTimeout)
/// </summary>
/// <param name="dnsServers"> The IPAddresses of the dns servers to use </param>
/// <param name="queryTimeout"> Query timeout in milliseconds </param>
public DnsClient(IEnumerable<IPAddress> dnsServers, int queryTimeout)
: base(dnsServers, queryTimeout, 53)
{
IsUdpEnabled = true;
IsTcpEnabled = true;
}
public DnsClient(IEnumerable<IPAddress> dnsServers, int queryTimeout = 10000)
: base(dnsServers, queryTimeout, new IClientTransport[] { new UdpClientTransport(), new TcpClientTransport() }, true) { }

protected override int MaximumQueryMessageSize => 512;
/// <summary>
/// Provides a new instance with custom dns servers and query timeout
/// </summary>
/// <param name="dnsServers"> The IPAddresses of the dns servers to use </param>
/// <param name="transports"> The transports which is used </param>
/// <param name="disposeTransport">
/// A value indicating, if the transports should be disposed when the DnsClient instance is
/// disposed
/// </param>
/// <param name="queryTimeout"> Query timeout in milliseconds </param>
public DnsClient(IEnumerable<IPAddress> dnsServers, IClientTransport[] transports, bool disposeTransport = false, int queryTimeout = 10000)
: base(dnsServers, queryTimeout, transports, disposeTransport) { }

/// <summary>
/// Queries a dns server for specified records.
Expand Down
Loading

0 comments on commit 38ce926

Please sign in to comment.