fixing SocketException when IP address cannot be resolved
parent
68da7d1a43
commit
c81c9e712c
|
@ -27,18 +27,25 @@ namespace OpenSim.Region.CoreModules.Agent.IPBan
|
||||||
{
|
{
|
||||||
IPAddress end = ipEndpoint.EndPoint;
|
IPAddress end = ipEndpoint.EndPoint;
|
||||||
|
|
||||||
IPHostEntry rDNS = Dns.GetHostEntry(end);
|
try
|
||||||
foreach (string ban in bans)
|
|
||||||
{
|
{
|
||||||
if (rDNS.HostName.Contains(ban) ||
|
IPHostEntry rDNS = Dns.GetHostEntry(end);
|
||||||
end.ToString().StartsWith(ban))
|
foreach (string ban in bans)
|
||||||
{
|
{
|
||||||
client.Disconnect("Banned - network \"" + ban + "\" is not allowed to connect to this server.");
|
if (rDNS.HostName.Contains(ban) ||
|
||||||
m_log.Warn("[IPBAN] Disconnected '" + end + "' due to '" + ban + "' ban.");
|
end.ToString().StartsWith(ban))
|
||||||
return;
|
{
|
||||||
|
client.Disconnect("Banned - network \"" + ban + "\" is not allowed to connect to this server.");
|
||||||
|
m_log.Warn("[IPBAN] Disconnected '" + end + "' due to '" + ban + "' ban.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_log.Warn("[IPBAN] User '" + end + "' not in any ban lists. Allowing connection.");
|
catch (System.Net.Sockets.SocketException sex)
|
||||||
|
{
|
||||||
|
m_log.WarnFormat("[IPBAN] IP address \"{0}\" cannot be resolved via DNS", end);
|
||||||
|
}
|
||||||
|
m_log.WarnFormat("[IPBAN] User \"{0}\" not in any ban lists. Allowing connection.", end);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue