mirror of
https://github.com/Stone-Red-Code/HyperbolicDownloader.git
synced 2026-09-04 09:06:10 +02:00
- Add host expiration check to the HostManager.Remove method
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user