CountryBlackList

Approved CountryBlackList 3.0.3

No permission to download

Jakkee

Plugin Developer
Plugin Developer
Contributor
Jul 28, 2014
1,463
342
83
Australia
Jakkee submitted a new resource:

CountryBlackList - Blacklist any countries you do not want on your server

Description:
Create a blacklist of countries you do not want on your server.
Use this link to find the country codes: Here

Installation:
- Place into Python folder
- Reload/restart the server
- Find Settings.ini
- Edit & Save
- Done

Commands:
None

INI:
[Settings]
ShowAcceptedMessage=true
ShowDeniedMessage=true
LogTimedOutConnection=true

[BlackList]
BlackListedCountries=KR, RU

[Messages]...
Read more about this resource...
 

PearlJ

Contributor
Contributor
Aug 14, 2014
86
16
8
27
Italy
misternerd.eu
I put my Country (Italy) in blacklist but I can, however, join in the server without problems.
When I connect says "from unknow". This also happens to others who I did try.
 

Jakkee

Plugin Developer
Plugin Developer
Contributor
Jul 28, 2014
1,463
342
83
Australia
I put my Country (Italy) in blacklist but I can, however, join in the server without problems.
When I connect says "from unknow". This also happens to others who I did try.
Thanks, Most likely the website I'm using is down or its a local hosted server and they are connecting from inside your network.
 

PearlJ

Contributor
Contributor
Aug 14, 2014
86
16
8
27
Italy
misternerd.eu
Thanks, Most likely the website I'm using is down or its a local hosted server and they are connecting from inside your network.
No it is not local server, my server is hosted on VPS.
Me and others two user (also they are italian) can join in the server without problems because the plugin (or website) does not indentify the Country.

I think that config file is correct:
Code:
[Settings]
ShowAcceptedMessage=false
ShowDeniedMessage=true
LogTimedOutConnection=true

[BlackList]
BlackListedCountries=RU, KR, TR, AZ, IL, CN, JP, IT

[Messages]
JoinMessage=[color cyan]%player%[/color] has connected from: [color cyan]%country%[/color]
DisconnectMessage=Your country is on the servers blacklist
OtherDisconnectMessage=[color cyan]%player%[/color] is trying to connect from: [color cyan]%country%[/color] but is black listed
 

Jakkee

Plugin Developer
Plugin Developer
Contributor
Jul 28, 2014
1,463
342
83
Australia
No it is not local server, my server is hosted on VPS.
Me and others two user (also they are italian) can join in the server without problems because the plugin (or website) does not indentify the Country.

I think that config file is correct:
Code:
[Settings]
ShowAcceptedMessage=false
ShowDeniedMessage=true
LogTimedOutConnection=true

[BlackList]
BlackListedCountries=RU, KR, TR, AZ, IL, CN, JP, IT

[Messages]
JoinMessage=[color cyan]%player%[/color] has connected from: [color cyan]%country%[/color]
DisconnectMessage=Your country is on the servers blacklist
OtherDisconnectMessage=[color cyan]%player%[/color] is trying to connect from: [color cyan]%country%[/color] but is black listed
I'll take a look, See what I find
 

DreTaX

Probably knows the answer...
Administrator
Jun 29, 2014
3,983
1,467
113
At your house.
github.com
@PearlJ

Jakkee Line 44 is wrong.

Here is the correct version:
Python:
__title__ = 'CountryBlackList'
__author__ = 'Jakkee'
__version__ = '1.1.1'

try:
    import clr
    clr.AddReferenceByPartialName("Fougerite", "GeoIP")
    import Fougerite
    import GeoIP
    from GeoIP import GeoIP as RealGeoIP 
except:
    raise ImportError("Failed to reference the GeoIP.dll, Download from: http://fougerite.com/resources/geoip.135/")

geo = RealGeoIP.Instance

class CountryBlackList:
    def On_PluginInit(self):
        Util.ConsoleLog(__title__ + " by " + __author__ + " Version: " + __version__ + " loaded.", False)
        if not Plugin.IniExists("Settings"):
            Plugin.CreateIni("Settings")
            ini = Plugin.GetIni("Settings")
            ini.AddSetting("Settings", "ShowAcceptedMessage", "true")
            ini.AddSetting("Settings", "ShowDeniedMessage", "true")
            ini.AddSetting("Settings", "LogTimedOutConnection", "true")
            ini.AddSetting("BlackList", "BlackListedCountries", "TK, JO")
            ini.AddSetting("Messages", "JoinMessage", "%PLAYER% has connected from: %COUNTRY%")
            ini.AddSetting("Messages", "PlayerDisconnectMessage", "Your country is on the servers blacklist")
            ini.AddSetting("Messages", "ServerDisconnectMessage", "%PLAYER% is trying to connect from: %COUNTRY% but is black listed")
            ini.AddSetting("Messages", "UnknownLocation", "A hidden location")
            ini.Save()
        ini = Plugin.GetIni("Settings")
        DataStore.Add("CountryBlackList", "SAM", ini.GetSetting("Settings", "ShowAcceptedMessage"))
        DataStore.Add("CountryBlackList", "SDM", ini.GetSetting("Settings", "ShowDeniedMessage"))
        DataStore.Add("CountryBlackList", "BL", ini.GetSetting("BlackList", "BlackListedCountries"))
        DataStore.Add("CountryBlackList", "JM", ini.GetSetting("Messages", "JoinMessage"))
        DataStore.Add("CountryBlackList", "PDM", ini.GetSetting("Messages", "PlayerDisconnectMessage"))
        DataStore.Add("CountryBlackList", "DM", ini.GetSetting("Messages", "ServerDisconnectMessage"))
        DataStore.Add("CountryBlackList", "UL", ini.GetSetting("Messages", "UnknownLocation"))

    def find(self, blacklist, CountryCode):
        try:
            blacklist = blacklist.Replace(" ", "")
            blacklist = blacklist.split(',')
            for configlist in blacklist:
                if CountryCode == configlist:
                    return True
                else:
                    continue
            return False
        except:
            return False

    def On_PlayerConnected(self, Player):
        IPData = geo.GetDataOfIP(Player.IP)
        if IPData is None:
            if DataStore.Get("CountryBlackList", "SAM") == "true":
                msg = DataStore.Get("CountryBlackList", "JM")
                msg = msg.Replace("%PLAYER%", Player.Name)
                msg = msg.Replace("%COUNTRY%", DataStore.Get("CountryBlackList", "UL"))
                Server.Broadcast(msg)
            return
        countrycode = IPData.CountryShort
        blacklist = DataStore.Get("CountryBlackList", "BL")
        if self.find(blacklist, countrycode):
            playerdisconnectMSG = DataStore.Get("CountryBlackList", "PDM")
            if DataStore.Get("CountryBlackList", "SDM") == "true":
                msg = DataStore.Get("CountryBlackList", "DM")
                msg = msg.Replace("%PLAYER%", Player.Name)
                msg = msg.Replace("%COUNTRY%", IPData.Country)
                Server.Broadcast(msg)
            Player.Message(playerdisconnectMSG + " [" + countrycode + "]")
            Player.Disconnect()
        else:
            if DataStore.Get("CountryBlackList", "SAM") == "true":
                msg = DataStore.Get("CountryBlackList", "JM")
                msg = msg.Replace("%PLAYER%", Player.Name)
                msg = msg.Replace("%COUNTRY%", IPData.Country)
                Server.Broadcast(msg)
 

tarynkelley

Moderator
Moderator
Nov 14, 2015
559
107
28
Parts Unknown
Is it possible to maybe implement a Steam ID based Whitelist?

I don't want to completly lock out a whole country, but allow players from the blocked country who seem to be fine and not hacking.
 
  • Informative
Reactions: PearlJ and Jakkee

Virobeast

Member
Member
Sep 9, 2014
31
6
8
Also it may be better to just have a country whitelist only feature, such was i wish to only allow people from Australia and New Zealand on my server, so all i have to do is add, AU, NZ.

Not every other code possible to block ;)
 
  • Informative
Reactions: Jakkee

Virobeast

Member
Member
Sep 9, 2014
31
6
8
Cheat list for anyone looking to whitelist

BlackListedCountries=TK, JO, AF, AL, DZ, AS, AD, AO, AI, AQ, AG, AR, AM, AW, AT, AZ, BS, BH, BD, BB, BY, BE, BZ, BJ, BM, BT, BO, BA, BW, BR, IO, VG, BN, BG, BF, BI, KH, CM, CA, CV, KY, CF, TD, CL, CN, CX, CC, CO, KM, CK, CR, HR, CU, CY, CZ, CD, DK, DJ, DM, DO, TL, EC, EG, SV, GQ, ER, EE, ET, FK, FO, FJ, FI, FR, PF, GA, GM, GE, DE, GH, GI, GR, GL, GD, GU, GT, GW, GN, GY, HT, HN, HK, HU, IS, IN, ID, IR, IQ, IE, IM, IL, IT, CI, JM, JP, JE, JO, KZ, KE, KI, KW, YT, KG, LA, LV, LB, LS, LR, LY, LI, MU, LT, LU, MO, MK, MG, MW, MY, MV, ML, MH, MR, MX, FM, MD, MC, MN, ME, MS, MA, MZ, MM, NA, NR, NP, NL, AN, NC, NI, NE, NG, NU, KP, MP, NO, OM, PK, PW, PA, PG, PL, PT, PR, QA, PY, PE, CG, RO , PN, PH, RU, MT, RW, BL, SH, KN, LC, MF, PM, VC, WS, SM, ST, SA, SN, RS, SC, SL, SG, SK, SI, SB, SO, ZA, GS, ES, LK, SD, SR, SJ, SZ, SE, SY, TW, TJ, TZ, TH, TG, TK, TO, TT, TN, TR, TM, TC, TV, VI, UG, AE, GB, US, UY, UA, UZ, VU, CH, VA, VE, VN, WF, EH, ZW, YE, ZM, KR