Skip to content

Commit 5001aed

Browse files
committed
fix(dotnet): support IP address server names
1 parent 6ffcbc4 commit 5001aed

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

ffi/dotnet/Devolutions.IronRdp/src/Connection.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,15 @@ static async Task SingleConnectStep<T>(ClientConnector connector, WriteBuf buf,
197197

198198
static async Task<NetworkStream> CreateTcpConnection(String servername, int port)
199199
{
200-
IPHostEntry ipHostInfo = await Dns.GetHostEntryAsync(servername);
201-
IPAddress ipAddress = ipHostInfo.AddressList[0];
200+
IPAddress ipAddress;
201+
202+
try {
203+
ipAddress = IPAddress.Parse(servername);
204+
} catch (FormatException) {
205+
IPHostEntry ipHostInfo = await Dns.GetHostEntryAsync(servername);
206+
ipAddress = ipHostInfo.AddressList[0];
207+
}
208+
202209
IPEndPoint ipEndPoint = new(ipAddress, port);
203210

204211
TcpClient client = new TcpClient();
@@ -220,4 +227,4 @@ public static byte[] Vecu8ToByte(VecU8 vecU8)
220227
vecU8.Fill(buffer);
221228
return buffer;
222229
}
223-
}
230+
}

0 commit comments

Comments
 (0)