aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules
diff options
context:
space:
mode:
authorJeff Ames2009-05-17 10:26:00 +0000
committerJeff Ames2009-05-17 10:26:00 +0000
commit5cfd84c92427658d88c4b36e1470744babd3d54d (patch)
tree5a08dd22f5866dd4e0cf0bdbed9353561390fa70 /OpenSim/Region/CoreModules
parentRemoving a superfluous message, just to make bamboo run again. (diff)
downloadopensim-SC_OLD-5cfd84c92427658d88c4b36e1470744babd3d54d.zip
opensim-SC_OLD-5cfd84c92427658d88c4b36e1470744babd3d54d.tar.gz
opensim-SC_OLD-5cfd84c92427658d88c4b36e1470744babd3d54d.tar.bz2
opensim-SC_OLD-5cfd84c92427658d88c4b36e1470744babd3d54d.tar.xz
Update svn properties.
Diffstat (limited to 'OpenSim/Region/CoreModules')
-rw-r--r--OpenSim/Region/CoreModules/Agent/IPBan/IPBanModule.cs162
-rw-r--r--OpenSim/Region/CoreModules/Agent/IPBan/SceneBanner.cs104
2 files changed, 133 insertions, 133 deletions
diff --git a/OpenSim/Region/CoreModules/Agent/IPBan/IPBanModule.cs b/OpenSim/Region/CoreModules/Agent/IPBan/IPBanModule.cs
index b904cb0..28e0382 100644
--- a/OpenSim/Region/CoreModules/Agent/IPBan/IPBanModule.cs
+++ b/OpenSim/Region/CoreModules/Agent/IPBan/IPBanModule.cs
@@ -1,81 +1,81 @@
1using System; 1using System;
2using System.Collections.Generic; 2using System.Collections.Generic;
3using System.IO; 3using System.IO;
4using System.Text; 4using System.Text;
5using Nini.Config; 5using Nini.Config;
6using OpenSim.Framework; 6using OpenSim.Framework;
7using OpenSim.Region.Framework.Interfaces; 7using OpenSim.Region.Framework.Interfaces;
8using OpenSim.Region.Framework.Scenes; 8using OpenSim.Region.Framework.Scenes;
9 9
10namespace OpenSim.Region.CoreModules.Agent.IPBan 10namespace OpenSim.Region.CoreModules.Agent.IPBan
11{ 11{
12 public class IPBanModule : IRegionModule 12 public class IPBanModule : IRegionModule
13 { 13 {
14 #region Implementation of IRegionModule 14 #region Implementation of IRegionModule
15 15
16 private List<string> m_bans = new List<string>(); 16 private List<string> m_bans = new List<string>();
17 17
18 public void Initialise(Scene scene, IConfigSource source) 18 public void Initialise(Scene scene, IConfigSource source)
19 { 19 {
20 new SceneBanner(scene, m_bans); 20 new SceneBanner(scene, m_bans);
21 21
22 lock(m_bans) 22 lock(m_bans)
23 { 23 {
24 foreach (EstateBan ban in scene.RegionInfo.EstateSettings.EstateBans) 24 foreach (EstateBan ban in scene.RegionInfo.EstateSettings.EstateBans)
25 { 25 {
26 if(!String.IsNullOrEmpty(ban.BannedHostIPMask)) 26 if(!String.IsNullOrEmpty(ban.BannedHostIPMask))
27 m_bans.Add(ban.BannedHostIPMask); 27 m_bans.Add(ban.BannedHostIPMask);
28 if (!String.IsNullOrEmpty(ban.BannedHostNameMask)) 28 if (!String.IsNullOrEmpty(ban.BannedHostNameMask))
29 m_bans.Add(ban.BannedHostNameMask); 29 m_bans.Add(ban.BannedHostNameMask);
30 } 30 }
31 } 31 }
32 } 32 }
33 33
34 public void PostInitialise() 34 public void PostInitialise()
35 { 35 {
36 if(File.Exists("bans.txt")) 36 if(File.Exists("bans.txt"))
37 { 37 {
38 string[] bans = File.ReadAllLines("bans.txt"); 38 string[] bans = File.ReadAllLines("bans.txt");
39 foreach (string ban in bans) 39 foreach (string ban in bans)
40 { 40 {
41 m_bans.Add(ban); 41 m_bans.Add(ban);
42 } 42 }
43 } 43 }
44 } 44 }
45 45
46 public void Close() 46 public void Close()
47 { 47 {
48 48
49 } 49 }
50 50
51 public string Name 51 public string Name
52 { 52 {
53 get { return "IPBanModule"; } 53 get { return "IPBanModule"; }
54 } 54 }
55 55
56 public bool IsSharedModule 56 public bool IsSharedModule
57 { 57 {
58 get { return true; } 58 get { return true; }
59 } 59 }
60 60
61 #endregion 61 #endregion
62 62
63 /// <summary> 63 /// <summary>
64 /// Bans all users from the specified network from connecting. 64 /// Bans all users from the specified network from connecting.
65 /// DNS bans are in the form "somewhere.com" will block ANY 65 /// DNS bans are in the form "somewhere.com" will block ANY
66 /// matching domain (including "betasomewhere.com", "beta.somewhere.com", 66 /// matching domain (including "betasomewhere.com", "beta.somewhere.com",
67 /// "somewhere.com.beta") - make sure to be reasonably specific in DNS 67 /// "somewhere.com.beta") - make sure to be reasonably specific in DNS
68 /// bans. 68 /// bans.
69 /// 69 ///
70 /// IP address bans match on first characters, so, 70 /// IP address bans match on first characters, so,
71 /// "127.0.0.1" will ban only that address, 71 /// "127.0.0.1" will ban only that address,
72 /// "127.0.1" will ban "127.0.10.0" 72 /// "127.0.1" will ban "127.0.10.0"
73 /// but "127.0.1." will ban only the "127.0.1.*" network 73 /// but "127.0.1." will ban only the "127.0.1.*" network
74 /// </summary> 74 /// </summary>
75 /// <param name="host">See summary for explanation of parameter</param> 75 /// <param name="host">See summary for explanation of parameter</param>
76 public void Ban(string host) 76 public void Ban(string host)
77 { 77 {
78 m_bans.Add(host); 78 m_bans.Add(host);
79 } 79 }
80 } 80 }
81} 81}
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 @@
1using System.Collections.Generic; 1using System.Collections.Generic;
2using System.Net; 2using System.Net;
3using OpenSim.Framework.Client; 3using OpenSim.Framework.Client;
4using OpenSim.Region.Framework.Scenes; 4using OpenSim.Region.Framework.Scenes;
5 5
6namespace OpenSim.Region.CoreModules.Agent.IPBan 6namespace 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}