From 26421c7469f983b3f2ecc6ddd5f0585c87bd46f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20CORTIER?= Date: Tue, 9 Apr 2024 23:53:15 +0900 Subject: [PATCH] fix(dotnet): support IP address server names --- ffi/dotnet/Devolutions.IronRdp/src/Connection.cs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/ffi/dotnet/Devolutions.IronRdp/src/Connection.cs b/ffi/dotnet/Devolutions.IronRdp/src/Connection.cs index 7e810e74..d1cd0c9d 100644 --- a/ffi/dotnet/Devolutions.IronRdp/src/Connection.cs +++ b/ffi/dotnet/Devolutions.IronRdp/src/Connection.cs @@ -197,8 +197,15 @@ public class Connection static async Task CreateTcpConnection(String servername, int port) { - IPHostEntry ipHostInfo = await Dns.GetHostEntryAsync(servername); - IPAddress ipAddress = ipHostInfo.AddressList[0]; + IPAddress ipAddress; + + try { + ipAddress = IPAddress.Parse(servername); + } catch (FormatException) { + IPHostEntry ipHostInfo = await Dns.GetHostEntryAsync(servername); + ipAddress = ipHostInfo.AddressList[0]; + } + IPEndPoint ipEndPoint = new(ipAddress, port); TcpClient client = new TcpClient(); @@ -220,4 +227,4 @@ public static class Utils vecU8.Fill(buffer); return buffer; } -} \ No newline at end of file +}