golang.org/x/crypto/ssh, but the ssh spec specifies quite clearly how to
flush the payload at the end of a packet. It requires what is essentially
the Z_PARTIAL_FLUSH method of zlib. Here’s the relevant part of the RFC,
as well as a good summary of the different flush methods.
http://tools.ietf.org/html/rfc4253#section-6.2
http://www.bolet.org/~pornin/deflate-flush-fr.html
As a side note, Z_PARTIAL_FLUSH was deprecated for a while, but is now
un-deprecated again (http://www.zlib.net/ChangeLog.txt).
This “partial flush” method isn’t implemented in compress/flate—the Writer
type has one method, Flush(), which corresponds to the Z_SYNC_FLUSH method
in zlib. (maybe because of the temporary deprecation?) So we can’t use
compress/flate to implement ssh compression correctly.
On the other hand, it seems that at least one SSH implementation
(http://www.lysator.liu.se/~nisse/lsh/) uses Z_SYNC_FLUSH, so apparently it
doesn’t cause problems in practice.
I think it still makes sense to conform to the ssh spec, but this means
adding partial flush functionality to flate.Writer. I can think of a few
potentially reasonable API shapes:
1) [backwards-incompatible] Drop the Flush method and replace it with
specific SyncFlush and PartialFlush methods.
2) [backwards-incompatible] Change the Flush method to take a parameter
specifying the type of flush.
3) [backwards-compatible] Add SyncFlush and PartialFlush methods, leaving
Flush as a sort of “recommended/default flush”, and suggesting that you use
the other flush methods if you care what kind you get.
4) [backwards-compatible] Simply add PartialFlush, just leaving Flush as
is. This is maybe the most likely option, as mentioned in the code review
for the original
Flush(): https://groups.google.com/forum/#!searchin/golang-dev/flate$20flush/golang-dev/XARip6_k42A/593ISDhrCV4J
It does leave the names a bit inconsistent with zlib, however.
So, assuming that this is a reasonable thing to add, what should the API
look like?
Cheers,
Aaron
--
You received this message because you are subscribed to the Google Groups "golang-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.