Fixed geoip crashing on startup if geoip.dat is missing. Also fixed it crashing if you enable it without restarting tshock.
This commit is contained in:
parent
bedfc060e2
commit
da91d56513
2 changed files with 5 additions and 4 deletions
|
|
@ -48,7 +48,6 @@ namespace TShockAPI
|
||||||
|
|
||||||
object Status(RestVerbs verbs, IParameterCollection parameters)
|
object Status(RestVerbs verbs, IParameterCollection parameters)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (TShock.Config.EnableTokenEndpointAuthentication)
|
if (TShock.Config.EnableTokenEndpointAuthentication)
|
||||||
return new RestObject("403") { Error = "Server settings require a token for this API call." };
|
return new RestObject("403") { Error = "Server settings require a token for this API call." };
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -182,8 +182,10 @@ namespace TShockAPI
|
||||||
RestApi.Port = Config.RestApiPort;
|
RestApi.Port = Config.RestApiPort;
|
||||||
RestManager = new RestManager(RestApi);
|
RestManager = new RestManager(RestApi);
|
||||||
RestManager.RegisterRestfulCommands();
|
RestManager.RegisterRestfulCommands();
|
||||||
if (Config.EnableGeoIP)
|
|
||||||
Geo = new MaxMind.GeoIPCountry(Path.Combine(SavePath, "GeoIP.dat"));
|
var geoippath = Path.Combine(SavePath, "GeoIP.dat");
|
||||||
|
if (Config.EnableGeoIP && File.Exists(geoippath))
|
||||||
|
Geo = new MaxMind.GeoIPCountry(geoippath);
|
||||||
|
|
||||||
Log.ConsoleInfo(string.Format("TShock Version {0} ({1}) now running.", Version, VersionCodename));
|
Log.ConsoleInfo(string.Format("TShock Version {0} ({1}) now running.", Version, VersionCodename));
|
||||||
|
|
||||||
|
|
@ -660,7 +662,7 @@ namespace TShockAPI
|
||||||
NetMessage.SendData((int)PacketTypes.TimeSet, -1, -1, "", 0, 0, Main.sunModY, Main.moonModY);
|
NetMessage.SendData((int)PacketTypes.TimeSet, -1, -1, "", 0, 0, Main.sunModY, Main.moonModY);
|
||||||
NetMessage.syncPlayers();
|
NetMessage.syncPlayers();
|
||||||
|
|
||||||
if (Config.EnableGeoIP)
|
if (Config.EnableGeoIP && Geo != null)
|
||||||
{
|
{
|
||||||
var code = Geo.TryGetCountryCode(IPAddress.Parse(player.IP));
|
var code = Geo.TryGetCountryCode(IPAddress.Parse(player.IP));
|
||||||
player.Country = code == null ? "N/A" : MaxMind.GeoIPCountry.GetCountryNameByCode(code);
|
player.Country = code == null ? "N/A" : MaxMind.GeoIPCountry.GetCountryNameByCode(code);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue