mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-08 00:47:55 +08:00
committed by
Carsten Brandt
parent
5f32d3af15
commit
127aae1e14
@ -4,7 +4,7 @@ Yii Framework 2 debug extension Change Log
|
||||
2.0.4 under development
|
||||
-----------------------
|
||||
|
||||
- no changes in this release.
|
||||
- Enh #7655: Added ability to filter access by hostname (thiagotalma)
|
||||
|
||||
|
||||
2.0.3 March 01, 2015
|
||||
|
||||
@ -30,6 +30,13 @@ class Module extends \yii\base\Module implements BootstrapInterface
|
||||
* by localhost.
|
||||
*/
|
||||
public $allowedIPs = ['127.0.0.1', '::1'];
|
||||
/**
|
||||
* @var array the list of hosts that are allowed to access this module.
|
||||
* Each array element is a hostname that will be resolved to an IP address that is compared
|
||||
* with the IP address of the user. A use case is to use a dynamic DNS (DDNS) to allow access.
|
||||
* The default value is `[]`.
|
||||
*/
|
||||
public $allowedHosts = [];
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
@ -197,6 +204,12 @@ class Module extends \yii\base\Module implements BootstrapInterface
|
||||
return true;
|
||||
}
|
||||
}
|
||||
foreach ($this->allowedHosts as $hostname) {
|
||||
$filter = gethostbyname($hostname);
|
||||
if ($filter === $ip) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Yii::warning('Access to debugger is denied due to IP address restriction. The requesting IP address is ' . $ip, __METHOD__);
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user