Exemple #1
0
        internal bool InvokeServerConnect(int who)
        {
            ConnectEventArgs args = new ConnectEventArgs
            {
                Who = who
            };

            this.ServerConnect.Invoke(args);
            return(args.Handled);
        }
Exemple #2
0
        internal bool InvokeServerConnect(int who)
        {
            if (Netplay.Clients[who].State != 0)
            {
                return(false);
            }

            ConnectEventArgs args = new ConnectEventArgs
            {
                Who = who
            };

            this.ServerConnect.Invoke(args);
            return(args.Handled);
        }
		internal bool InvokeServerConnect(int who)
		{
			ConnectEventArgs args = new ConnectEventArgs
			{
				Who = who
			};

			this.ServerConnect.Invoke(args);
			return args.Handled;
		}
Exemple #4
0
        /// <summary>OnConnect - Fired when a player connects to the server.</summary>
        /// <param name="args">args - The ConnectEventArgs object.</param>
        private void OnConnect(ConnectEventArgs args)
        {
            var player = new TSPlayer(args.Who);

            if (Utils.ActivePlayers() + 1 > Config.MaxSlots + Config.ReservedSlots)
            {
                Utils.ForceKick(player, Config.ServerFullNoReservedReason, true, false);
                args.Handled = true;
                return;
            }

            if (!FileTools.OnWhitelist(player.IP))
            {
                Utils.ForceKick(player, Config.WhitelistKickReason, true, false);
                args.Handled = true;
                return;
            }

            if (Geo != null)
            {
                var code = Geo.TryGetCountryCode(IPAddress.Parse(player.IP));
                player.Country = code == null ? "N/A" : GeoIPCountry.GetCountryNameByCode(code);
                if (code == "A1")
                {
                    if (Config.KickProxyUsers)
                    {
                        Utils.ForceKick(player, "Proxies are not allowed.", true, false);
                        args.Handled = true;
                        return;
                    }
                }
            }
            Players[args.Who] = player;
        }
Exemple #5
0
        private void OnConnect(ConnectEventArgs e)
        {
            var player = new TSPlayer(e.Who);
            if (player == null)
            {
                e.Handled = true;
                return;
            }

            string[] ban = EBUtils.IPBanInfo(player.IP);

            if (ban[0] == "banned")
            {
                TShock.Utils.Kick(player, string.Format("You are banned: {0}", ban[5]), true, true, null, true);
                e.Handled = true;
                return;
            }
        }
 public void OnConnect(ConnectEventArgs e)
 {
     string[] blProvider = GetDNSBLServer().ToArray();
     CheckProxy m_checker= new CheckProxy(TShock.Players[e.Who].IP,blProvider);
     if (!CheckWhitelist(TShock.Players[e.Who].IP))
     {
         if (m_checker.IPAddr.Valid)
         {
             if (m_checker.BlackList.IsListed)
             {
                 TShock.Utils.ForceKick(TShock.Players[e.Who],
                                        string.Format("You are listed on the blacklist at {0}.",
                                                      m_checker.BlackList.VerifiedOnServer), true, false);
                 Log.ConsoleInfo(string.Format("{0} was found on the blacklist at {1}", TShock.Players[e.Who].IP,
                                               m_checker.BlackList.VerifiedOnServer));
                 e.Handled = true;
                 return;
             }
         }
     }
 }
Exemple #7
0
 /// <summary>
 /// ServerConnect callback.
 /// </summary>
 /// <param name="args"></param>
 private void OnServerConnect(ConnectEventArgs args)
 {
     lock (this.m_AddonsLock)
     {
         this.m_Addons.ForEach(a =>
             {
                 var ret = a.Value.InvokeEvent("ServerConnect", args);
                 if (ret != null && ret.Length >= 1)
                 {
                     bool result;
                     if (bool.TryParse(ret[0].ToString(), out result) && result)
                         args.Handled = true;
                 }
             });
     }
 }
Exemple #8
0
        private void OnConnect(ConnectEventArgs args)
        {
            var player = new TSPlayer(args.Who);
            string host = SQL.GetHostFromCache(player.IP);
            if (host == null)
            {
                try
                {
                    System.Net.IPHostEntry hostname = System.Net.Dns.GetHostByAddress(player.IP);
                    host = hostname.HostName;
                }
                catch (Exception e)
                {
                    host = player.IP;
                }
                SQL.InsertCacheEntry(host, player.IP);

            }
            SQL.HostBan ban = SQL.GetBanByHost(host);
            if (ban != null)
            {
                    TShock.Utils.ForceKick(player, string.Format("Banned for: {0}.", ban.Reason), true, false);
                    args.Handled = true;
                    return;
            }
        }