Giter Site home page Giter Site logo

Comments (1)

nchelluri avatar nchelluri commented on May 27, 2024

Hi, the issue is that you are looking up IPs in the database for which we don't have a city record - the data is just not there.

If you look up the data using a tool such as mmdblookup, found here, you'll see that none of the IPs you posted have a "city" field. E.g.:

$ mmdblookup --file /usr/share/GeoIP/GeoLite2-City.mmdb --ip 13.77.161.179

  {
    "continent": 
      {
        "code": 
          "NA" <utf8_string>
        "geoname_id": 
          6255149 <uint32>
        "names": 
          {
            "de": 
              "Nordamerika" <utf8_string>
            "en": 
              "North America" <utf8_string>
            "es": 
              "Norteamérica" <utf8_string>
            "fr": 
              "Amérique du Nord" <utf8_string>
            "ja": 
              "北アメリカ" <utf8_string>
            "pt-BR": 
              "América do Norte" <utf8_string>
            "ru": 
              "Северная Америка" <utf8_string>
            "zh-CN": 
              "北美洲" <utf8_string>
          }
      }
    "country": 
      {
        "geoname_id": 
          6252001 <uint32>
        "iso_code": 
          "US" <utf8_string>
        "names": 
          {
            "de": 
              "USA" <utf8_string>
            "en": 
              "United States" <utf8_string>
            "es": 
              "Estados Unidos" <utf8_string>
            "fr": 
              "États-Unis" <utf8_string>
            "ja": 
              "アメリカ合衆国" <utf8_string>
            "pt-BR": 
              "Estados Unidos" <utf8_string>
            "ru": 
              "США" <utf8_string>
            "zh-CN": 
              "美国" <utf8_string>
          }
      }
    "location": 
      {
        "accuracy_radius": 
          1000 <uint16>
        "latitude": 
          47.609200 <double>
        "longitude": 
          -122.331400 <double>
        "time_zone": 
          "America/Los_Angeles" <utf8_string>
      }
    "registered_country": 
      {
        "geoname_id": 
          6252001 <uint32>
        "iso_code": 
          "US" <utf8_string>
        "names": 
          {
            "de": 
              "USA" <utf8_string>
            "en": 
              "United States" <utf8_string>
            "es": 
              "Estados Unidos" <utf8_string>
            "fr": 
              "États-Unis" <utf8_string>
            "ja": 
              "アメリカ合衆国" <utf8_string>
            "pt-BR": 
              "Estados Unidos" <utf8_string>
            "ru": 
              "США" <utf8_string>
            "zh-CN": 
              "美国" <utf8_string>
          }
      }
    "subdivisions": 
      [
        {
          "geoname_id": 
            5815135 <uint32>
          "iso_code": 
            "WA" <utf8_string>
          "names": 
            {
              "en": 
                "Washington" <utf8_string>
              "es": 
                "Washington" <utf8_string>
              "fr": 
                "Washington" <utf8_string>
              "ja": 
                "ワシントン州" <utf8_string>
              "ru": 
                "Вашингтон" <utf8_string>
              "zh-CN": 
                "华盛顿州" <utf8_string>
            }
        }
      ]
  }

However, if you look up an IP that does have data in the database, you'll see the "city" field:

$ mmdblookup --file /usr/share/GeoIP/GeoLite2-City.mmdb --ip 173.213.100.106

  {
    "city": 
      {
        "geoname_id": 
          5506956 <uint32>
        "names": 
          {
            "de": 
              "Las Vegas" <utf8_string>
            "en": 
              "Las Vegas" <utf8_string>
            "es": 
              "Las Vegas" <utf8_string>
            "fr": 
              "Las Vegas" <utf8_string>
            "ja": 
              "ラスベガス" <utf8_string>
            "pt-BR": 
              "Las Vegas" <utf8_string>
            "ru": 
              "Лас-Вегас" <utf8_string>
            "zh-CN": 
              "拉斯维加斯" <utf8_string>
          }
      }
[...snip...]

Moreover, I would strongly recommend against using a production database in your tests, because the underlying data in the database changes from release to release. Instead, you could test using a test DB, found here. You could store a version of the file in your repo and the data would never change.

Hope this helps.

from geoip2-dotnet.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.