Proxy bugfixes

This commit is contained in:
Daniil Gentili 2019-12-29 13:20:18 +01:00
parent a3bfde1dea
commit 4d3543b49b
Signed by: danog
GPG Key ID: 8C1BE3B34B230CA7
5 changed files with 29 additions and 15 deletions

View File

@ -34,7 +34,7 @@ class ContextConnector implements Connector
public function __construct(DataCenter $dataCenter, bool $fromDns = false)
{
$this->dataCenter = $dataCenter;
$this->fromDns = false;
$this->fromDns = $fromDns;
$this->logger = $dataCenter->getAPI()->getLogger();
}

View File

@ -175,11 +175,11 @@ class DataCenter
/**
* Constructor function.
*
* @param MTProto $API Main MTProto instance
* @param array $dclist DC IP list
* @param array $settings Settings
* @param boolean $reconnectAll Whether to reconnect to all DCs or just to changed ones
* @param CookieJar $jar Cookie jar
* @param MTProto $API Main MTProto instance
* @param array $dclist DC IP list
* @param array $settings Settings
* @param boolean $reconnectAll Whether to reconnect to all DCs or just to changed ones
* @param CookieJar $jar Cookie jar
*
* @return void
*/
@ -207,6 +207,7 @@ class DataCenter
if ($socket instanceof DataCenterConnection && !\strpos($key, '_bk')) {
//$this->API->logger->logger(\sprintf(\danog\MadelineProto\Lang::$current_lang['dc_con_stop'], $key), \danog\MadelineProto\Logger::VERBOSE);
if ($reconnectAll || isset($changed[$id])) {
$this->API->logger->logger("Disconnecting all before reconnect!");
$socket->needReconnect(true);
$socket->setExtra($this->API);
$socket->disconnect();
@ -583,7 +584,7 @@ class DataCenter
*/
public function getNonProxiedDNSClient(): Resolver
{
return $this->DoHClient;
return $this->nonProxiedDoHClient;
}
/**

View File

@ -372,7 +372,7 @@ class DataCenterConnection implements JsonSerializable
$this->decRead = $media ? self::READ_WEIGHT_MEDIA : self::READ_WEIGHT;
$this->decWrite = self::WRITE_WEIGHT;
if ($id === -1) {
if ($id === -1 || !isset($this->connections[$id])) {
if ($this->connections) {
$this->API->logger("Already connected!", Logger::WARNING);
return;

View File

@ -78,9 +78,9 @@ class DefaultStream implements
)
);
}
$this->stream = yield ($this->connector ?? connector())->connect((string) $uri, $ctx->getSocketContext(), $ctx->getCancellationToken());
if ($ctx->isSecure()) {
if ($secure) {
yield $this->stream->setupTls();
}
yield $this->stream->write($header);

View File

@ -106,16 +106,12 @@ find phar5 -type f -exec sed 's/\w* \.\.\./.../' -i {} +
branch="-$TRAVIS_BRANCH"
cd $madelinePath
export TRAVIS_PHAR="madeline$php$branch.phar"
export TEST_SECRET_CHAT=test
export TEST_USERNAME=danogentili
export TEST_DESTINATION_GROUPS='["@danogentili"]'
export MTPROTO_SETTINGS='{"logger":{"logger_level":5}}'
php tools/makephar.php $HOME/phar5 "$TRAVIS_PHAR" $TRAVIS_COMMIT
curl -s https://api.telegram.org/bot$BOT_TOKEN/sendDocument -F chat_id=101374607 -F document="@$TRAVIS_PHAR"
php tools/makephar.php $HOME/phar5 "madeline$php$branch.phar" $TRAVIS_COMMIT
tests/testing.php <<EOF
m
@ -128,6 +124,23 @@ n
n
EOF
export TRAVIS_PHAR="madeline$php$branch.phar"
tests/testing.php
rm testing.madeline
tests/testing.php <<EOF
m
$API_ID
$API_HASH
b
$BOT_TOKEN
n
n
n
EOF
tests/testing.php
eval "$(ssh-agent -s)"
echo -e "$private_key" > madeline_rsa