moby / vpnkit

A toolkit for embedding VPN capabilities in your application
Apache License 2.0
1.1k stars 187 forks source link

mux: perform an initial handshake to check the data connection #487

Closed djs55 closed 5 years ago

djs55 commented 5 years ago

Previously if we connected to the wrong service we would output a confusing set of error messages.

Previously if the connection returned EOF (e.g. because it was forwarded by something like docker run -p) we would also output a confusing set of error messages.

This patch makes the constructor NewMultiplexer return an error, which is the result of a handshake exchange. This means that NewMultiplexer is now a blocking operation.

The handshake contains the magic string

  https://github.com/moby/vpnkit multiplexer protocol\n

so hopefully it will be obvious to other people what this protocol is.

For future use the handshake includes a variable length payload which could contain feature flags in the future.

Signed-off-by: David Scott dave.scott@docker.com

djs55 commented 5 years ago

Travis (the CI which builds and tests the Go code) is now happy, so merging