HTTP proxy bugfix

This commit is contained in:
Daniil Gentili 2019-06-12 22:18:53 +02:00
parent 80e50bcf20
commit 0544ad7320

View File

@ -53,9 +53,12 @@ class HttpProxy implements RawProxyStreamInterface, BufferedProxyStreamInterface
$address = $uri->getHost();
$port = $uri->getPort();
if (strlen(inet_pton($address)) === 16) {
try {
if (strlen(inet_pton($address) === 16)) {
$address = '['.$address.']';
}
} catch (\danog\MadelineProto\Exception $e) {
}
yield $this->stream->write("CONNECT $address:$port HTTP/1.1\r\nHost: $address:$port\r\nAccept: */*\r\n".$this->getProxyAuthHeader()."Connection: keep-Alive\r\n\r\n");
@ -121,11 +124,11 @@ class HttpProxy implements RawProxyStreamInterface, BufferedProxyStreamInterface
$length = (int) $headers['content-length'];
$read = yield $buffer->bufferRead($length);
}
\danog\MadelineProto\Logger::log('Connected to '.$address.':'.$port.' via http');
if ($secure && method_exists($this->getSocket(), 'enableCrypto')) {
yield $this->getSocket()->enableCrypto((new ClientTlsContext())->withPeerName($uri->getHost()));
}
\danog\MadelineProto\Logger::log('Connected to '.$address.':'.$port.' via http');
if (strlen($header)) {
yield (yield $this->stream->getWriteBuffer(strlen($header)))->bufferWrite($header);