Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 4 additions & 12 deletions lib/private/Http/Client/DnsPinMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,15 @@
use Psr\Http\Message\RequestInterface;

class DnsPinMiddleware {
/** @var NegativeDnsCache */
private $negativeDnsCache;
private IpAddressClassifier $ipAddressClassifier;

public function __construct(
NegativeDnsCache $negativeDnsCache,
IpAddressClassifier $ipAddressClassifier,
private NegativeDnsCache $negativeDnsCache,
private IpAddressClassifier $ipAddressClassifier,
) {
$this->negativeDnsCache = $negativeDnsCache;
$this->ipAddressClassifier = $ipAddressClassifier;
}

/**
* Fetch soa record for a target
*
* @param string $target
* @return array|null
*/
private function soaRecord(string $target): ?array {
$labels = explode('.', $target);
Expand Down Expand Up @@ -99,7 +91,7 @@ protected function dnsGetRecord(string $hostname, int $type): array|false {
return \dns_get_record($hostname, $type);
}

public function addDnsPinning() {
public function addDnsPinning(): callable {
return function (callable $handler) {
return function (
RequestInterface $request,
Expand All @@ -109,7 +101,7 @@ public function addDnsPinning() {
return $handler($request, $options);
}

$hostName = (string)$request->getUri()->getHost();
$hostName = $request->getUri()->getHost();
$port = $request->getUri()->getPort();

$ports = [
Expand Down
Loading