fixing SocketException when IP address cannot be resolved

0.6.5-rc1
Dr Scofield 2009-05-12 14:57:42 +00:00
parent 68da7d1a43
commit c81c9e712c
1 changed files with 15 additions and 8 deletions

View File

@ -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);
} }
} }
} }