Clean up error return in making MessageStream

This error was a vestige.  The complementary function
NewClientMessageStream already did not have a returned error.

Signed-off-by: Daniel Farina <daniel@heroku.com>
Remove Startup message validation from femebe

It is more naturally rendered in pgproto, even though it is true that
there are no well-formed first-packets that are so large in the wild.

Signed-off-by: Daniel Farina <daniel@heroku.com>
Message.Force returns the buffered byte slice

Because .Force() is idempotent (provided it has succeeded once) there
are few callers interested in forcing and *not* subsequently getting
the byte slice.  Those who do are free to ignore the return value.

Signed-off-by: Daniel Farina <daniel@heroku.com>
go fmt

Signed-off-by: Daniel Farina <daniel@heroku.com>
Vertical white space

Signed-off-by: Daniel Farina <daniel@heroku.com>
Placate Go "gc" compiler family flow analysis

Not to be confused with garbage collection.  "Awesome" naming.

Signed-off-by: Daniel Farina <daniel@heroku.com>
Deprecate distinct pseudo-MsgType for first-messages

First-packets have a zero-byte for the MsgType: the "real" type of the
first packet is typically a four-byte integer and can be handled
independently.  These constants are just vestiges of an attempt to
pack the few known startup packet types into the core protocol framing
and mechanics.

Signed-off-by: Daniel Farina <daniel@heroku.com>
Startup packet parsing and some testing

This handles taking apart and putting together startup packets.  Some
tests are included, even though they are not exhaustive.

Signed-off-by: Daniel Farina <daniel@heroku.com>
De-bitrot simpleproxy.go and fix disconnection propagation

Some much needed maintenance of the simpleproxy.  Not only does it
compile, but some alterations have been made to support propagating
disconnections of client or server to one another.

Signed-off-by: Daniel Farina <daniel@heroku.com>
Remove IsStartup operator

It has a DOS exploit, because it doesn't check message size before
.Force().  It also can be wrong, because it doesn't actually verify
the structure of the startup packet, which ReadStartupMessage does
properly.

Finally, this operator would only be useful to the hypothetical person
who wanted to know something is kind-of-like a startup packet (right
size, right header) without parsing it.  Until then, it's gone.

Signed-off-by: Daniel Farina <daniel@heroku.com>
Add header comment to first-packet handling

Signed-off-by: Daniel Farina <daniel@heroku.com>
Add BackendKeyData Reading, whack around error handling

The main purpose of this patch is to provide structured access to
BackendKeyData messages.  In doing so, it seemed like some of the
errors specially crafted for Startup packets should be made more
general, in particular the class of "wrong size" and "too large"
errors.

"Too small" errors are not very interesting, so they have been demoted
to a more vague ErrWrongSize error.  On the other hand, messages that
seem oversized can represent an attack on the system (anticipating
crashing it via full-buffering) and these have been given their own
category, ErrTooBig.

I then noticed some suspicious looking panicing raised in some
routines: these have been removed and replaced with return codes.

Signed-off-by: Dan Farina <drfarina@acm.org>