Skip to content

Commit 6908a02

Browse files
committed
Merge conflict resolution
1 parent 1b41c5c commit 6908a02

3 files changed

Lines changed: 31 additions & 0 deletions

File tree

src/Atlasd/Atlasd.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@
4747
<Folder Include="Properties\" />
4848
</ItemGroup>
4949

50+
<ItemGroup>
51+
<PackageReference Include="MaxMind.GeoIP2" Version="5.1.0" />
52+
</ItemGroup>
53+
5054
<ItemGroup>
5155
<ProjectReference Include="..\..\vendor\MBNCSUtil\src\MBNCSUtil.csproj" />
5256
</ItemGroup>

src/Atlasd/Battlenet/Protocols/Game/GameState.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,33 @@ public void Dispose() /* part of IDisposable */
169169
IsDisposing = false;
170170
}
171171

172+
public void GenerateLocaleFromGeoIP()
173+
{
174+
var file = Path.GetFullPath(Path.Combine(AppContext.BaseDirectory, "GeoIP2-City.mmdb"));
175+
// This creates the DatabaseReader object, which should be reused across
176+
// lookups.
177+
using (var reader = new MaxMind.GeoIP2.DatabaseReader(file))
178+
{
179+
// Replace "City" with the appropriate method for your database, e.g.,
180+
// "Country".
181+
var city = reader.City((Client.RemoteEndPoint as IPEndPoint).Address.ToString());
182+
183+
Console.WriteLine(city.Country.IsoCode); // 'US'
184+
Console.WriteLine(city.Country.Name); // 'United States'
185+
Console.WriteLine(city.Country.Names["zh-CN"]); // '美国'
186+
187+
Console.WriteLine(city.MostSpecificSubdivision.Name); // 'Minnesota'
188+
Console.WriteLine(city.MostSpecificSubdivision.IsoCode); // 'MN'
189+
190+
Console.WriteLine(city.City.Name); // 'Minneapolis'
191+
192+
Console.WriteLine(city.Postal.Code); // '55455'
193+
194+
Console.WriteLine(city.Location.Latitude); // 44.9733
195+
Console.WriteLine(city.Location.Longitude); // -93.2323
196+
}
197+
}
198+
172199
public byte[] GenerateStatstring()
173200
{
174201
byte[] statstring = null;

var/bnftp/ad-20201030-3days.png

-573 Bytes
Loading

0 commit comments

Comments
 (0)