diff --git a/HyperbolicDownloader/Networking/HostsManager.cs b/HyperbolicDownloader/Networking/HostsManager.cs index 8f39129..b485bc8 100644 --- a/HyperbolicDownloader/Networking/HostsManager.cs +++ b/HyperbolicDownloader/Networking/HostsManager.cs @@ -34,9 +34,12 @@ internal class HostsManager SaveHosts(); } - public void Remove(NetworkSocket host) + public void Remove(NetworkSocket host, bool forceRemove = false) { - hosts.RemoveAll(x => x.IPAddress == host.IPAddress && x.Port == host.Port); + if (DateTime.Now - host.LastActive >= new TimeSpan(24, 0, 0) || forceRemove) + { + hosts.RemoveAll(x => x.IPAddress == host.IPAddress && x.Port == host.Port); + } SaveHosts(); } diff --git a/HyperbolicDownloader/UserInterface/InputHandler.cs b/HyperbolicDownloader/UserInterface/InputHandler.cs index 6715f5a..f2d50ce 100644 --- a/HyperbolicDownloader/UserInterface/InputHandler.cs +++ b/HyperbolicDownloader/UserInterface/InputHandler.cs @@ -194,7 +194,7 @@ internal class InputHandler if (!validIpAdress) { - hostsManager.Remove(host); + hostsManager.Remove(host, true); continue; } @@ -210,6 +210,7 @@ internal class InputHandler { Console.CursorLeft = 0; ConsoleExt.WriteLine($"{host.IPAddress}:{host.Port} > Inactive", ConsoleColor.Red); + hostsManager.Remove(host); continue; }