Bugfixes to HTTP proxy

This commit is contained in:
Daniil Gentili 2018-04-18 16:40:40 +02:00
parent e0ceb0f39c
commit 771e34d332
3 changed files with 16 additions and 13 deletions

View File

@ -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)

2
docs

@ -1 +1 @@
Subproject commit 733a119e0cd84382fd46c51e5ada2b19e1a296a1
Subproject commit 3a5b18f742fa7f2898562aa3e9d7d20a2634bf69

View File

@ -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');
}