mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-08 17:07:33 +08:00
committed by
Carsten Brandt
parent
5f32d3af15
commit
127aae1e14
@ -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