fpoirotte / pssht

SSH server written in PHP
https://pssht.readthedocs.io
MIT License
43 stars 9 forks source link

Support pecl_http 2.x for compression #30

Open fpoirotte opened 9 years ago

fpoirotte commented 9 years ago

pssht relies on the PECL HTTP extension to provide compression on a stream of data (rather than on a fixed-length buffer). Currently, the old 1.x branch is the only version supported.

The goal of this ticket is to add support for version 2.x as well to have broader support for compression. As an alternative, maybe take a look at stream filters to see if it is possible to use them in a streaming mode.

kklem0 commented 8 years ago

Just a quick looking around, why not use stream_filter_append for example to inflate/deflate so you can get rid of pecl_http which is not installed usually? (also seeing some failed tests about it)

fpoirotte commented 8 years ago

Hi,

For compression to work in ssh, a way to flush the compression buffers is required. The flush operation adds synchronization points to the data, which can be used for example by the receiving end to determine when to stop looking for more data to uncompress.

The pecl_http extension provides the FLUSH_SYNC flag for that purpose so that a synchronization point is automatically added after each call to the update() method. Unfortunately, the zlib extension does not currently support flushing its internal buffers (see https://bugs.php.net/bug.php?id=48725) and therefore is not a suitable replacement for pecl_http for the time being.

Regarding the current tests failures, they are due to some functional tests where the OpenBSD SSH client is used to establish a connection to a pssht server with varying ciphers. For some reason, this works when I test it locally, but errors out on travis-ci.

fpoirotte commented 6 years ago

PHP 7.0 added support for incremental compression/decompression (see http://php.net/manual/en/zlib.examples.php), so it may be possible to use this new API to achieve the same result.