Targets .NET Core 3.0 (#39)

This commit is contained in:
Kamron Batman 2019-08-02 17:53:18 -07:00 • committed by GitHub
parent 0993c03b70
commit 08bf44af9a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
125 changed files with 1473 additions and 14244 deletions

View file

@ -807,17 +807,15 @@ namespace Server.Accounting
return list;
}
/// <summary>
/// Checks if a specific NetState is allowed access to this account.
/// </summary>
/// <param name="ns">NetState instance to check.</param>
/// <returns>True if allowed, false if not.</returns>
public bool HasAccess( NetState ns )
{
return ( ns != null && HasAccess( ns.Address ) );
}
/// <summary>
/// Checks if a specific NetState is allowed access to this account.
/// </summary>
/// <param name="ns">NetState instance to check.</param>
/// <returns>True if allowed, false if not.</returns>
public bool HasAccess(NetState ns) => ns != null && HasAccess(ns.Address);
public bool HasAccess( IPAddress ipAddress ) {
public bool HasAccess( IPAddress ipAddress )
{
AccessLevel level = AccountHandler.LockdownLevel;
if ( level > AccessLevel.Player )
@ -825,9 +823,7 @@ namespace Server.Accounting
bool hasAccess = false;
if ( m_AccessLevel >= level )
{
hasAccess = true;
}
else
{
for ( int i = 0; !hasAccess && i < Length; ++i )
@ -839,11 +835,13 @@ namespace Server.Accounting
}
}
if ( !hasAccess )
Console.WriteLine("{0} {1}", hasAccess ? "yes" : "no", m_AccessLevel);
if ( !hasAccess )
return false;
}
bool accessAllowed = ( IPRestrictions.Length == 0 || IPLimiter.IsExempt( ipAddress ) );
bool accessAllowed = IPRestrictions.Length == 0 || IPLimiter.IsExempt( ipAddress );
for ( int i = 0; !accessAllowed && i < IPRestrictions.Length; ++i )
accessAllowed = Utility.IPMatch( IPRestrictions[i], ipAddress );
@ -903,9 +901,8 @@ namespace Server.Accounting
public bool CheckAccess( IPAddress ipAddress ) {
bool hasAccess = HasAccess( ipAddress );
if ( hasAccess ) {
if ( hasAccess )
LogAccess( ipAddress );
}
return hasAccess;
}

View file

@ -22,14 +22,16 @@ namespace Server.Accounting
PacketHandlers.RegisterThrottler(0xCF, Throttle_Callback);
}
public static bool Throttle_Callback(NetState ns)
public static TimeSpan Throttle_Callback(NetState ns)
{
InvalidAccountAccessLog accessLog = FindAccessLog(ns);
if (accessLog == null)
return true;
return TimeSpan.Zero;
return DateTime.UtcNow >= accessLog.LastAccessTime + ComputeThrottle(accessLog.Counts);
DateTime date = DateTime.UtcNow;
DateTime access = accessLog.LastAccessTime + ComputeThrottle(accessLog.Counts);
return date >= access ? TimeSpan.Zero : date - access;
}
public static InvalidAccountAccessLog FindAccessLog(NetState ns)
@ -126,4 +128,4 @@ namespace Server.Accounting
LastAccessTime = DateTime.UtcNow;
}
}
}
}

View file

@ -315,8 +315,8 @@ namespace Server.Misc
if (!(Accounts.GetAccount(un) is Account acct))
{
if (AutoAccountCreation && un.Trim().Length > 0
) // To prevent someone from making an account of just '' or a bunch of meaningless spaces
// To prevent someone from making an account of just '' or a bunch of meaningless spaces
if (AutoAccountCreation && un.Trim().Length > 0)
{
e.State.Account = acct = CreateAccount(e.State, un, pw);
e.Accepted = acct?.CheckAccess(e.State) ?? false;