public override void Update(Server server, float dt) { if (!loaded) { loaded = true; LoadBanlist(server); } if (server.banlist.ClearTimeBans() > 0) { SaveBanlist(server); } foreach (KeyValuePair <int, ClientOnServer> k in server.clients) { int clientId = k.Key; ClientOnServer c = k.Value; IPEndPointCi iep1 = c.socket.RemoteEndPoint(); if (server.banlist.IsIPBanned(iep1.AddressToString())) { IPEntry entry = server.banlist.GetIPEntry(iep1.AddressToString()); string reason = entry.Reason; if (string.IsNullOrEmpty(reason)) { reason = ""; } server.SendPacket(clientId, ServerPackets.DisconnectPlayer(string.Format(server.language.ServerIPBanned(), reason))); Console.WriteLine(string.Format("Banned IP {0} tries to connect.", iep1.AddressToString())); server.ServerEventLog(string.Format("Banned IP {0} tries to connect.", iep1.AddressToString())); server.KillPlayer(clientId); continue; } string username = c.playername; if (server.banlist.IsUserBanned(username)) { UserEntry entry = server.banlist.GetUserEntry(username); string reason = entry.Reason; if (string.IsNullOrEmpty(reason)) { reason = ""; } server.SendPacket(clientId, ServerPackets.DisconnectPlayer(string.Format(server.language.ServerUsernameBanned(), reason))); Console.WriteLine(string.Format("{0} fails to join (banned username: {1}).", (c.socket.RemoteEndPoint()).AddressToString(), username)); server.ServerEventLog(string.Format("{0} fails to join (banned username: {1}).", (c.socket.RemoteEndPoint()).AddressToString(), username)); server.KillPlayer(clientId); continue; } } }
public abstract void EnetHostInitialize(EnetHost host, IPEndPointCi address, int peerLimit, int channelLimit, int incomingBandwidth, int outgoingBandwidth);
public override void EnetHostInitialize(EnetHost host, IPEndPointCi address, int peerLimit, int channelLimit, int incomingBandwidth, int outgoingBandwidth) { if (address != null) { throw new Exception(); } EnetHostNative host_ = (EnetHostNative)host; host_.host.Initialize(null, peerLimit, channelLimit, incomingBandwidth, outgoingBandwidth); }