mirror of
https://github.com/linuxserver/Heimdall.git
synced 2025-12-02 13:09:53 +09:00
Update to laravel 7
This commit is contained in:
@@ -54,11 +54,8 @@ class RequestMatcher implements RequestMatcherInterface
|
||||
private $schemes = [];
|
||||
|
||||
/**
|
||||
* @param string|null $path
|
||||
* @param string|null $host
|
||||
* @param string|string[]|null $methods
|
||||
* @param string|string[]|null $ips
|
||||
* @param array $attributes
|
||||
* @param string|string[]|null $schemes
|
||||
*/
|
||||
public function __construct(string $path = null, string $host = null, $methods = null, $ips = null, array $attributes = [], $schemes = null, int $port = null)
|
||||
@@ -87,10 +84,8 @@ class RequestMatcher implements RequestMatcherInterface
|
||||
|
||||
/**
|
||||
* Adds a check for the URL host name.
|
||||
*
|
||||
* @param string|null $regexp A Regexp
|
||||
*/
|
||||
public function matchHost($regexp)
|
||||
public function matchHost(?string $regexp)
|
||||
{
|
||||
$this->host = $regexp;
|
||||
}
|
||||
@@ -100,17 +95,15 @@ class RequestMatcher implements RequestMatcherInterface
|
||||
*
|
||||
* @param int|null $port The port number to connect to
|
||||
*/
|
||||
public function matchPort(int $port = null)
|
||||
public function matchPort(?int $port)
|
||||
{
|
||||
$this->port = $port;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a check for the URL path info.
|
||||
*
|
||||
* @param string|null $regexp A Regexp
|
||||
*/
|
||||
public function matchPath($regexp)
|
||||
public function matchPath(?string $regexp)
|
||||
{
|
||||
$this->path = $regexp;
|
||||
}
|
||||
@@ -120,7 +113,7 @@ class RequestMatcher implements RequestMatcherInterface
|
||||
*
|
||||
* @param string $ip A specific IP address or a range specified using IP/netmask like 192.168.1.0/24
|
||||
*/
|
||||
public function matchIp($ip)
|
||||
public function matchIp(string $ip)
|
||||
{
|
||||
$this->matchIps($ip);
|
||||
}
|
||||
@@ -132,7 +125,11 @@ class RequestMatcher implements RequestMatcherInterface
|
||||
*/
|
||||
public function matchIps($ips)
|
||||
{
|
||||
$this->ips = null !== $ips ? (array) $ips : [];
|
||||
$ips = null !== $ips ? (array) $ips : [];
|
||||
|
||||
$this->ips = array_reduce($ips, static function (array $ips, string $ip) {
|
||||
return array_merge($ips, preg_split('/\s*,\s*/', $ip));
|
||||
}, []);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -147,11 +144,8 @@ class RequestMatcher implements RequestMatcherInterface
|
||||
|
||||
/**
|
||||
* Adds a check for request attribute.
|
||||
*
|
||||
* @param string $key The request attribute name
|
||||
* @param string $regexp A Regexp
|
||||
*/
|
||||
public function matchAttribute($key, $regexp)
|
||||
public function matchAttribute(string $key, string $regexp)
|
||||
{
|
||||
$this->attributes[$key] = $regexp;
|
||||
}
|
||||
@@ -170,7 +164,11 @@ class RequestMatcher implements RequestMatcherInterface
|
||||
}
|
||||
|
||||
foreach ($this->attributes as $key => $pattern) {
|
||||
if (!preg_match('{'.$pattern.'}', $request->attributes->get($key))) {
|
||||
$requestAttribute = $request->attributes->get($key);
|
||||
if (!\is_string($requestAttribute)) {
|
||||
return false;
|
||||
}
|
||||
if (!preg_match('{'.$pattern.'}', $requestAttribute)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -187,7 +185,7 @@ class RequestMatcher implements RequestMatcherInterface
|
||||
return false;
|
||||
}
|
||||
|
||||
if (IpUtils::checkIp($request->getClientIp(), $this->ips)) {
|
||||
if (IpUtils::checkIp($request->getClientIp() ?? '', $this->ips)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user