aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/CoreModules/Agent/IPBan/SceneBanner.cs42
1 files changed, 23 insertions, 19 deletions
diff --git a/OpenSim/Region/CoreModules/Agent/IPBan/SceneBanner.cs b/OpenSim/Region/CoreModules/Agent/IPBan/SceneBanner.cs
index dbfcfee..6efd090 100644
--- a/OpenSim/Region/CoreModules/Agent/IPBan/SceneBanner.cs
+++ b/OpenSim/Region/CoreModules/Agent/IPBan/SceneBanner.cs
@@ -34,7 +34,7 @@ namespace OpenSim.Region.CoreModules.Agent.IPBan
34{ 34{
35 internal class SceneBanner 35 internal class SceneBanner
36 { 36 {
37 private static readonly log4net.ILog m_log 37 private static readonly log4net.ILog m_log
38 = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); 38 = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
39 39
40 private List<string> bans; 40 private List<string> bans;
@@ -49,30 +49,34 @@ namespace OpenSim.Region.CoreModules.Agent.IPBan
49 49
50 void EventManager_OnClientConnect(IClientCore client) 50 void EventManager_OnClientConnect(IClientCore client)
51 { 51 {
52 IClientIPEndpoint ipEndpoint; 52 // Only need to run through all this if there are entries in the ban list
53 if (client.TryGet(out ipEndpoint)) 53 if (bans.Count > 0)
54 { 54 {
55 IPAddress end = ipEndpoint.EndPoint; 55 IClientIPEndpoint ipEndpoint;
56 56 if (client.TryGet(out ipEndpoint))
57 try
58 { 57 {
59 IPHostEntry rDNS = Dns.GetHostEntry(end); 58 IPAddress end = ipEndpoint.EndPoint;
60 foreach (string ban in bans) 59
60 try
61 { 61 {
62 if (rDNS.HostName.Contains(ban) || 62 IPHostEntry rDNS = Dns.GetHostEntry(end);
63 end.ToString().StartsWith(ban)) 63 foreach (string ban in bans)
64 { 64 {
65 client.Disconnect("Banned - network \"" + ban + "\" is not allowed to connect to this server."); 65 if (rDNS.HostName.Contains(ban) ||
66 m_log.Warn("[IPBAN] Disconnected '" + end + "' due to '" + ban + "' ban."); 66 end.ToString().StartsWith(ban))
67 return; 67 {
68 client.Disconnect("Banned - network \"" + ban + "\" is not allowed to connect to this server.");
69 m_log.Warn("[IPBAN] Disconnected '" + end + "' due to '" + ban + "' ban.");
70 return;
71 }
68 } 72 }
69 } 73 }
74 catch (System.Net.Sockets.SocketException sex)
75 {
76 m_log.WarnFormat("[IPBAN] IP address \"{0}\" cannot be resolved via DNS", end);
77 }
78 // m_log.DebugFormat("[IPBAN] User \"{0}\" not in any ban lists. Allowing connection.", end);
70 } 79 }
71 catch (System.Net.Sockets.SocketException sex)
72 {
73 m_log.WarnFormat("[IPBAN] IP address \"{0}\" cannot be resolved via DNS", end);
74 }
75 m_log.WarnFormat("[IPBAN] User \"{0}\" not in any ban lists. Allowing connection.", end);
76 } 80 }
77 } 81 }
78 } 82 }