Пример #1
0
 public static bool IsBanned(RemoteAddress address)
 {
     try
     {
         string identifier = address.GetIdentifier();
         if (System.IO.File.Exists(Netplay.BanFilePath))
         {
             using (StreamReader streamReader = new StreamReader(Netplay.BanFilePath))
             {
                 string str;
                 while ((str = streamReader.ReadLine()) != null)
                 {
                     if (str == identifier)
                     {
                         return(true);
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
     }
     return(false);
 }
Пример #2
0
 public static bool IsBanned(RemoteAddress address)
 {
     try
     {
         string identifier = address.GetIdentifier();
         if (File.Exists(BanFilePath))
         {
             using (StreamReader streamReader = new StreamReader(BanFilePath))
             {
                 string a;
                 while ((a = streamReader.ReadLine()) != null)
                 {
                     if (a == identifier)
                     {
                         return(true);
                     }
                 }
             }
         }
     }
     catch (Exception)
     {
     }
     return(false);
 }
Пример #3
0
        public static bool IsBanned(RemoteAddress address)
        {
            try
            {
                string identifier = address.GetIdentifier();
                if (File.Exists(Netplay.BanFilePath))
                {
                    using (StreamReader streamReader = new StreamReader(Netplay.BanFilePath))
                    {
                        string a;
                        while ((a = streamReader.ReadLine()) != null)
                        {
                            if (a == identifier)
                            {
                                return(true);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
#if DEBUG
                Console.WriteLine(ex);
                System.Diagnostics.Debugger.Break();
#endif
            }
            return(false);
        }
Пример #4
0
        public static void AddBan(int plr)
        {
            RemoteAddress remoteAddress = Clients[plr].Socket.GetRemoteAddress();

            using StreamWriter streamWriter = new StreamWriter(BanFilePath, append: true);
            streamWriter.WriteLine("//" + Main.player[plr].name);
            streamWriter.WriteLine(remoteAddress.GetIdentifier());
        }