Torann / laravel-geoip

Determine the geographical location of website visitors based on their IP addresses.
http://lyften.com/projects/laravel-geoip
BSD 2-Clause "Simplified" License
2.07k stars 372 forks source link

v1.1 unable to download GeoLite2-City.mmdb.gz #165

Closed jiriko closed 4 years ago

jiriko commented 4 years ago

It seems it's still using the old url instead of the new one with the license key?

 file_get_contents(): Filename cannot be empty

  at /home/vagrant/code/tmapi/vendor/pragmarx/support/src/GeoIp/Updater.php:100
     96|      * @return bool
     97|      */
     98|     private function md5Match()
     99|     {
  > 100|         if (! $match = md5_file($this->databaseFile) == file_get_contents($this->md5File)) {
    101|             $this->addMessage("MD5 is not matching for {$this->databaseFile} and {$this->md5File}.");
    102|
    103|             return false;
    104|         }

  Exception trace:

  1   file_get_contents("")
      /home/vagrant/code/tmapi/vendor/pragmarx/support/src/GeoIp/Updater.php:100

Exception trace:

  1   gzopen("/........../config/geoip/GeoLite2-City.mmdb.gz", "rb")
      /...../pragmarx/support/src/GeoIp/Updater.php:200
  2   PragmaRX\Support\GeoIp\Updater::dezipGzFile("..../config/geoip/GeoLite2-City.mmdb.gz")
      /........./pragmarx/support/src/GeoIp/Updater.php:57

  3   PragmaRX\Support\GeoIp\Updater::downloadGzipped("..../config/geoip", "http://geolite.maxmind.com/download/geoip/database/GeoLite2-City.mmdb.gz")
      /..../vendor/pragmarx/support/src/GeoIp/Updater.php:136

  4   PragmaRX\Support\GeoIp\Updater::updateGeoIpFiles("...././config/geoip")
      /....../vendor/pragmarx/firewall/src/Firewall.php:324

  5   PragmaRX\Firewall\Firewall::updateGeoIp()
      /...../vendor/pragmarx/firewall/src/Vendor/Laravel/Artisan/UpdateGeoIp.php:30

our config:

<?php

return [

    /*
    |--------------------------------------------------------------------------
    | Logging Configuration
    |--------------------------------------------------------------------------
    |
    | Here you may configure the log settings for when a location is not found
    | for the IP provided.
    |
    */

    'log_failures' => true,

    /*
    |--------------------------------------------------------------------------
    | Include Currency in Results
    |--------------------------------------------------------------------------
    |
    | When enabled the system will do it's best in deciding the user's currency
    | by matching their ISO code to a preset list of currencies.
    |
    */

    'include_currency' => false,

    /*
    |--------------------------------------------------------------------------
    | Default Service
    |--------------------------------------------------------------------------
    |
    | Here you may specify the default storage driver that should be used
    | by the framework.
    |
    | Supported: "maxmind_database", "maxmind_api", "ipapi"
    |
    */

    'service' => 'ipapi',

    /*
    |--------------------------------------------------------------------------
    | Storage Specific Configuration
    |--------------------------------------------------------------------------
    |
    | Here you may configure as many storage drivers as you wish.
    |
    */

    'services' => [

        'maxmind_database' => [
            'class' => \Torann\GeoIP\Services\MaxMindDatabase::class,
            'database_path' => storage_path('app/geoip.mmdb'),
            'update_url' => sprintf('https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-City&license_key=%s&suffix=tar.gz', env('MAXMIND_LICENSE_KEY')),
            'locales' => ['en'],
        ],

        'maxmind_api' => [
            'class' => \Torann\GeoIP\Services\MaxMindWebService::class,
            'user_id' => env('MAXMIND_USER_ID'),
            'license_key' => env('MAXMIND_LICENSE_KEY'),
            'locales' => ['en'],
        ],

        'ipapi' => [
            'class' => \Torann\GeoIP\Services\IPApi::class,
            'secure' => true,
            'key' => env('IPAPI_KEY'),
            'continent_path' => storage_path('app/continents.json'),
            'lang' => 'en',
        ],

        'ipgeolocation' => [
            'class' => \Torann\GeoIP\Services\IPGeoLocation::class,
            'secure' => true,
            'key' => env('IPGEOLOCATION_KEY'),
            'continent_path' => storage_path('app/continents.json'),
            'lang' => 'en',
        ],

        'ipdata' => [
            'class'  => \Torann\GeoIP\Services\IPData::class,
            'key'    => env('IPDATA_API_KEY'),
            'secure' => true,
        ],

    ],

    /*
    |--------------------------------------------------------------------------
    | Default Cache Driver
    |--------------------------------------------------------------------------
    |
    | Here you may specify the type of caching that should be used
    | by the package.
    |
    | Options:
    |
    |  all  - All location are cached
    |  some - Cache only the requesting user
    |  none - Disable cached
    |
    */

    'cache' => 'all',

    /*
    |--------------------------------------------------------------------------
    | Cache Tags
    |--------------------------------------------------------------------------
    |
    | Cache tags are not supported when using the file or database cache
    | drivers in Laravel. This is done so that only locations can be cleared.
    |
    */

    'cache_tags' => ['torann-geoip-location'],

    /*
    |--------------------------------------------------------------------------
    | Cache Expiration
    |--------------------------------------------------------------------------
    |
    | Define how long cached location are valid.
    |
    */

    'cache_expires' => 30,

    /*
    |--------------------------------------------------------------------------
    | Default Location
    |--------------------------------------------------------------------------
    |
    | Return when a location is not found.
    |
    */

    'default_location' => [
        'ip' => '127.0.0.0',
        'iso_code' => 'US',
        'country' => 'United States',
        'city' => 'New Haven',
        'state' => 'CT',
        'state_name' => 'Connecticut',
        'postal_code' => '06510',
        'lat' => 41.31,
        'lon' => -72.92,
        'timezone' => 'America/New_York',
        'continent' => 'NA',
        'default' => true,
        'currency' => 'USD',
    ],

];
jiriko commented 4 years ago

not related sorry