go: mux: avoid desynchronising the stream with io.Copy
go: mux: avoid desynchronising the stream with io.Copy

Previously we would `io.CopyN` from the network to the internal
pipe. If the internal pipe `Write` fails with `EOF` immediately
then `io.CopyN` will return `0, EOF` to reflect the fact that it
has failed to copy any bytes. However this means we don't know
how many bytes to discard to find the next header boundary, causing
the stream to desynchronise.

This patch reads the whole payload into a temporary `bytes.Buffer`
and then performs a best-effort `io.Copy` into the `readPipe`,
discarding any data which won't fit. This guarantees the stream
remains synchronised.

Note we trust the clients not to exceed the Window size and blow up
the size of the `bytes.Buffer`. Clients are assumed to be trusted.

Signed-off-by: David Scott <63c9eb0ea83039690fefa11afe17873ba8278a56@docker.com>

djs55/vpnkit,djs55/vpnkit,djs55/vpnkit