This commit is contained in:
Daniil Gentili 2020-02-26 11:47:30 +01:00
parent f22263ed78
commit 753e6575ac
Signed by: danog
GPG Key ID: 8C1BE3B34B230CA7
10 changed files with 52 additions and 39 deletions

View File

@ -138,7 +138,7 @@ class API extends InternalDoc
$this->storage = $this->API->storage ?? $this->storage;
unset($unserialized);
yield from $this->API->initAsynchronously();
$this->APIFactory();
$this->logger->logger(Lang::$current_lang['madelineproto_ready'], Logger::NOTICE);
@ -182,7 +182,7 @@ class API extends InternalDoc
}
}
/**
* Wakeup function
* Wakeup function.
*
* @return void
*/

View File

@ -48,14 +48,14 @@ final class APIWrapper
private bool $gettingApiId = false;
/**
* Web API template
*
* Web API template.
*
* @var string
*/
private string $webApiTemplate = '';
/**
* My.telegram.org wrapper
* My.telegram.org wrapper.
*
* @var ?MyTelegramOrgWrapper
*/
@ -69,13 +69,13 @@ final class APIWrapper
private int $serialized = 0;
/**
* AbstractAPIFactory instance
*
* AbstractAPIFactory instance.
*
* @var AbstractAPIFactory
*/
private AbstractAPIFactory $factory;
/**
* API wrapper
* API wrapper.
*
* @param API $API API instance to wrap
* @param AbstractAPIFactory $factory Factory
@ -87,11 +87,11 @@ final class APIWrapper
}
/**
* Link two APIWrapper and API instances
* Link two APIWrapper and API instances.
*
* @param API|APIWrapper $a Instance to which link
* @param API|APIWrapper $b Instance from which link
*
*
* @return void
*/
public static function link($a, $b): void
@ -115,7 +115,7 @@ final class APIWrapper
}
/**
* Get MTProto instance
* Get MTProto instance.
*
* @return MTProto|null
*/
@ -125,7 +125,7 @@ final class APIWrapper
}
/**
* Get API factory
* Get API factory.
*
* @return AbstractAPIFactory
*/

View File

@ -70,7 +70,7 @@ abstract class AbstractAPIFactory extends AsyncConstruct
*/
protected function exportNamespace(string $namespace = ''): self
{
$class = array_reverse(array_values(class_parents(static::class)))[3];
$class = \array_reverse(\array_values(\class_parents(static::class)))[3];
$instance = new $class;
$instance->namespace = $namespace.'.';
self::link($instance, $this);
@ -78,11 +78,11 @@ abstract class AbstractAPIFactory extends AsyncConstruct
return $instance;
}
/**
* Link two APIFactory instances
* Link two APIFactory instances.
*
* @param self $a First instance
* @param self $b Second instance
*
*
* @return void
*/
protected static function link(self $a, self $b): void
@ -135,7 +135,7 @@ abstract class AbstractAPIFactory extends AsyncConstruct
}
}
/**
* Info to dump
* Info to dump.
*
* @return array
*/

View File

@ -68,10 +68,10 @@ class AsyncConstruct
return !$this->asyncInitPromise;
}
/**
* Mark instance as (de)inited forcefully
* Mark instance as (de)inited forcefully.
*
* @param boolean $inited Whether to mark the instance as inited or deinited
*
*
* @return void
*/
public function forceInit(bool $inited): void

View File

@ -115,7 +115,7 @@ class DataCenter
*/
private $CookieJar;
/**
* DNS connector
* DNS connector.
*
* @var DNSConnector
*/
@ -226,7 +226,7 @@ class DataCenter
$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->nonProxiedDoHClient = Magic::$altervista || Magic::$zerowebhost ? new Rfc1035StubResolver() : new Rfc8484StubResolver($nonProxiedDoHConfig);
$this->dnsConnector = new DnsConnector(new Rfc1035StubResolver());
}
}

View File

@ -5409,6 +5409,20 @@ class InternalDoc extends APIFactory
{
return $this->__call(__FUNCTION__, [$obj, $var]);
}
/**
* Sets a private variable in an object.
*
* @param object $obj Object
* @param string $var Attribute name
* @param mixed $val Attribute value
*
* @return mixed
* @access public
*/
public function setVar($obj, string $var, &$val): void
{
\danog\MadelineProto\MTProto::setVar($obj, $var, $val);
}
/**
* Discard call.
*

View File

@ -30,19 +30,19 @@ use danog\MadelineProto\MTProto;
class PeriodicLoop extends ResumableSignalLoop
{
/**
* Callback
* Callback.
*
* @var callable
*/
private $callback;
/**
* Loop name
* Loop name.
*
* @var string
*/
private string $name;
/**
* Loop timeeout
* Loop timeeout.
*
* @var int
*/

File diff suppressed because one or more lines are too long

View File

@ -24,10 +24,10 @@ use function Amp\ByteStream\getOutputBufferStream;
trait Templates
{
/**
* Echo page to console
* Echo page to console.
*
* @param string $message Error message
*
*
* @return \Generator
*/
private function webEcho(string $message = ''): \Generator
@ -57,17 +57,17 @@ trait Templates
}
}
/**
* Web template
* Web template.
*
* @var string
*/
private $web_template = '<!DOCTYPE html><html><head><title>MadelineProto</title></head><body><h1>MadelineProto</h1><form method="POST">%s<button type="submit"/>Go</button></form><p>%s</p></body></html>';
/**
* Format message according to template
* Format message according to template.
*
* @param string $message Message
* @param string $form Form contents
*
*
* @return string
*/
private function webEchoTemplate(string $message, string $form): string

View File

@ -73,7 +73,7 @@ final class DataCenterTest extends TestCase
);
$API->datacenter = $datacenter;
$API->getLogger()->logger("Testing protocol $protocol using transport $transport, ".($obfuscated ? 'obfuscated ' : 'not obfuscated ').($test_mode ? 'test DC ' : 'main DC ').($ipv6 ? 'IPv6 ' : 'IPv4 ').($doh ? "DNS over HTTPS" : "DNS");
$API->getLogger()->logger("Testing protocol $protocol using transport $transport, ".($obfuscated ? 'obfuscated ' : 'not obfuscated ').($test_mode ? 'test DC ' : 'main DC ').($ipv6 ? 'IPv6 ' : 'IPv4 ').($doh ? "DNS over HTTPS" : "DNS"));
\sleep(1);
try {