diff --git a/src/danog/MadelineProto/DataCenter.php b/src/danog/MadelineProto/DataCenter.php index b725d65c..238f4436 100644 --- a/src/danog/MadelineProto/DataCenter.php +++ b/src/danog/MadelineProto/DataCenter.php @@ -507,7 +507,24 @@ class DataCenter foreach ($combo as $stream) { if ($stream[0] === DefaultStream::getName() && $stream[1] === []) { - $stream[1] = [[$this, 'socketConnect'], [$this, 'cryptoConnect']]; + $isIpv6 = $ipv6 === 'ipv6'; + $stream[1] = [ + function ( + string $uri, + ClientConnectContext $socketContext = null, + CancellationToken $token = null + ) use ($isIpv6): Promise { + return $this->socketConnect($isIpv6, $uri, $socketContext, $token); + }, + function ( + string $uri, + ClientConnectContext $socketContext = null, + ClientTlsContext $tlsContext = null, + CancellationToken $token = null + ) use ($isIpv6): Promise { + return $this->cryptoConnect($isIpv6, $uri, $socketContext, $tlsContext, $token); + } + ]; } $ctx->addStream(...$stream); } @@ -567,7 +584,24 @@ class DataCenter foreach ($combo as $stream) { if ($stream[0] === DefaultStream::getName() && $stream[1] === []) { - $stream[1] = [[$this, 'socketConnect'], [$this, 'cryptoConnect']]; + $isIpv6 = $ipv6 === 'ipv6'; + $stream[1] = [ + function ( + string $uri, + ClientConnectContext $socketContext = null, + CancellationToken $token = null + ) use ($isIpv6): Promise { + return $this->socketConnect($isIpv6, $uri, $socketContext, $token); + }, + function ( + string $uri, + ClientConnectContext $socketContext = null, + ClientTlsContext $tlsContext = null, + CancellationToken $token = null + ) use ($isIpv6): Promise { + return $this->cryptoConnect($isIpv6, $uri, $socketContext, $tlsContext, $token); + } + ]; } $ctx->addStream(...$stream); } diff --git a/src/danog/MadelineProto/Stream/Transport/DefaultStream.php b/src/danog/MadelineProto/Stream/Transport/DefaultStream.php index 32786f2d..dfdf49f0 100644 --- a/src/danog/MadelineProto/Stream/Transport/DefaultStream.php +++ b/src/danog/MadelineProto/Stream/Transport/DefaultStream.php @@ -57,9 +57,9 @@ class DefaultStream extends Socket implements RawStreamInterface, ProxyStreamInt public function connectAsync(\danog\MadelineProto\Stream\ConnectionContext $ctx, string $header = ''): \Generator { if ($ctx->isSecure()) { - $this->stream = yield ($this->cryptoConnector)($ctx->getIpv6(), $ctx->getStringUri(), $ctx->getSocketContext(), null, $ctx->getCancellationToken()); + $this->stream = yield ($this->cryptoConnector)($ctx->getStringUri(), $ctx->getSocketContext(), null, $ctx->getCancellationToken()); } else { - $this->stream = yield ($this->connector)($ctx->getIpv6(), $ctx->getStringUri(), $ctx->getSocketContext(), $ctx->getCancellationToken()); + $this->stream = yield ($this->connector)($ctx->getStringUri(), $ctx->getSocketContext(), $ctx->getCancellationToken()); } yield $this->stream->write($header); }