Country IP Blocking system for Gunz

Page 1 of 3 123 LastLast
Results 1 to 15 of 42
  1. #1
    HeroGamers Developer emisand is offline
    MemberRank
    Mar 2006 Join Date
    UruguayLocation
    330Posts

    Country IP Blocking system for Gunz

    Country IP Blocking System

    Introduction:
    I have researched and designed a system for Gunz that denies the access to your server for people from selected countries.

    It works like in some official servers, when you open gunz, you will get a messagebox telling you that people from your country can't access to the server. And then if they try to connect, connection will be rejected.

    Purpose of this development:
    If you make a server destinated only for people from your country or region, you can prevent from getting people from other countries that you don't want.

    Overview of the System:
    This works with the original functions that locator and matchserver have to block countries.
    It uses 4 sql tables that come with the official DB, some procedures and 2 functions.

    I have created a program in C++ that takes a IP_To_Country CSV database (you can get it for free), and formats it into MSSQL queries that will work with your Gunz Database.

    Then you only have to excecute that SQL file, configure some things, and all will be working.

    Installation:

    1-

    First, you need to download the ip_to_country CSV database.
    You can get it from here: http://ip-to-country.webhosting.info/node/view/6
    Or directly here: http://ip-to-country.webhosting.info...ountry.csv.zip

    This database is free and it's updated once a month.
    You must use only this database, any other ip to country database will not work with my program.

    2-
    Download GunzCountryDB.rar from the attachment (It's the program that converts the CSV database to the MSSQL queries).

    3-

    • Decompress both files IN THE SAME FOLDER
    • Open GunzCountryDB.exe

    You will have 2 options.

    You must select option 1 if it's the first time you are using this or something went wrong and you want to reinstall the requiered tables, procedures and functions.

    You can select option 2 ONLY if you want to update the Ip To Country database because you downloaded a new one.

    To select an option, just type the number and press enter.


    • Then you will prompted to write the IP_To_Country CSV file name, you should write for example ip_to_country.csv (the file must be at the same folder where you are excecuting the program).
    • After that you have to write the destination file name, it may have a .sql extension, if the file doesn't exists, it will be created automatically, if it exists, it will be deleted and re-created.

    The program will process all the data and generate the SQL file.

    NOTE: If you had any problem with the program, you can download the SQL files generated with the latest ip-to-country.csv Database

    There you have ipcountry_mode1.sql and ipcountry_mode2.sql, so mode1 and two mean the mode used in the program to generate them.

    Generated with the CSV File created at October 2008
    Download: http://rapidshare.com/files/15406204...ctober2008.rar

    4-
    Now you have to excecute the SQL file in your Gunz Database.
    So open your SQL Manager, I recommend EMS SQL Manager, but you can also use Microsoft SQL Server Management Studio.
    Then load the sql file and excecute it to your Gunz DB.

    NOTE: It will take LONG to excecute, it will take like 10 minutes to excecute. (Taked 9 minutes in my Core 2 Duo E6550, 2 GB Ram Computer)

    NOTE 2: If you want to be able to connect from 127.0.0.1 (Gunz Client and Server in the same computer) or from 192.168.*.* (Gunz Server in LAN) you must execute this query after excecuting the other script:

    Code:
    INSERT INTO CustomIP (ID, IPFrom, IPTo, IsBlock, CountryCode3, comment, RegDate)
    (SELECT 90000, 2130706433, 2130706433, 0, '', 'IP Blocked', GETDATE())
    UNION ALL
    (SELECT 90001, 3232235521, 3232301055, 0, '', 'IP Blocked', GETDATE())
    5-
    Now you have to configure what countries you want to allow in your server and what countries you don't want.

    To block a country you have to set the column IsBlock to 1 to the countries you don't want at the table CustomIP.

    You have 2 ways to do this.
    a- Blocking all countries and then allowing the countries you want to access to your server.
    b- Allowing all countries and blocking the countries you don't want to access your server.

    This depends in the number of countries that you will block.
    If you only want 1 or little countries to access your server use option a
    If you want almost all the countries to access and to block a few, use option b.

    So you should use the CountryCode3 of the countries to set IsBlock in CustomIP.

    For option a, excecute a query like this:
    Code:
    UPDATE CustomIP SET IsBlock = 1
    UPDATE CustomIP Set IsBlock = 0 WHERE CountryCode3 = FIRST_COUNTRY, OR CountryCode3 = SECOND_COUNTRY OR CountryCode3 = THIRD_COUNTRY.....
    For option b, excecute a query like this:
    Code:
    UPDATE CustomIP SET IsBlock = 0
    UPDATE CustomIP Set IsBlock = 1 WHERE CountryCode3 = FIRST_COUNTRY, OR CountryCode3 = SECOND_COUNTRY OR CountryCode3 = THIRD_COUNTRY.....
    In FIRST_COUNTRY, SECOND_COUNTRY, etc you have to write the CountryCode3 of that country.

    To get what countrycode3 has every country, look at here:
    http://en.wikipedia.org/wiki/ISO_3166-1_alpha-3

    Or you can also see what country code has every country at the table CountryCode.
    In that table you have 2 columns, the first one has the country code 3, and the second the country name.

    After Setting IsBlock in CustomIP, do the same but in the table BlockCountryCode, use the same queries you used before, but with BlockCountryCode as table name.

    NOTE:
    In BlockCountryCode you should leave the first row (That one with empty CountryCode3) with 0 in IsBlock, because if the country of someone is not detected, the system will return that empty countrycode3 and you should allow that people to access.

    NOTE 2:
    If you look at the table CustomIP the column comment has set this for all the rows: You are not allowed access from your country

    That message will be displayed when someone from a blocked country tries to connect to your server.
    You can change it by excecuting:
    Code:
    UPDATE CustomIP SET comment = 'NEW_MESSAGE'
    6-
    It's almost done.
    The last thing you have to do, is to activate the system at your locator and matchserver.

    So open the Locator.ini from your locator,
    search for the line:
    USE_COUNTRY_CODE_FILTER="no"

    Change it to:
    USE_COUNTRY_CODE_FILTER="yes"

    Then open Server.ini from you matchserver,
    search for:
    [FILTER]
    USE="0"
    ACCEPT_INVALID_IP="0"

    Change it to:
    [FILTER]
    USE="1"
    ACCEPT_INVALID_IP="0"

    Now you only have to restart your locator and matchserver.

    If you want to deactivate the country restriction, you only have to set Locator.ini and Matchserver.ini with the configurations you had before.

    After doing all that, it's all done!

    I hope you like this system.

    If you have any problem with this or to make any comment, post at this thread.

    Thank You
    Attached Files Attached Files
    Last edited by emisand; 14-10-08 at 11:39 PM.


  2. #2
    DRGunZ 2 Creator wesman2232 is offline
    MemberRank
    Jan 2007 Join Date
    Erie, PALocation
    4,872Posts

    Re: [Release] Country IP Blocking system for Gunz

    wow nice. But as long as they can speak english anyone is allowed in my server :)
    Off-topic : first post xD

  3. #3
    The beer?? Its here !!! Rotana is offline
    MemberRank
    Jan 2007 Join Date
    The NetherlandsLocation
    1,733Posts

    Re: [Release] Country IP Blocking system for Gunz

    Great Release
    Usefull information for alot of people. Stickied.

    Edit: The insert of the custom ip's need an columed named ID in the table. After making that query completed in 7:59 :D

  4. #4
    Account Upgraded | Title Enabled! ~DN is offline
    MemberRank
    Jul 2008 Join Date
    JailLocation
    515Posts

    Re: [Release] Country IP Blocking system for Gunz

    awesome xD nice release

  5. #5
    Gunz Developer / Support _System32_ is offline
    MemberRank
    Feb 2008 Join Date
    VenezuelaLocation
    583Posts

    Re: [Release] Country IP Blocking system for Gunz

    Yes, Nice Release.. I Love you work Emisand.. I Love this work Lambda :D!

  6. #6
    Account Upgraded | Title Enabled! 7-Eleven is offline
    MemberRank
    Oct 2007 Join Date
    LalaLandLocation
    714Posts

    Re: [Release] Country IP Blocking system for Gunz

    Awesome release, but I need time to consume every instruction above, xD

    EDIT - I've come across this warning.


    Warning! The maximum key length is 900 bytes. The index 'IX_IPtoCountryCode_IPRange_060612' has maximum length of 24000 bytes. For some combination of large values, the insert/update operation will fail.
    Warning: The maximum length of the row exceeds the permissible limit of 8060 bytes. For some combination of large values, the insert/update operation will fail.

    Will it give a huge affect?
    Last edited by 7-Eleven; 04-08-08 at 05:15 PM.

  7. #7
    Account Upgraded | Title Enabled! 4ndr34s is offline
    MemberRank
    Sep 2007 Join Date
    At My Home O_oLocation
    587Posts

    Re: [Release] Country IP Blocking system for Gunz

    nice relase

  8. #8
    The beer?? Its here !!! Rotana is offline
    MemberRank
    Jan 2007 Join Date
    The NetherlandsLocation
    1,733Posts

    Re: [Release] Country IP Blocking system for Gunz

    I have tested the ip filter, but i cant login any more.
    this is the error i get:
    Code:
    MMatchServer::CheckIsNonBlockCountry - add new IPtoCountry(f:0, t0, c:) fail.
    Any idea's?

  9. #9
    HeroGamers Developer emisand is offline
    MemberRank
    Mar 2006 Join Date
    UruguayLocation
    330Posts

    Re: [Release] Country IP Blocking system for Gunz

    Quote Originally Posted by Rotana View Post
    I have tested the ip filter, but i cant login any more.
    this is the error i get:
    Code:
    MMatchServer::CheckIsNonBlockCountry - add new IPtoCountry(f:0, t0, c:) fail.
    Any idea's?
    Is the server at the same computer you are trying to connect with the client?
    Or even in a local area network

    I think that 127.0.0.1 and 192.x.x.x are not at customip table.

    Try excecuting this query for adding the 127.0.0.1 and 192.168.*.* to customip:

    Code:
    INSERT INTO CustomIP (ID, IPFrom, IPTo, IsBlock, CountryCode3, comment, RegDate)
    (SELECT 90000, 2130706433, 2130706433, 0, '', 'IP Blocked', GETDATE())
    UNION ALL
    (SELECT 90001, 3232235521, 3232301055, 0, '', 'IP Blocked', GETDATE())

  10. #10
    Who is the cow! sari4ever is offline
    MemberRank
    Apr 2007 Join Date
    Holy LandLocation
    790Posts

    Re: [Release] Country IP Blocking system for Gunz

    OMG i was waiting for this thank you :)

  11. #11
    Account Upgraded | Title Enabled! UkRaiNeR is offline
    MemberRank
    Sep 2006 Join Date
    US/UkraineLocation
    352Posts

    Re: [Release] Country IP Blocking system for Gunz

    good stuff

  12. #12
    HeroGamers Developer emisand is offline
    MemberRank
    Mar 2006 Join Date
    UruguayLocation
    330Posts

    Re: [Release] Country IP Blocking system for Gunz

    If you know about a better IP To Country database I can create a converter for it.

    I know there are better databases but they are not free.

    So if you know about a better free IP To country database, or you want to share a not free database, answer at this thread or send it to me by PM

    Thank you.

  13. #13
    Account Upgraded | Title Enabled! alfredao is offline
    MemberRank
    Jan 2008 Join Date
    Coronel FabriciLocation
    705Posts

    Re: [Release] Country IP Blocking system for Gunz

    Nice man, But i think private servers want a lot of players in ur server and accept players of others countries.

  14. #14
    The beer?? Its here !!! Rotana is offline
    MemberRank
    Jan 2007 Join Date
    The NetherlandsLocation
    1,733Posts

    Re: [Release] Country IP Blocking system for Gunz

    Quote Originally Posted by emisand View Post
    Is the server at the same computer you are trying to connect with the client?
    Or even in a local area network

    I think that 127.0.0.1 and 192.x.x.x are not at customip table.

    Try excecuting this query for adding the 127.0.0.1 and 192.168.*.* to customip:

    Code:
    INSERT INTO CustomIP (ID, IPFrom, IPTo, IsBlock, CountryCode3, comment, RegDate)
    (SELECT 90000, 2130706433, 2130706433, 0, '', 'IP Blocked', GETDATE())
    UNION ALL
    (SELECT 90001, 3232235521, 3232301055, 0, '', 'IP Blocked', GETDATE())
    Works fine now, THANKS

  15. #15
    Member nubbynub is offline
    MemberRank
    Jun 2007 Join Date
    75Posts

    Re: [Release] Country IP Blocking system for Gunz

    I get the same error as 7-Eleven. Yupp. Hmm. I guess I'll do without this for a while.



Page 1 of 3 123 LastLast

Advertisement