From 771e34d332147e8d5d1cbc876e69246224b83198 Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Wed, 18 Apr 2018 16:40:40 +0200 Subject: [PATCH] Bugfixes to HTTP proxy --- README.md | 3 +++ docs | 2 +- src/HttpProxy.php | 24 ++++++++++++------------ 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 80674e17..df1e32aa 100644 --- a/README.md +++ b/README.md @@ -127,6 +127,9 @@ Tip: if you receive an error (or nothing), [send us](https://t.me/pwrtelegramgro * [Sending secret messages](https://docs.madelineproto.xyz/docs/SECRET_CHATS.html#sending-secret-messages) * [Lua binding](https://docs.madelineproto.xyz/docs/LUA.html) * [Using a proxy](https://docs.madelineproto.xyz/docs/PROXY.html) + * [Use pre-built Socks5 proxy](https://docs.madelineproto.xyz/docs/PROXY.html#socks5-proxy) + * [Use pre-built HTTP proxy](https://docs.madelineproto.xyz/docs/PROXY.html#http-proxy) + * [Build your own proxy](https://docs.madelineproto.xyz/docs/PROXY.html#build-your-proxy) * [Contributing](https://docs.madelineproto.xyz/docs/CONTRIB.html) * [Translation](https://docs.madelineproto.xyz/docs/CONTRIB.html#translation) * [Contribution guide](https://docs.madelineproto.xyz/docs/CONTRIB.html#contribution-guide) diff --git a/docs b/docs index 733a119e..3a5b18f7 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit 733a119e0cd84382fd46c51e5ada2b19e1a296a1 +Subproject commit 3a5b18f742fa7f2898562aa3e9d7d20a2634bf69 diff --git a/src/HttpProxy.php b/src/HttpProxy.php index 0e928699..1c74d65a 100644 --- a/src/HttpProxy.php +++ b/src/HttpProxy.php @@ -41,27 +41,27 @@ class HttpProxy implements \danog\MadelineProto\Proxy $this->sock = new $name(strlen(@inet_pton($this->extra['address'])) !== 4 ? \AF_INET6 : \AF_INET, \SOCK_STREAM, $this->protocol); } - public function setOption($level, $name, $value) + public function setOption(int $level, int $name, $value) { return $this->sock->setOption($level, $name, $value); } - public function getOption($level, $name) + public function getOption(int $level, int $name) { return $this->sock->getOption($level, $name); } - public function setBlocking($blocking) + public function setBlocking(bool $blocking) { return $this->sock->setBlocking($blocking); } - public function bind($address, $port = 0) + public function bind(string $address, int $port = 0) { throw new \danog\MadelineProto\Exception('Not Implemented'); } - public function listen($backlog = 0) + public function listen(int $backlog = 0) { throw new \danog\MadelineProto\Exception('Not Implemented'); } @@ -71,12 +71,12 @@ class HttpProxy implements \danog\MadelineProto\Proxy throw new \danog\MadelineProto\Exception('Not Implemented'); } - public function select(array &$read, array &$write, array &$except, $tv_sec, $tv_usec = 0) + public function select(array &$read, array &$write, array &$except, int $tv_sec, int $tv_usec = 0) { return $this->sock->select($read, $write, $except, $tv_sec, $tv_usec); } - public function connect($address, $port = 0) + public function connect(string $address, int $port = 0) { $this->sock->connect($this->extra['address'], $this->extra['port']); @@ -138,17 +138,17 @@ class HttpProxy implements \danog\MadelineProto\Proxy return ['protocol' => $protocol, 'protocol_version' => $protocol_version, 'code' => $code, 'description' => $description, 'body' => $read, 'headers' => $headers]; } - public function read($length, $flags = 0) + public function read(int $length, int $flags = 0) { return $this->sock->read($length, $flags); } - public function write($buffer, $length = -1) + public function write(string $buffer, int $length = -1) { return $this->sock->write($buffer, $length); } - public function send($data, $length, $flags) + public function send(string $data, int $length, int $flags) { throw new \danog\MadelineProto\Exception('Not Implemented'); } @@ -158,12 +158,12 @@ class HttpProxy implements \danog\MadelineProto\Proxy $this->sock->close(); } - public function getPeerName($port = true) + public function getPeerName(bool $port = true) { throw new \danog\MadelineProto\Exception('Not Implemented'); } - public function getSockName($port = true) + public function getSockName(bool $port = true) { throw new \danog\MadelineProto\Exception('Not Implemented'); }