8000 VPN RPC protocol does not have good support for version negotiation · Issue #15601 · coder/coder · GitHub
[go: up one dir, main page]

8000 Skip to content
VPN RPC protocol does not have good support for version negotiation #15601
@deansheather

Description

@deansheather

Currently we're using apiversion.APIVersion as our version type for the VPN RPC code. This code was originally written for client=>server version negotiation where only the server would support multiple versions, and the client would only send it's best version. In the VPN RPC protocol though, we would conceivably have situations where either side could be newer and so both sides should be able to negotiate the best version.

Proposal

Change our codervpn header/handshake format from codervpn <version> <role_enum> to codervpn <role_enum> <versions...>.

The sent versions in the header would be each major version and the maximum supported minor version on that major version. E.g. codervpn manager 1.3 2.2 3.0 means: 1.0, 1.1, 1.2, 1.3, 2.0, 2.1, 2.2, 3.0 are supported by this peer.

Once each end of the connection receives it's peer's handshake, it will compare the versions against each other to determine the highest mutual version. E.g. with codervpn peer1 1.3 2.2 3.0 and codervpn peer2 1.3 2.1 the version used will be 2.1. If the peers decide that no version is shared, they should log/notify the user and close the connection.

We will most likely need a new type to store these API versions and compare them. Maybe it should go in the apiversion package but we rename the old type and give this type a different name.

The validation method should have a signature like so, returning the best major/minor combination or an error if the two peers are not compatible.

func (v Version) NegotiateVersion(peer Version) (int major, int minor, err error) {}

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0