diff options
Diffstat (limited to 'OpenSim/Region/CoreModules/Agent/IPBan/SceneBanner.cs')
-rw-r--r-- | OpenSim/Region/CoreModules/Agent/IPBan/SceneBanner.cs | 104 |
1 files changed, 52 insertions, 52 deletions
diff --git a/OpenSim/Region/CoreModules/Agent/IPBan/SceneBanner.cs b/OpenSim/Region/CoreModules/Agent/IPBan/SceneBanner.cs index 20a2159..a5e9963 100644 --- a/OpenSim/Region/CoreModules/Agent/IPBan/SceneBanner.cs +++ b/OpenSim/Region/CoreModules/Agent/IPBan/SceneBanner.cs | |||
@@ -1,52 +1,52 @@ | |||
1 | using System.Collections.Generic; | 1 | using System.Collections.Generic; |
2 | using System.Net; | 2 | using System.Net; |
3 | using OpenSim.Framework.Client; | 3 | using OpenSim.Framework.Client; |
4 | using OpenSim.Region.Framework.Scenes; | 4 | using OpenSim.Region.Framework.Scenes; |
5 | 5 | ||
6 | namespace OpenSim.Region.CoreModules.Agent.IPBan | 6 | namespace OpenSim.Region.CoreModules.Agent.IPBan |
7 | { | 7 | { |
8 | internal class SceneBanner | 8 | internal class SceneBanner |
9 | { | 9 | { |
10 | private static readonly log4net.ILog m_log | 10 | private static readonly log4net.ILog m_log |
11 | = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | 11 | = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); |
12 | 12 | ||
13 | private List<string> bans; | 13 | private List<string> bans; |
14 | private SceneBase m_scene; | 14 | private SceneBase m_scene; |
15 | public SceneBanner(SceneBase scene, List<string> banList) | 15 | public SceneBanner(SceneBase scene, List<string> banList) |
16 | { | 16 | { |
17 | scene.EventManager.OnClientConnect += EventManager_OnClientConnect; | 17 | scene.EventManager.OnClientConnect += EventManager_OnClientConnect; |
18 | 18 | ||
19 | bans = banList; | 19 | bans = banList; |
20 | m_scene = scene; | 20 | m_scene = scene; |
21 | } | 21 | } |
22 | 22 | ||
23 | void EventManager_OnClientConnect(IClientCore client) | 23 | void EventManager_OnClientConnect(IClientCore client) |
24 | { | 24 | { |
25 | IClientIPEndpoint ipEndpoint; | 25 | IClientIPEndpoint ipEndpoint; |
26 | if(client.TryGet(out ipEndpoint)) | 26 | if(client.TryGet(out ipEndpoint)) |
27 | { | 27 | { |
28 | IPAddress end = ipEndpoint.EndPoint; | 28 | IPAddress end = ipEndpoint.EndPoint; |
29 | 29 | ||
30 | try | 30 | try |
31 | { | 31 | { |
32 | IPHostEntry rDNS = Dns.GetHostEntry(end); | 32 | IPHostEntry rDNS = Dns.GetHostEntry(end); |
33 | foreach (string ban in bans) | 33 | foreach (string ban in bans) |
34 | { | 34 | { |
35 | if (rDNS.HostName.Contains(ban) || | 35 | if (rDNS.HostName.Contains(ban) || |
36 | end.ToString().StartsWith(ban)) | 36 | end.ToString().StartsWith(ban)) |
37 | { | 37 | { |
38 | client.Disconnect("Banned - network \"" + ban + "\" is not allowed to connect to this server."); | 38 | client.Disconnect("Banned - network \"" + ban + "\" is not allowed to connect to this server."); |
39 | m_log.Warn("[IPBAN] Disconnected '" + end + "' due to '" + ban + "' ban."); | 39 | m_log.Warn("[IPBAN] Disconnected '" + end + "' due to '" + ban + "' ban."); |
40 | return; | 40 | return; |
41 | } | 41 | } |
42 | } | 42 | } |
43 | } | 43 | } |
44 | catch (System.Net.Sockets.SocketException sex) | 44 | catch (System.Net.Sockets.SocketException sex) |
45 | { | 45 | { |
46 | m_log.WarnFormat("[IPBAN] IP address \"{0}\" cannot be resolved via DNS", end); | 46 | m_log.WarnFormat("[IPBAN] IP address \"{0}\" cannot be resolved via DNS", end); |
47 | } | 47 | } |
48 | m_log.WarnFormat("[IPBAN] User \"{0}\" not in any ban lists. Allowing connection.", end); | 48 | m_log.WarnFormat("[IPBAN] User \"{0}\" not in any ban lists. Allowing connection.", end); |
49 | } | 49 | } |
50 | } | 50 | } |
51 | } | 51 | } |
52 | } | 52 | } |