• 7 Vote(s) - 4.14 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[BROKEN] CountryPlugin v1.1 (with IP support)
#1
THIS PLUGIN IS BROKEN/OUTDATED, DO NOT USE.

CountryPlugin is a plugin that allows you to block players who have an IP from a specific country. Alternatively, you can allow players who ONLY have an IP in a specific country and block all others. You can block/allow more than 1 country and can also create IP bans with wildcard support (for subnet bans).

Settings (sv_config.ini): (They will be automatically generated when you run the plugin for the first time).
Code:
[CountryPlugin]
CountryList=
IPBanList=
OnlyAllowCountries=False
DisplayPlayerCountry=True

CountryList - The list of countries to allow only or block (seperated by commas). For a list of valid countries, please look here. You can use either country codes or country names, it doesn't matter. For example, your country list might look like this:
Code:
CountryList=Unknown,AP,AF,AG,Austria
Please note that if you join to your server through an internal IP (because the server is hosted on your computer), your country will appear as Unknown which can cause problems (eg. You blacklisted Unknown countries but that would mean you can't join your own server). The good thing is I've disabled checking if the player's IP matches the server's internal IP (not sure if it's supported on Linux though, should be).

IPBanList - A list of IPs to ban from the server (seperated by commas). Wildcards are supported for subnet bans. Example:
Code:
IPBanList=142.245.255.212,167.232.9.*,232.564.*.*

OnlyAllowCountries - When set to false, it will block any players who have their country in the CountryList. When set to true, only players with their country in the CountryList will be allowed to join.

DisplayPlayerCountry - When set to true, it displays a message to everyone telling where the player comes from.

Chat Commands:
Before using chat commands, you will need the Permission Plugin by @Pozzuh. If you don't want to use it however, add this to your config file if you haven't already (make sure to add your XUID into the Admin_xuids setting):
Code:
[Permission]
//You can add more user groups here
Usergroups=Admin
//Add admin xuids here (Use the status command in console to obtain XUIDs)
Admin_xuids=xuid1,xuid2,xuid3
//Admins can use all commands (Do not change!).
Admin_commands=*ALL*

!getcountrylist - Displays the current country list.
!addcountry <country name or country code> - Adds a country to the country list.
!removecountry <country name or country code> - Removes a country from the country list.
!togglecountrydisplay - Toggles the DisplayPlayerCountry setting.
!forcecountryrecheck - Forces each player in the server to be rechecked. This is useful if you've just made changes to the country list.
!getplayerip <player name> - Displays the IP Address of the specified player.
!getipbanlist - Displays the server's IP ban list.
!banip <ip address> - Bans an IP from the server, note that it will not kick any active players with the same IP, use the !forcecountryrecheck command to do that. As stated before, wildcards ARE supported, refer to the Settings subheading for more information.
!unbanip <ip address> - Unbans an IP from the server.

I purposely didn't add a command to toggle 'OnlyAllowCountries' because it could screw everything up.

Changes:
Version 1.1 (20th March 2012):
- Fixed a bug where all players would be kicked if the IPBan list was left empty.

Notes and Credits:
Please report any bugs, I haven't had much time to test it (I'm actually posting this thread from another computer) so yeah. Smile Source code is included so enjoy!

IP -> Country conversion is powered by GeoIP Country so thanks to MaxMind and Tim Huang for supplying the C# API. The country database is updated every month, you can obtain the latest database here ('Download the latest GeoLite Country Binary Format') and replace the one found in the source\Resources and rebuild it.


Attached Files
.zip   MW3 CountryPlugin v1.1.zip (Size: 1.52 MB / Downloads: 760)
[Image: 30xhrep.png]

A casual conversation between barata and I about Nukem.
  Reply
#2
Very clear instructions and an awesome plugin.

Now if only others would make the directions/information for their plugins as clear!

Thanks,
  Reply
#3
@master131 I don't know if you know this, but you don't have to rebuild your plugins for every new version.

+repped btw, awesome plugin.
[Image: MaEIQ.png]
  Reply
#4
Oh, well, for some reason last time I had to. :S Thanks anyway for the information.
[Image: 30xhrep.png]

A casual conversation between barata and I about Nukem.
  Reply
#5
Awesome, thanks!! Haven't test it yet, will report the result soon!
  Reply
#6
got source? Smile

Had a life, Got a modem..
  Reply
#7
(03-17-2012, 10:52)pieter Wrote: got source? Smile

Its in the file lol.

Good Job @master131
  Reply
#8
awesome, +rep
  Reply
#9
nice plugin but kinda nazi idea LOL
[Image: r212360a129ce9b84444093b6cd2699013a1fbn155.png]
  Reply
#10
(03-17-2012, 13:55)G-Man Wrote: nice plugin but kinda nazi idea LOL

Yeah, personally, I wouldn't use it (maybe just the IP banning part and displaying where a player comes from) but someone requested it so I made it. :3 I don't even run a 24/7 server anyway, I only start up mine to code plugins. :p
[Image: 30xhrep.png]

A casual conversation between barata and I about Nukem.
  Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)