Skip to content

Commit

Permalink
Merge pull request #4 from osugregor/master
Browse files Browse the repository at this point in the history
Ability to override certain IP addresses
  • Loading branch information
buonzz committed Jan 8, 2015
2 parents 3d851a6 + 7d97796 commit 0944809
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
8 changes: 6 additions & 2 deletions src/Buonzz/GeoIP/GeoIP.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ class GeoIP{
*/
public function __construct(){
if(isset($_SERVER['REMOTE_ADDR']))
$this->ip = $_SERVER['REMOTE_ADDR'];
$this->ip = $_SERVER['REMOTE_ADDR'];

// Check if an override for the current ip exists
$overrides = \Config::get('laravel-4-freegeoip::overrides');
if(isset($this->ip, $overrides))$this->ip = $overrides[$this->ip];
}

/**
Expand Down Expand Up @@ -196,4 +200,4 @@ function resolve($ip){
return $data;
}

}
}
8 changes: 7 additions & 1 deletion src/config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,10 @@

// Timeout when calling the API (in seconds)
'timeout' => 30,
);

// IP address overrides. Defaults localhost to Google
'overrides' => array(
'127.0.0.1' => '64.233.160.0',
'localhost' => '64.233.160.0',
)
);

0 comments on commit 0944809

Please sign in to comment.