Adds style cop (#109)
This commit is contained in:
parent
3e715bcb60
commit
556a17aba8
1725 changed files with 33831 additions and 38046 deletions
|
|
@ -30,7 +30,7 @@ namespace Server
|
|||
object toAdd;
|
||||
|
||||
IPAddress addr;
|
||||
if ( IPAddress.TryParse( line, out addr ) )
|
||||
if (IPAddress.TryParse( line, out addr ))
|
||||
toAdd = addr;
|
||||
else
|
||||
toAdd = line;
|
||||
|
|
@ -41,7 +41,7 @@ namespace Server
|
|||
}
|
||||
}
|
||||
|
||||
public static List<IFirewallEntry> List{ get; }
|
||||
public static List<IFirewallEntry> List { get; }
|
||||
|
||||
public static IFirewallEntry ToFirewallEntry(object entry)
|
||||
{
|
||||
|
|
@ -60,7 +60,7 @@ namespace Server
|
|||
if (IPAddress.TryParse(entry, out IPAddress addr))
|
||||
return new IPFirewallEntry(addr);
|
||||
|
||||
//Try CIDR parse
|
||||
// Try CIDR parse
|
||||
string[] str = entry.Split('/');
|
||||
|
||||
if (str.Length == 2)
|
||||
|
|
@ -147,15 +147,15 @@ namespace Server
|
|||
|
||||
for ( int i = 0; !contains && i < m_Blocked.Count; ++i )
|
||||
{
|
||||
if ( m_Blocked[i] is IPAddress )
|
||||
if (m_Blocked[i] is IPAddress)
|
||||
contains = ip.Equals( m_Blocked[i] );
|
||||
else if ( m_Blocked[i] is String )
|
||||
else if (m_Blocked[i] is String)
|
||||
{
|
||||
string s = (string)m_Blocked[i];
|
||||
|
||||
contains = Utility.IPMatchCIDR( s, ip );
|
||||
|
||||
if ( !contains )
|
||||
if (!contains)
|
||||
contains = Utility.IPMatch( s, ip );
|
||||
}
|
||||
}
|
||||
|
|
@ -164,8 +164,6 @@ namespace Server
|
|||
* */
|
||||
}
|
||||
|
||||
#region Firewall Entries
|
||||
|
||||
public interface IFirewallEntry
|
||||
{
|
||||
bool IsBlocked(IPAddress address);
|
||||
|
|
@ -173,7 +171,7 @@ namespace Server
|
|||
|
||||
public class IPFirewallEntry : IFirewallEntry
|
||||
{
|
||||
private IPAddress m_Address;
|
||||
private readonly IPAddress m_Address;
|
||||
|
||||
public IPFirewallEntry(IPAddress address) => m_Address = address;
|
||||
|
||||
|
|
@ -203,8 +201,8 @@ namespace Server
|
|||
|
||||
public class CIDRFirewallEntry : IFirewallEntry
|
||||
{
|
||||
private int m_CIDRLength;
|
||||
private IPAddress m_CIDRPrefix;
|
||||
private readonly int m_CIDRLength;
|
||||
private readonly IPAddress m_CIDRPrefix;
|
||||
|
||||
public CIDRFirewallEntry(IPAddress cidrPrefix, int cidrLength)
|
||||
{
|
||||
|
|
@ -240,7 +238,7 @@ namespace Server
|
|||
|
||||
public class WildcardIPFirewallEntry : IFirewallEntry
|
||||
{
|
||||
private string m_Entry;
|
||||
private readonly string m_Entry;
|
||||
|
||||
private bool m_Valid;
|
||||
|
||||
|
|
@ -249,7 +247,7 @@ namespace Server
|
|||
public bool IsBlocked(IPAddress address)
|
||||
{
|
||||
if (!m_Valid)
|
||||
return false; //Why process if it's invalid? it'll return false anyway after processing it.
|
||||
return false; // Why process if it's invalid? it'll return false anyway after processing it.
|
||||
|
||||
bool matched = Utility.IPMatch(m_Entry, address, out bool valid);
|
||||
m_Valid = valid;
|
||||
|
|
@ -268,7 +266,5 @@ namespace Server
|
|||
|
||||
public override int GetHashCode() => m_Entry.GetHashCode();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue