Thread: Ip Banning in the server Class

Results 1 to 9 of 9
  1. #1 Ip Banning in the server Class 
    Whitey
    Guest
    Firstly, Find
    Code:
    String connectingHost = s.getInetAddress().getHostName();
    Below it, add
    Code:
                    if(blocked == true)
                        {
                        s.close();
                        }
    Now, above
    Code:
    public void run() {
    add
    Code:
        public boolean blocked = false;
        public String hostBans[] = {"127.0.0.1", "localhost", "www.routerlogin.com"}; //these are examples, remove them or you wont be able to log on from your local computer.
        public void checkHost(String connectingHost)
            {
            for(int chk = 0; chk < hostBans.length; chk++)
                {
                if(connectingHost.startsWith(hostBans[chk]))
                    {
                    blocked = true;
                    }
                }
            }
    Adding new bans is really simple, just add a new ,"HOSTNAMEHERE" to the array.
     

  2. #2  
    Registered Member

    Join Date
    Jul 2006
    Age
    30
    Posts
    1,247
    Thanks given
    0
    Thanks received
    5
    Rep Power
    190
    nice rep++ (dont gonna use)
    just yoricka...
     

  3. #3  
    Donator

    tj007razor's Avatar
    Join Date
    Feb 2007
    Posts
    895
    Thanks given
    2
    Thanks received
    9
    Rep Power
    210
    cool much better than my current ip ban, but is there any way to make this add ips through a command? I am quite often not at home, where my server is, when I need to ip ban someone, so that would be great.
     

  4. #4  
    Whitey
    Guest
    Quote Originally Posted by tj007razor View Post
    cool much better than my current ip ban, but is there any way to make this add ips through a command? I am quite often not at home, where my server is, when I need to ip ban someone, so that would be great.
    There is, with a little effort, you can make it add to the array from either a command, or from a text file (From which you may append to with a command)
     

  5. #5  
    Donator

    tj007razor's Avatar
    Join Date
    Feb 2007
    Posts
    895
    Thanks given
    2
    Thanks received
    9
    Rep Power
    210
    Could I just make it read from my current txt file?
     

  6. #6  
    Whitey
    Guest
    Quote Originally Posted by tj007razor View Post
    Could I just make it read from my current txt file?
    Yes, but thats defeating the whole object of this lol.
     

  7. #7  
    Donator

    tj007razor's Avatar
    Join Date
    Feb 2007
    Posts
    895
    Thanks given
    2
    Thanks received
    9
    Rep Power
    210
    No, it would still work much better than other IP bans, just be a lot easier to manipulate.
     

  8. #8  
    Whitey
    Guest
    Quote Originally Posted by tj007razor View Post
    No, it would still work much better than other IP bans, just be a lot easier to manipulate.
    Yeah, find a code that adds to the array via loading a text file.
     

  9. #9  
    Tobbo
    Guest
    did u ever find a way to add ur bannedips.txt?
     


Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Tags for this Thread

View Tag Cloud

Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •