Skip to content
This repository has been archived by the owner on Oct 22, 2024. It is now read-only.

Commit

Permalink
fix: Add validation for country database
Browse files Browse the repository at this point in the history
  • Loading branch information
K4ryuu committed Mar 28, 2024
1 parent 442b815 commit d6fda9c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
-- 2023.03.28 - V4.0.4

- fix: Table generation problems because of lastseen default value
- fix: Add validation for country database

-- 2023.03.26 - V4.0.3

Expand Down
7 changes: 7 additions & 0 deletions K4-System/src/Plugin/PluginStock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,13 @@ public string GetPlayerCountryCode(CCSPlayerController player)
string[] parts = playerIp.Split(':');
string realIP = parts.Length == 2 ? parts[0] : playerIp;

string filePath = Path.Combine(ModuleDirectory, "GeoLite2-Country.mmdb");
if (!File.Exists(filePath))
{
Logger.LogError($"GeoLite2-Country.mmdb not found in {ModuleDirectory}. Download it from https://github.com/P3TERX/GeoLite.mmdb/releases and place it in the same directory as the plugin.");
return "??";
}

using DatabaseReader reader = new DatabaseReader(Path.Combine(ModuleDirectory, "GeoLite2-Country.mmdb"));
{
try
Expand Down

0 comments on commit d6fda9c

Please sign in to comment.