HTTP proxy bugfix
This commit is contained in:
parent
80e50bcf20
commit
0544ad7320
|
@ -53,8 +53,11 @@ class HttpProxy implements RawProxyStreamInterface, BufferedProxyStreamInterface
|
||||||
$address = $uri->getHost();
|
$address = $uri->getHost();
|
||||||
$port = $uri->getPort();
|
$port = $uri->getPort();
|
||||||
|
|
||||||
if (strlen(inet_pton($address)) === 16) {
|
try {
|
||||||
$address = '['.$address.']';
|
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");
|
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'];
|
$length = (int) $headers['content-length'];
|
||||||
$read = yield $buffer->bufferRead($length);
|
$read = yield $buffer->bufferRead($length);
|
||||||
}
|
}
|
||||||
\danog\MadelineProto\Logger::log('Connected to '.$address.':'.$port.' via http');
|
|
||||||
|
|
||||||
if ($secure && method_exists($this->getSocket(), 'enableCrypto')) {
|
if ($secure && method_exists($this->getSocket(), 'enableCrypto')) {
|
||||||
yield $this->getSocket()->enableCrypto((new ClientTlsContext())->withPeerName($uri->getHost()));
|
yield $this->getSocket()->enableCrypto((new ClientTlsContext())->withPeerName($uri->getHost()));
|
||||||
}
|
}
|
||||||
|
\danog\MadelineProto\Logger::log('Connected to '.$address.':'.$port.' via http');
|
||||||
|
|
||||||
if (strlen($header)) {
|
if (strlen($header)) {
|
||||||
yield (yield $this->stream->getWriteBuffer(strlen($header)))->bufferWrite($header);
|
yield (yield $this->stream->getWriteBuffer(strlen($header)))->bufferWrite($header);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user