Drop Maxmind.GeoIP and Newtonsoft.Json dependencies
This commit is contained in:
4
Makefile
4
Makefile
@@ -46,7 +46,7 @@ SDK ?=
|
||||
CSC = mcs $(SDK)
|
||||
CSFLAGS = -nologo -warn:4 -codepage:utf8 -unsafe -warnaserror
|
||||
DEFINE = TRACE
|
||||
COMMON_LIBS = System.dll System.Core.dll System.Data.dll System.Data.DataSetExtensions.dll System.Drawing.dll System.Xml.dll thirdparty/download/ICSharpCode.SharpZipLib.dll thirdparty/download/FuzzyLogicLibrary.dll thirdparty/download/MaxMind.Db.dll thirdparty/download/MaxMind.GeoIP2.dll thirdparty/download/Eluant.dll thirdparty/download/SmarIrc4net.dll
|
||||
COMMON_LIBS = System.dll System.Core.dll System.Data.dll System.Data.DataSetExtensions.dll System.Drawing.dll System.Xml.dll thirdparty/download/ICSharpCode.SharpZipLib.dll thirdparty/download/FuzzyLogicLibrary.dll thirdparty/download/MaxMind.Db.dll thirdparty/download/Eluant.dll thirdparty/download/SmarIrc4net.dll
|
||||
NUNIT_LIBS_PATH :=
|
||||
NUNIT_LIBS := $(NUNIT_LIBS_PATH)nunit.framework.dll
|
||||
|
||||
@@ -400,8 +400,6 @@ install-core: default
|
||||
@$(CP) SharpFont.dll.config "$(DATA_INSTALL_DIR)"
|
||||
@$(INSTALL_PROGRAM) Open.Nat.dll "$(DATA_INSTALL_DIR)"
|
||||
@$(INSTALL_PROGRAM) MaxMind.Db.dll "$(DATA_INSTALL_DIR)"
|
||||
@$(INSTALL_PROGRAM) MaxMind.GeoIP2.dll "$(DATA_INSTALL_DIR)"
|
||||
@$(INSTALL_PROGRAM) Newtonsoft.Json.dll "$(DATA_INSTALL_DIR)"
|
||||
@$(INSTALL_PROGRAM) SmarIrc4net.dll "$(DATA_INSTALL_DIR)"
|
||||
|
||||
ifneq ($(UNAME_S),Darwin)
|
||||
|
||||
@@ -11,14 +11,45 @@
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using ICSharpCode.SharpZipLib.GZip;
|
||||
using MaxMind.GeoIP2;
|
||||
using MaxMind.Db;
|
||||
|
||||
namespace OpenRA.Network
|
||||
{
|
||||
public class GeoIP
|
||||
{
|
||||
static DatabaseReader database;
|
||||
public class GeoIP2Record
|
||||
{
|
||||
[MaxMind.Db.Constructor] public GeoIP2Record(GeoIP2Country country)
|
||||
{
|
||||
Country = country;
|
||||
}
|
||||
|
||||
public GeoIP2Country Country { get; set; }
|
||||
}
|
||||
|
||||
public class GeoIP2Country
|
||||
{
|
||||
[MaxMind.Db.Constructor] public GeoIP2Country(GeoIP2CountryNames names)
|
||||
{
|
||||
Names = names;
|
||||
}
|
||||
|
||||
public GeoIP2CountryNames Names { get; set; }
|
||||
}
|
||||
|
||||
public class GeoIP2CountryNames
|
||||
{
|
||||
[MaxMind.Db.Constructor] public GeoIP2CountryNames(string en)
|
||||
{
|
||||
English = en;
|
||||
}
|
||||
|
||||
public string English { get; set; }
|
||||
}
|
||||
|
||||
static Reader database;
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
@@ -26,7 +57,7 @@ namespace OpenRA.Network
|
||||
{
|
||||
using (var fileStream = new FileStream("GeoLite2-Country.mmdb.gz", FileMode.Open, FileAccess.Read))
|
||||
using (var gzipStream = new GZipInputStream(fileStream))
|
||||
database = new DatabaseReader(gzipStream);
|
||||
database = new Reader(gzipStream);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -40,7 +71,11 @@ namespace OpenRA.Network
|
||||
|
||||
try
|
||||
{
|
||||
return database.Country(ip).Country.Name ?? Unknown;
|
||||
var record = database.Find<GeoIP2Record>(IPAddress.Parse(ip));
|
||||
if (record != null)
|
||||
return record.Country.Names.English;
|
||||
else
|
||||
return Unknown;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
||||
@@ -74,10 +74,6 @@
|
||||
<HintPath>..\thirdparty\download\ICSharpCode.SharpZipLib.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="MaxMind.GeoIP2">
|
||||
<HintPath>..\thirdparty\download\MaxMind.GeoIP2.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="MaxMind.Db">
|
||||
<HintPath>..\thirdparty\download\MaxMind.Db.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
|
||||
@@ -54,10 +54,6 @@
|
||||
<Reference Include="StyleCop">
|
||||
<HintPath>..\thirdparty\download\StyleCop.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="MaxMind.GeoIP2">
|
||||
<HintPath>..\thirdparty\download\MaxMind.GeoIP2.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="ICSharpCode.SharpZipLib">
|
||||
<HintPath>..\thirdparty\download\ICSharpCode.SharpZipLib.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
|
||||
@@ -65,8 +65,6 @@ cp thirdparty/download/Eluant* packaging/built
|
||||
|
||||
# GeoIP database access
|
||||
cp thirdparty/download/MaxMind.Db.dll packaging/built
|
||||
cp thirdparty/download/MaxMind.GeoIP2.dll packaging/built
|
||||
cp thirdparty/download/Newtonsoft.Json.dll packaging/built
|
||||
|
||||
# global chat
|
||||
cp thirdparty/download/SmarIrc4net.dll packaging/built
|
||||
|
||||
@@ -107,8 +107,6 @@ Section "Game" GAME
|
||||
File "${SRCDIR}\OpenAL-CS.dll"
|
||||
File "${SRCDIR}\global mix database.dat"
|
||||
File "${SRCDIR}\MaxMind.Db.dll"
|
||||
File "${SRCDIR}\MaxMind.GeoIP2.dll"
|
||||
File "${SRCDIR}\Newtonsoft.Json.dll"
|
||||
File "${SRCDIR}\GeoLite2-Country.mmdb.gz"
|
||||
File "${SRCDIR}\eluant.dll"
|
||||
File "${SRCDIR}\SmarIrc4net.dll"
|
||||
@@ -202,8 +200,6 @@ Function ${UN}Clean
|
||||
Delete $INSTDIR\OpenRA.ico
|
||||
Delete "$INSTDIR\global mix database.dat"
|
||||
Delete $INSTDIR\MaxMind.Db.dll
|
||||
Delete $INSTDIR\MaxMind.GeoIP2.dll
|
||||
Delete $INSTDIR\Newtonsoft.Json.dll
|
||||
Delete $INSTDIR\GeoLite2-Country.mmdb.gz
|
||||
Delete $INSTDIR\KopiLua.dll
|
||||
Delete $INSTDIR\soft_oal.dll
|
||||
@@ -215,15 +211,15 @@ Function ${UN}Clean
|
||||
Delete $INSTDIR\OpenAL-CS.dll
|
||||
Delete $INSTDIR\SmarIrc4net.dll
|
||||
RMDir /r $INSTDIR\Support
|
||||
|
||||
|
||||
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\OpenRA"
|
||||
DeleteRegKey HKLM "Software\Classes\.orarep"
|
||||
DeleteRegKey HKLM "Software\Classes\OpenRA_replay"
|
||||
DeleteRegKey HKLM "Software\Classes\openra"
|
||||
|
||||
|
||||
Delete $INSTDIR\uninstaller.exe
|
||||
RMDir $INSTDIR
|
||||
|
||||
|
||||
!insertmacro MUI_STARTMENU_GETFOLDER Application $StartMenuFolder
|
||||
RMDir /r "$SMPROGRAMS\$StartMenuFolder"
|
||||
Delete $DESKTOP\OpenRA.lnk
|
||||
|
||||
10
thirdparty/fetch-thirdparty-deps.ps1
vendored
10
thirdparty/fetch-thirdparty-deps.ps1
vendored
@@ -35,16 +35,12 @@ if (!(Test-Path "ICSharpCode.SharpZipLib.dll"))
|
||||
rmdir SharpZipLib -Recurse
|
||||
}
|
||||
|
||||
if (!(Test-Path "MaxMind.GeoIP2.dll"))
|
||||
if (!(Test-Path "MaxMind.Db.dll"))
|
||||
{
|
||||
echo "Fetching MaxMind.GeoIP2 from NuGet."
|
||||
./nuget.exe install MaxMind.GeoIP2 -Version 2.6.0 -ExcludeVersion
|
||||
echo "Fetching MaxMind.Db from NuGet."
|
||||
./nuget.exe install MaxMind.Db -Version 2.0.0 -ExcludeVersion
|
||||
cp MaxMind.Db/lib/net45/MaxMind.Db.* .
|
||||
rmdir MaxMind.Db -Recurse
|
||||
cp MaxMind.GeoIP2/lib/net45/MaxMind.GeoIP2* .
|
||||
rmdir MaxMind.GeoIP2 -Recurse
|
||||
cp Newtonsoft.Json/lib/net45/Newtonsoft.Json* .
|
||||
rmdir Newtonsoft.Json -Recurse
|
||||
}
|
||||
|
||||
if (!(Test-Path "SharpFont.dll"))
|
||||
|
||||
12
thirdparty/fetch-thirdparty-deps.sh
vendored
12
thirdparty/fetch-thirdparty-deps.sh
vendored
@@ -47,17 +47,11 @@ if [ ! -f ICSharpCode.SharpZipLib.dll ]; then
|
||||
rm -rf SharpZipLib
|
||||
fi
|
||||
|
||||
if [ ! -f MaxMind.GeoIP2.dll ]; then
|
||||
echo "Fetching MaxMind.GeoIP2 from NuGet"
|
||||
get Newtonsoft.Json 8.0.3
|
||||
get MaxMind.Db 2.0.0
|
||||
get MaxMind.GeoIP2 2.6.0
|
||||
if [ ! -f MaxMind.Db.dll ]; then
|
||||
echo "Fetching MaxMind.Db from NuGet"
|
||||
get MaxMind.Db 2.0.0 -IgnoreDependencies
|
||||
cp ./MaxMind.Db/lib/net45/MaxMind.Db.* .
|
||||
rm -rf MaxMind.Db
|
||||
cp ./MaxMind.GeoIP2/lib/net45/MaxMind.GeoIP2* .
|
||||
rm -rf MaxMind.GeoIP2
|
||||
cp ./Newtonsoft.Json/lib/net45/Newtonsoft.Json* .
|
||||
rm -rf Newtonsoft.Json
|
||||
fi
|
||||
|
||||
if [ ! -f SharpFont.dll ]; then
|
||||
|
||||
Reference in New Issue
Block a user