Skip to content

Commit b646094

Browse files
author
paezao
committed
1 parent cd63927 commit b646094

File tree

2,395 files changed

+368397
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,395 files changed

+368397
-0
lines changed
+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
using System;
2+
using System.IO;
3+
using System.Net;
4+
using System.Net.Sockets;
5+
using Server;
6+
using Server.Misc;
7+
8+
namespace Server
9+
{
10+
public class AccessRestrictions
11+
{
12+
public static void Initialize()
13+
{
14+
EventSink.SocketConnect += new SocketConnectEventHandler( EventSink_SocketConnect );
15+
}
16+
17+
private static void EventSink_SocketConnect( SocketConnectEventArgs e )
18+
{
19+
try
20+
{
21+
IPAddress ip = ((IPEndPoint)e.Socket.RemoteEndPoint).Address;
22+
23+
if ( Firewall.IsBlocked( ip ) )
24+
{
25+
Console.WriteLine( "Client: {0}: Firewall blocked connection attempt.", ip );
26+
e.AllowConnection = false;
27+
return;
28+
}
29+
else if ( IPLimiter.SocketBlock && !IPLimiter.Verify( ip ) )
30+
{
31+
Console.WriteLine( "Client: {0}: Past IP limit threshold", ip );
32+
33+
using ( StreamWriter op = new StreamWriter( "ipLimits.log", true ) )
34+
op.WriteLine( "{0}\tPast IP limit threshold\t{1}", ip, DateTime.Now );
35+
36+
e.AllowConnection = false;
37+
return;
38+
}
39+
}
40+
catch
41+
{
42+
e.AllowConnection = false;
43+
}
44+
}
45+
}
46+
}

0 commit comments

Comments
 (0)