초기커밋
This commit is contained in:
162
ServerCommon/z.Backup/AccountAuthorityManager.cs
Normal file
162
ServerCommon/z.Backup/AccountAuthorityManager.cs
Normal file
@@ -0,0 +1,162 @@
|
||||
//using ServerCore; using ServerBase;
|
||||
//using System.Collections.Concurrent;
|
||||
//using System.Text.RegularExpressions;
|
||||
|
||||
|
||||
|
||||
|
||||
//namespace ServerCommon
|
||||
//{
|
||||
// public class AccountAuthorityManager
|
||||
// {
|
||||
// private static readonly AccountAuthorityManager _instance = new();
|
||||
// static AccountAuthorityManager() { }
|
||||
// private AccountAuthorityManager() { }
|
||||
// public static AccountAuthorityManager Instance { get { return _instance; } }
|
||||
|
||||
// public bool isInspection { get; set; } = false;
|
||||
// public bool isReadyForDistroy { get; set; } = false;
|
||||
|
||||
// MainDB? _mainDB = null;
|
||||
// BlackListEntity _blackListEntity = new();
|
||||
// WhiteListEntity _whiteListEntity = new();
|
||||
|
||||
// ReaderWriterLockSlim rwWhiteListLock = new();
|
||||
// ReaderWriterLockSlim rwBlackListLock = new();
|
||||
|
||||
// public async Task<bool> LoadDB(MainDB mainDB)
|
||||
// {
|
||||
// if (mainDB == null)
|
||||
// {
|
||||
// return false;
|
||||
// }
|
||||
// _mainDB = mainDB;
|
||||
|
||||
// if (await UpdateWhiteList() == false)
|
||||
// {
|
||||
// return false;
|
||||
// }
|
||||
|
||||
// if (await UpdateBlackList() == false)
|
||||
// {
|
||||
// return false;
|
||||
// }
|
||||
|
||||
// return true;
|
||||
// }
|
||||
|
||||
// public async Task<bool> UpdateWhiteList()
|
||||
// {
|
||||
// if (_mainDB == null)
|
||||
// {
|
||||
// Log.getLogger().error("_mainDB == null");
|
||||
// return false;
|
||||
// }
|
||||
|
||||
// WhiteListEntity? whiteList = await _mainDB.GetWhiteListData();
|
||||
// if (whiteList == null)
|
||||
// {
|
||||
// whiteList = await _mainDB.AddWhiteList();
|
||||
// if (whiteList == null)
|
||||
// {
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
|
||||
// rwWhiteListLock.EnterWriteLock();
|
||||
// try
|
||||
// {
|
||||
// _whiteListEntity = whiteList;
|
||||
// return true;
|
||||
// }
|
||||
// finally { rwWhiteListLock.ExitWriteLock(); }
|
||||
// }
|
||||
|
||||
// public async Task<bool> UpdateBlackList()
|
||||
// {
|
||||
// if (_mainDB == null)
|
||||
// {
|
||||
// Log.getLogger().error("_mainDB == null");
|
||||
// return false;
|
||||
// }
|
||||
|
||||
// BlackListEntity? blackList = await _mainDB.GetBlackListData();
|
||||
// if (blackList == null)
|
||||
// {
|
||||
// blackList = await _mainDB.AddBlackList();
|
||||
// if (blackList == null)
|
||||
// {
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
|
||||
// rwBlackListLock.EnterWriteLock();
|
||||
// try
|
||||
// {
|
||||
// _blackListEntity = blackList;
|
||||
// return true;
|
||||
// }
|
||||
// finally { rwBlackListLock.ExitWriteLock(); }
|
||||
// }
|
||||
|
||||
// public bool IsWhiteListUser(string accountId)
|
||||
// {
|
||||
// rwWhiteListLock.EnterReadLock();
|
||||
// try
|
||||
// {
|
||||
// if(_whiteListEntity.Attr.WhiteListByID.TryGetValue(accountId, out var value) == true)
|
||||
// {
|
||||
// return true;
|
||||
// }
|
||||
// foreach(var pattern in _whiteListEntity.Attr.WhiteListByPattern)
|
||||
// {
|
||||
// Regex regex = new Regex(@pattern.Key);
|
||||
// if (regex.IsMatch(accountId))
|
||||
// {
|
||||
// return true;
|
||||
// }
|
||||
// }
|
||||
|
||||
// return false;
|
||||
// }
|
||||
// finally { rwWhiteListLock.ExitReadLock();}
|
||||
// }
|
||||
|
||||
// public bool IsBlockUser(AccountEntity myAccountEntity)
|
||||
// {
|
||||
// DateTime dt = DateTime.Now;
|
||||
// if (myAccountEntity.Attr.BlockStartDate <= dt && dt <= myAccountEntity.Attr.BlockEndDate)
|
||||
// {
|
||||
// return true;
|
||||
// }
|
||||
// return false;
|
||||
// }
|
||||
|
||||
// public bool IsBlackListUser(string accountId)
|
||||
// {
|
||||
// rwBlackListLock.EnterReadLock();
|
||||
// try
|
||||
// {
|
||||
// if (_blackListEntity.Attr.BlackListByID.TryGetValue(accountId, out var blackList) == true)
|
||||
// {
|
||||
// if(DateTime.Compare(DateTime.Now, blackList) < 0)
|
||||
// {
|
||||
// return true;
|
||||
// }
|
||||
// }
|
||||
// foreach (var pattern in _blackListEntity.Attr.BlackListByPattern)
|
||||
// {
|
||||
// Regex regex = new Regex(@pattern.Key);
|
||||
// if (regex.IsMatch(accountId)
|
||||
// && DateTime.Compare(DateTime.Now, pattern.Value) < 0)
|
||||
// {
|
||||
// return true;
|
||||
// }
|
||||
// }
|
||||
|
||||
// return false;
|
||||
// }
|
||||
// finally { rwBlackListLock.ExitReadLock();}
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
Reference in New Issue
Block a user