IP Ban in 5165

12/21/2009 07:11 majick#1
I cannot for the life of me get it implemented

Any help?
12/21/2009 09:20 -impulse-#2
First of all...you need to parse the IP from the connected socket, then check if it's in a banned list(that you should have) and if it does put socket.Disconnect(false);
12/21/2009 15:19 ~Falcon#3
Quote:
Originally Posted by -impulse- View Post
First of all...you need to parse the IP from the connected socket, then check if it's in a banned list(that you should have) and if it does put socket.Disconnect(false);
RemoteEndPoint.ToString().Split(':')[0];
12/21/2009 15:31 Nullable#4
Code:
// Read the ips from a file, text file or whatever you like to use if you are going to use other database types then you are on your own
string[] BannedClients = File.ReadAllText(<banned ips list path>).Split('\r', '\n');
// Iterate through the array
foreach(string Client in BannedClients)
{
     if(<Socket refrence name>.RemoteEndPoint.ToString().Split(':')[0] == Client)
           <Socket refrence name>.Disconnect(false);
    // Then if you have a list of clients or whatever which you should have then you should remove the client from the List<T> or Dictionary<T Key, T Value>
}