mirror of
https://github.com/Stone-Red-Code/HyperbolicDownloader.git
synced 2026-09-08 07:46:23 +02:00
- Add host expiration check to the HostManager.Remove method
This commit is contained in:
@@ -34,9 +34,12 @@ internal class HostsManager
|
|||||||
SaveHosts();
|
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();
|
SaveHosts();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -194,7 +194,7 @@ internal class InputHandler
|
|||||||
|
|
||||||
if (!validIpAdress)
|
if (!validIpAdress)
|
||||||
{
|
{
|
||||||
hostsManager.Remove(host);
|
hostsManager.Remove(host, true);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -210,6 +210,7 @@ internal class InputHandler
|
|||||||
{
|
{
|
||||||
Console.CursorLeft = 0;
|
Console.CursorLeft = 0;
|
||||||
ConsoleExt.WriteLine($"{host.IPAddress}:{host.Port} > Inactive", ConsoleColor.Red);
|
ConsoleExt.WriteLine($"{host.IPAddress}:{host.Port} > Inactive", ConsoleColor.Red);
|
||||||
|
|
||||||
hostsManager.Remove(host);
|
hostsManager.Remove(host);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user