Fixes code according to modern code style. Fixes a few expression bugs.
This commit is contained in:
parent
89eea25e5f
commit
970fd563b2
3324 changed files with 441118 additions and 433755 deletions
|
|
@ -4,51 +4,50 @@ using Server.Network;
|
|||
|
||||
namespace Server.Misc
|
||||
{
|
||||
public class IPLimiter
|
||||
{
|
||||
public static bool Enabled = true;
|
||||
public static bool SocketBlock = true; // true to block at connection, false to block at login request
|
||||
public class IPLimiter
|
||||
{
|
||||
public static bool Enabled = true;
|
||||
public static bool SocketBlock = true; // true to block at connection, false to block at login request
|
||||
|
||||
public static int MaxAddresses = 10;
|
||||
|
||||
public static IPAddress[] Exemptions = {
|
||||
//IPAddress.Parse( "127.0.0.1" ),
|
||||
};
|
||||
public static int MaxAddresses = 10;
|
||||
|
||||
public static bool IsExempt( IPAddress ip )
|
||||
{
|
||||
for ( int i = 0; i < Exemptions.Length; i++ )
|
||||
{
|
||||
if ( ip.Equals( Exemptions[i] ) )
|
||||
return true;
|
||||
}
|
||||
public static IPAddress[] Exemptions =
|
||||
{
|
||||
//IPAddress.Parse( "127.0.0.1" ),
|
||||
};
|
||||
|
||||
return false;
|
||||
}
|
||||
public static bool IsExempt(IPAddress ip)
|
||||
{
|
||||
for (int i = 0; i < Exemptions.Length; i++)
|
||||
if (ip.Equals(Exemptions[i]))
|
||||
return true;
|
||||
|
||||
public static bool Verify( IPAddress ourAddress )
|
||||
{
|
||||
if ( !Enabled || IsExempt( ourAddress ) )
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
List<NetState> netStates = NetState.Instances;
|
||||
public static bool Verify(IPAddress ourAddress)
|
||||
{
|
||||
if (!Enabled || IsExempt(ourAddress))
|
||||
return true;
|
||||
|
||||
int count = 0;
|
||||
List<NetState> netStates = NetState.Instances;
|
||||
|
||||
for ( int i = 0; i < netStates.Count; ++i )
|
||||
{
|
||||
NetState compState = netStates[i];
|
||||
int count = 0;
|
||||
|
||||
if ( ourAddress.Equals( compState.Address ) )
|
||||
{
|
||||
++count;
|
||||
for (int i = 0; i < netStates.Count; ++i)
|
||||
{
|
||||
NetState compState = netStates[i];
|
||||
|
||||
if ( count >= MaxAddresses )
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (ourAddress.Equals(compState.Address))
|
||||
{
|
||||
++count;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (count >= MaxAddresses)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue