-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
IP
O código tenta buscar um novo IP público, mas se isso falha ele reutiliza o IP antigo e mesmo assim marca a verificação como bem-sucedida. Com isso, o sistema acha que o IP foi atualizado agora, quando na verdade houve erro, e acaba bloqueando novas tentativas até o tempo de refresh acabar.
Por algum motivo o debug localhost também não funcionou.
private string GetCachedPublicIp()
{
var now = DateTime.UtcNow;
if (_lastIp != null && now - _lastFetch < _refreshInterval)
return _lastIp;
string ip = GetPublicIp() ?? _lastIp ?? "Not Found";
_lastIp = ip;
_lastFetch = now;
return ip;
}
string ip = GetPublicIp() ?? _lastIp ?? "Not Found";
_lastIp = ip;
_lastFetch = now; // <= Atualiza o tempo mesmo se GetPublicIp falhar
return ip;
MAC
Analisando
private static string? GetMacAddress()
{
foreach (var nic in NetworkInterface.GetAllNetworkInterfaces())
{
if (nic.OperationalStatus == OperationalStatus.Up &&
nic.NetworkInterfaceType != NetworkInterfaceType.Loopback)
{
var bytes = nic.GetPhysicalAddress().GetAddressBytes();
// Ignora adaptadores sem endereço físico
if (bytes == null || bytes.Length == 0)
continue;
var mac = BitConverter.ToString(bytes);
if (string.IsNullOrWhiteSpace(mac))
continue;
return mac;
}
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working
Type
Projects
Status
Ready