@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | ): callable { |
120 | 120 | $storage = StorageFactory::create($cache); |
121 | 121 | |
122 | - return static function (\Closure $handler) use ($storage, $dohServers, $logger, $debug) { |
|
122 | + return static function(\Closure $handler) use ($storage, $dohServers, $logger, $debug) { |
|
123 | 123 | /** @psalm-var \Closure(\Psr\Http\Message\RequestInterface, array $options): \GuzzleHttp\Promise\PromiseInterface $handler */ |
124 | 124 | return new self($handler, $storage, $dohServers, $logger ?? new NullLogger(), $debug); |
125 | 125 | }; |
@@ -171,14 +171,14 @@ discard block |
||
171 | 171 | $domainName = $dnsRecord->getDomainName(); |
172 | 172 | $ipAddressesString = implode(',', $ipAddresses); |
173 | 173 | $curlOptions[\CURLOPT_RESOLVE] = [ |
174 | - $domainName . ':80:' . $ipAddressesString, |
|
175 | - $domainName . ':443:' . $ipAddressesString, |
|
174 | + $domainName.':80:'.$ipAddressesString, |
|
175 | + $domainName.':443:'.$ipAddressesString, |
|
176 | 176 | ]; |
177 | 177 | |
178 | 178 | $port = $request->getUri()->getPort(); |
179 | 179 | |
180 | 180 | if ($port !== null && $port !== 80 && $port !== 443) { |
181 | - $curlOptions[\CURLOPT_RESOLVE][] = $domainName . ':' . $port . ':' . $ipAddressesString; |
|
181 | + $curlOptions[\CURLOPT_RESOLVE][] = $domainName.':'.$port.':'.$ipAddressesString; |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | $this->logger->debug(sprintf('[DoH] Set ip addresses %s for domain %s', $ipAddressesString, $domainName)); |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | $options['curl'] = $curlOptions; |
187 | 187 | |
188 | 188 | return ($this->nextHandler)($request, $options)->then( |
189 | - static function (ResponseInterface $response) use ($ipAddressesString, $dnsRecord) { |
|
189 | + static function(ResponseInterface $response) use ($ipAddressesString, $dnsRecord) { |
|
190 | 190 | if ($dnsRecord->cacheHit) { |
191 | 191 | $cacheTtl = max(0, $dnsRecord->getExpiredAt()->getTimestamp() - time()); |
192 | 192 | $response = $response->withHeader(self::HEADER_RESPONSE_CACHE_TTL, (string) $cacheTtl); |
@@ -200,20 +200,20 @@ |
||
200 | 200 | { |
201 | 201 | $encodedDomainName = implode( |
202 | 202 | '', |
203 | - array_map(static function (string $domainBit) { |
|
204 | - return \chr(\strlen($domainBit)) . $domainBit; |
|
203 | + array_map(static function(string $domainBit) { |
|
204 | + return \chr(\strlen($domainBit)).$domainBit; |
|
205 | 205 | }, explode('.', $domainName)) |
206 | 206 | ); |
207 | 207 | |
208 | 208 | return "\xab\xcd" |
209 | - . \chr(1) . \chr(0) |
|
210 | - . \chr(0) . \chr(1) // qdc |
|
211 | - . \chr(0) . \chr(0) // anc |
|
212 | - . \chr(0) . \chr(0) // nsc |
|
213 | - . \chr(0) . \chr(0) // arc |
|
214 | - . $encodedDomainName . \chr(0) // domain name |
|
215 | - . \chr(0) . \chr(ResourceTypes::A) // resource type |
|
216 | - . \chr(0) . \chr(1); // qclass |
|
209 | + . \chr(1).\chr(0) |
|
210 | + . \chr(0).\chr(1) // qdc |
|
211 | + . \chr(0).\chr(0) // anc |
|
212 | + . \chr(0).\chr(0) // nsc |
|
213 | + . \chr(0).\chr(0) // arc |
|
214 | + . $encodedDomainName.\chr(0) // domain name |
|
215 | + . \chr(0).\chr(ResourceTypes::A) // resource type |
|
216 | + . \chr(0).\chr(1); // qclass |
|
217 | 217 | } |
218 | 218 | |
219 | 219 | private static function encodeRequest(string $request): string |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | |
41 | 41 | return $dnsRecord; |
42 | 42 | } catch (InvalidArgumentException $e) { |
43 | - throw new \RuntimeException('Invalid cache key ' . $cacheKey, 0, $e); |
|
43 | + throw new \RuntimeException('Invalid cache key '.$cacheKey, 0, $e); |
|
44 | 44 | } |
45 | 45 | } |
46 | 46 | |
@@ -52,12 +52,12 @@ discard block |
||
52 | 52 | try { |
53 | 53 | $this->cache->set($cacheKey, $dnsRecord, $dnsRecord->getTTL()); |
54 | 54 | } catch (InvalidArgumentException $e) { |
55 | - throw new \RuntimeException('Invalid cache key ' . $cacheKey, 0, $e); |
|
55 | + throw new \RuntimeException('Invalid cache key '.$cacheKey, 0, $e); |
|
56 | 56 | } |
57 | 57 | } |
58 | 58 | |
59 | 59 | private function getCacheKey(string $domainName): string |
60 | 60 | { |
61 | - return rawurlencode('guzzle.doh.psr16.' . $domainName); |
|
61 | + return rawurlencode('guzzle.doh.psr16.'.$domainName); |
|
62 | 62 | } |
63 | 63 | } |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | |
41 | 41 | return $dnsRecord; |
42 | 42 | } catch (InvalidArgumentException $e) { |
43 | - throw new \RuntimeException('Invalid cache key ' . $cacheKey, 0, $e); |
|
43 | + throw new \RuntimeException('Invalid cache key '.$cacheKey, 0, $e); |
|
44 | 44 | } |
45 | 45 | } |
46 | 46 | |
@@ -55,12 +55,12 @@ discard block |
||
55 | 55 | $cacheItem->set($dnsRecord); |
56 | 56 | $this->cachePool->save($cacheItem); |
57 | 57 | } catch (InvalidArgumentException $e) { |
58 | - throw new \RuntimeException('Invalid cache key ' . $cacheKey, 0, $e); |
|
58 | + throw new \RuntimeException('Invalid cache key '.$cacheKey, 0, $e); |
|
59 | 59 | } |
60 | 60 | } |
61 | 61 | |
62 | 62 | private function getCacheKey(string $domainName): string |
63 | 63 | { |
64 | - return rawurlencode('guzzle.doh.psr6.' . $domainName); |
|
64 | + return rawurlencode('guzzle.doh.psr6.'.$domainName); |
|
65 | 65 | } |
66 | 66 | } |