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