From 0a149647b6c2062809a428c2ae659b8052afe480 Mon Sep 17 00:00:00 2001 From: zorua162 Date: Sat, 18 Nov 2023 22:00:16 +0000 Subject: [PATCH] Add an IP lookup to the WebSocketBot --- MinecraftClient/ChatBots/WebSocketBot.cs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/MinecraftClient/ChatBots/WebSocketBot.cs b/MinecraftClient/ChatBots/WebSocketBot.cs index 6ba4395e..8320e5b4 100644 --- a/MinecraftClient/ChatBots/WebSocketBot.cs +++ b/MinecraftClient/ChatBots/WebSocketBot.cs @@ -291,7 +291,17 @@ public class WebSocketBot : ChatBot public WebSocketBot() { - var match = Regex.Match(Config.Ip!, @"\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}"); + // Lookup the given address + try + { + _ip = Dns.GetHostAddresses(Config.Ip!).First().ToString(); + } + catch (Exception e) + { + // Set Ip to a non-acceptable value to fail the Ip check + _ip = "not found"; + } + var match = Regex.Match(_ip, @"\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}"); if (!match.Success) { @@ -305,7 +315,6 @@ public class WebSocketBot : ChatBot return; } - _ip = Config.Ip; _port = Config.Port; _password = Config.Password; _authenticatedSessions = new();