28 using System.Collections.Generic;
30 using OpenSim.Framework.Client;
31 using OpenSim.Region.Framework.Scenes;
35 internal class SceneBanner
37 private static readonly log4net.ILog m_log
38 = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
40 private List<string> bans;
42 public SceneBanner(
SceneBase scene, List<string> banList)
44 scene.EventManager.OnClientConnect += EventManager_OnClientConnect;
50 void EventManager_OnClientConnect(
IClientCore client)
56 if (client.TryGet(out ipEndpoint))
58 IPAddress end = ipEndpoint.EndPoint;
62 IPHostEntry rDNS = Dns.GetHostEntry(end);
63 foreach (
string ban
in bans)
65 if (rDNS.HostName.Contains(ban) ||
66 end.ToString().StartsWith(ban))
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.");
74 catch (System.Net.Sockets.SocketException)
76 m_log.WarnFormat(
"[IPBAN] IP address \"{0}\" cannot be resolved via DNS", end);