mirror of
https://github.com/project-redbud/FunGame-Server.git
synced 2025-04-20 19:19:39 +08:00
添加BannedList
This commit is contained in:
parent
f7025ed27c
commit
8db0dd9fa1
@ -84,6 +84,7 @@ void StartServer()
|
||||
ListeningSocket = ServerSocket.StartListening();
|
||||
|
||||
// 开始监听连接
|
||||
AddBannedList(ListeningSocket);
|
||||
Config.RoomList = new(ListeningSocket);
|
||||
ServerHelper.WriteLine("Listen -> " + Config.ServerPort);
|
||||
ServerHelper.WriteLine("服务器启动成功,开始监听 . . .");
|
||||
@ -110,7 +111,7 @@ void StartServer()
|
||||
}
|
||||
Config.ConnectingPlayersCount++;
|
||||
ServerHelper.WriteLine(SocketHelper.MakeClientName(ClientIPAddress) + " 正在连接服务器 . . .");
|
||||
if (Config.BannedList.ContainsKey(ClientIPAddress))
|
||||
if (ListeningSocket.BannedList.Contains(ClientIPAddress))
|
||||
{
|
||||
SendRefuseConnect(socket, "服务器已拒绝黑名单用户连接。");
|
||||
ServerHelper.WriteLine("检测到 " + SocketHelper.MakeClientName(ClientIPAddress) + " 为黑名单用户,已禁止其连接!");
|
||||
@ -212,4 +213,13 @@ SQLResult TestSQLConnection()
|
||||
{
|
||||
new MySQLHelper(ServerLoginLogs.Insert_ServerLoginLogs(Config.ServerName, Config.ServerKey)).Execute(out SQLResult TestResult);
|
||||
return TestResult;
|
||||
}
|
||||
|
||||
void AddBannedList(ServerSocket server)
|
||||
{
|
||||
string[] bans = Config.ServerBannedList.Split(',');
|
||||
foreach (string banned in bans)
|
||||
{
|
||||
server.BannedList.Add(banned);
|
||||
}
|
||||
}
|
@ -14,6 +14,7 @@ namespace Milimoe.FunGame.Server.Others
|
||||
public static string ServerPassword { get; set; } = ""; // 服务器的密码
|
||||
public static string ServerDescription { get; set; } = ""; // 服务器的描述
|
||||
public static string ServerKey { get; set; } = ""; // 注册社区服务器的Key
|
||||
public static string ServerBannedList { get; set; } = ""; // 禁止连接的黑名单
|
||||
public static int MaxPlayers { get; set; } = 20; // 最多接受连接的玩家数量
|
||||
public static int MaxConnectionFaileds { get; set; } = 5; // 最大连接失败次数
|
||||
public static int OnlinePlayersCount { get; set; } = 0; // 已连接的玩家数量
|
||||
@ -21,7 +22,6 @@ namespace Milimoe.FunGame.Server.Others
|
||||
public static Encoding DefaultEncoding { get; } = General.DefaultEncoding; // 默认传输字符集
|
||||
public static FunGameInfo.FunGame FunGameType { get; } = FunGameInfo.FunGame.FunGame_Server;
|
||||
public static Hashtable OrderList { get; } = new();
|
||||
public static Hashtable BannedList { get; } = new();
|
||||
public static RoomList? RoomList { get; set; }
|
||||
}
|
||||
|
||||
|
@ -40,6 +40,7 @@ namespace Milimoe.FunGame.Server.Utility
|
||||
settings.Add("Notice", INIHelper.ReadINI("Server", "Notice"));
|
||||
settings.Add("Key", INIHelper.ReadINI("Server", "Key"));
|
||||
settings.Add("Status", Convert.ToInt32(INIHelper.ReadINI("Server", "Status")));
|
||||
settings.Add("BannedList", INIHelper.ReadINI("Server", "BannedList"));
|
||||
settings.Add("OfficialMail", INIHelper.ReadINI("ServerMail", "OfficialMail"));
|
||||
settings.Add("SupportMail", INIHelper.ReadINI("ServerMail", "SupportMail"));
|
||||
settings.Add("Port", Convert.ToInt32(INIHelper.ReadINI("Socket", "Port")));
|
||||
@ -61,19 +62,26 @@ namespace Milimoe.FunGame.Server.Utility
|
||||
string? Describe = (string?)settings["Describe"];
|
||||
string? Notice = (string?)settings["Notice"];
|
||||
string? Key = (string?)settings["Key"];
|
||||
string? BannedList = (string?)settings["BannedList"];
|
||||
|
||||
if (Name != null) Config.ServerName = Name;
|
||||
if (Password != null) Config.ServerPassword = Password;
|
||||
if (Describe != null) Config.ServerDescription = Describe;
|
||||
if (Notice != null) Config.ServerNotice = Notice;
|
||||
if (Key != null) Config.ServerKey = Key;
|
||||
if (BannedList != null) Config.ServerBannedList = BannedList;
|
||||
|
||||
string? OfficialMail = (string?)settings["OfficialMail"];
|
||||
string? SupportMail = (string?)settings["SupportMail"];
|
||||
|
||||
if (OfficialMail != null) OfficialEmail.Email = OfficialMail;
|
||||
if (SupportMail != null) OfficialEmail.SupportEmail = SupportMail;
|
||||
|
||||
int? Status = (int?)settings["Status"];
|
||||
int? Port = (int?)settings["Port"];
|
||||
int? MaxPlayer = (int?)settings["MaxPlayer"];
|
||||
int? MaxConnectFailed = (int?)settings["MaxConnectFailed"];
|
||||
|
||||
if (Status != null) Config.ServerStatus = (int)Status;
|
||||
if (Port != null) Config.ServerPort = (int)Port;
|
||||
if (MaxPlayer != null) Config.MaxPlayers = (int)MaxPlayer;
|
||||
|
Loading…
x
Reference in New Issue
Block a user