Add DoH setting
This commit is contained in:
parent
0a2e325229
commit
d74efbfd08
@ -60,7 +60,7 @@ class MyEventHandler extends EventHandler
|
|||||||
*
|
*
|
||||||
* @param array $update Update
|
* @param array $update Update
|
||||||
*
|
*
|
||||||
* @return void
|
* @return \Generator
|
||||||
*/
|
*/
|
||||||
public function onUpdateNewChannelMessage(array $update): \Generator
|
public function onUpdateNewChannelMessage(array $update): \Generator
|
||||||
{
|
{
|
||||||
|
@ -98,13 +98,13 @@ class DataCenter
|
|||||||
/**
|
/**
|
||||||
* DNS over HTTPS client.
|
* DNS over HTTPS client.
|
||||||
*
|
*
|
||||||
* @var \Amp\DoH\Rfc8484StubResolver
|
* @var Rfc8484StubResolver|Rfc1035StubResolver
|
||||||
*/
|
*/
|
||||||
private $DoHClient;
|
private $DoHClient;
|
||||||
/**
|
/**
|
||||||
* Non-proxied DNS over HTTPS client.
|
* Non-proxied DNS over HTTPS client.
|
||||||
*
|
*
|
||||||
* @var \Amp\DoH\Rfc8484StubResolver
|
* @var Rfc8484StubResolver|Rfc1035StubResolver
|
||||||
*/
|
*/
|
||||||
private $nonProxiedDoHClient;
|
private $nonProxiedDoHClient;
|
||||||
/**
|
/**
|
||||||
@ -233,13 +233,15 @@ class DataCenter
|
|||||||
$DoHHTTPClient = (new HttpClientBuilder())->interceptNetwork(new CookieInterceptor($this->CookieJar))->usingPool(new UnlimitedConnectionPool(new DefaultConnectionFactory(new ContextConnector($this, true))))->build();
|
$DoHHTTPClient = (new HttpClientBuilder())->interceptNetwork(new CookieInterceptor($this->CookieJar))->usingPool(new UnlimitedConnectionPool(new DefaultConnectionFactory(new ContextConnector($this, true))))->build();
|
||||||
$DoHConfig = new DoHConfig([new Nameserver('https://mozilla.cloudflare-dns.com/dns-query'), new Nameserver('https://dns.google/resolve')], $DoHHTTPClient);
|
$DoHConfig = new DoHConfig([new Nameserver('https://mozilla.cloudflare-dns.com/dns-query'), new Nameserver('https://dns.google/resolve')], $DoHHTTPClient);
|
||||||
$nonProxiedDoHConfig = new DoHConfig([new Nameserver('https://mozilla.cloudflare-dns.com/dns-query'), new Nameserver('https://dns.google/resolve')]);
|
$nonProxiedDoHConfig = new DoHConfig([new Nameserver('https://mozilla.cloudflare-dns.com/dns-query'), new Nameserver('https://dns.google/resolve')]);
|
||||||
$this->DoHClient = Magic::$altervista || Magic::$zerowebhost ? new Rfc1035StubResolver() : new Rfc8484StubResolver($DoHConfig);
|
$this->DoHClient = Magic::$altervista || Magic::$zerowebhost || !$settings->getUseDoH()
|
||||||
$this->nonProxiedDoHClient = Magic::$altervista || Magic::$zerowebhost ? new Rfc1035StubResolver() : new Rfc8484StubResolver($nonProxiedDoHConfig);
|
? new Rfc1035StubResolver()
|
||||||
|
: new Rfc8484StubResolver($DoHConfig);
|
||||||
|
$this->nonProxiedDoHClient = Magic::$altervista || Magic::$zerowebhost || !$settings->getUseDoH()
|
||||||
|
? new Rfc1035StubResolver()
|
||||||
|
: new Rfc8484StubResolver($nonProxiedDoHConfig);
|
||||||
|
|
||||||
$this->dnsConnector = new DnsConnector(new Rfc1035StubResolver());
|
$this->dnsConnector = new DnsConnector(new Rfc1035StubResolver());
|
||||||
if (\class_exists(Rfc6455Connector::class)) {
|
$this->webSocketConnector = new Rfc6455Connector($this->HTTPClient);
|
||||||
$this->webSocketConnector = new Rfc6455Connector($this->HTTPClient);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
$this->settings->applyChanges();
|
$this->settings->applyChanges();
|
||||||
}
|
}
|
||||||
|
@ -82,7 +82,7 @@ class Logger
|
|||||||
/**
|
/**
|
||||||
* Default logger instance.
|
* Default logger instance.
|
||||||
*
|
*
|
||||||
* @var ?self
|
* @var self
|
||||||
*/
|
*/
|
||||||
public static $default;
|
public static $default;
|
||||||
/**
|
/**
|
||||||
|
@ -86,6 +86,11 @@ class Connection extends SettingsAbstract
|
|||||||
*/
|
*/
|
||||||
protected bool $retry = true;
|
protected bool $retry = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether to use DNS over HTTPS.
|
||||||
|
*/
|
||||||
|
protected bool $useDoH = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Subdomains of web.telegram.org for https protocol.
|
* Subdomains of web.telegram.org for https protocol.
|
||||||
*/
|
*/
|
||||||
@ -594,4 +599,28 @@ class Connection extends SettingsAbstract
|
|||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get whether to use DNS over HTTPS.
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function getUseDoH(): bool
|
||||||
|
{
|
||||||
|
return $this->useDoH;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set whether to use DNS over HTTPS.
|
||||||
|
*
|
||||||
|
* @param bool $useDoH Whether to use DNS over HTTPS
|
||||||
|
*
|
||||||
|
* @return self
|
||||||
|
*/
|
||||||
|
public function setUseDoH(bool $useDoH): self
|
||||||
|
{
|
||||||
|
$this->useDoH = $useDoH;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user