Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Report wireguard endpoint as a candidate when an endpoint override is in place #305

Merged
merged 7 commits into from
Apr 3, 2024

Conversation

bschwind
Copy link
Member

Scenario: you have a machine which at one point ran innernet override-endpoint with an endpoint which maybe worked in the past, but doesn't work now. Because the endpoint is overridden, it is the endpoint peers try, along with any extra endpoint candidates reported by the peer.

What doesn't get reported to other peers is the current wireguard endpoint the innernet server sees. It used to only use that wg endpoint if the peer hadn't overridden it.

The easiest fix I can think of is to just add the endpoint the server sees to the list of NAT candidates we give peers to try.

The server logic could perhaps be simplified further - report all possible candidates we know about on the server side, and maybe allow the client to specify additional endpoints it wants to use as candidates. But for now this PR is probably sufficient?

I haven't tested yet, and it might need more tests added to our CI to cover this case.

Copy link
Member

@strohel strohel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh nice, that's very useful and very sane behavior.

One little technicality. If @mcginty happens to be around, it'd be cool if you could check if your intent with this makes good sense.

server/src/api/mod.rs Outdated Show resolved Hide resolved
@mcginty
Copy link
Collaborator

mcginty commented Mar 18, 2024

@strohel I chatted with @bschwind about it, and it makes perfect sense to me! It should have been like this all along in my opinion (after candidates were added, that is).

On that note, I think there are a couple of things worth considering to make this even clearer:

  • The server should really only report a list of endpoints to try, there's no need to have both an endpoint and candidates field any more is there?
  • override-endpoint as a name makes this all a bit more confusing. We might even consider deprecating it in favor of allowing the user to specify an arbitrary number of additional candidates (add-candidate-endpoints?)

@bschwind
Copy link
Member Author

The server should really only report a list of endpoints to try, there's no need to have both an endpoint and candidates field any more is there?

Yes, I think now there is no point in distinguishing the two. We just need to figure out the API and all that for adding/removing endpoint candidates, which I didn't want to tackle in this PR as it involves quite a bit more changes.

Copy link
Member

@strohel strohel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@strohel I chatted with @bschwind about it, and it makes perfect sense to me! It should have been like this all along in my opinion (after candidates were added, that is).

Ah cool!

On that note, I think there are a couple of things worth considering to make this even clearer:

  • The server should really only report a list of endpoints to try, there's no need to have both an endpoint and candidates field any more is there?

Makes good sense. I guess this would be a breaking change to the server<->client protocol, so I wonder what our different version interoperability story is:

  • I guess new clients should be compatible with older servers? It is harder to control client versions, people will usually install the latest version.
  • Would be also nice if older clients are compatible with new servers, can be hard to udpate all of them if some are stuck wit outdated OSes etc.

We may also decide the protocol breaking change is not worth it. We can still have just a list of endpoints on Rust level on both server and client, just (de)serialize it to "first: Endpoint + rest: Vec" on the wire. (as a side-effect, it encodes the combined list is non-empty)

  • override-endpoint as a name makes this all a bit more confusing. We might even consider deprecating it in favor of allowing the user to specify an arbitrary number of additional candidates (add-candidate-endpoints?)

Yup!


Anyways, as @bschwind says, I think this change is a good improvement as-is, let's merge after testing and release as 1.6.2.

The follow-ups can go in later.

@bschwind
Copy link
Member Author

Haven't merged this yet as I'd like to add some CI tests, will hopefully get to that soon.

@bschwind
Copy link
Member Author

@mcginty @strohel I added more tests for this guy, it could use another look.

@bschwind bschwind force-pushed the report-endpoint-as-candidate branch from f4341c2 to 65d211f Compare March 29, 2024 10:44
Copy link
Member

@strohel strohel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bschwind thanks for the tests! LGTM++

Copy link
Collaborator

@mcginty mcginty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DOUBLE APPROVE

@bschwind bschwind merged commit 4fb77f8 into main Apr 3, 2024
9 checks passed
@bschwind bschwind deleted the report-endpoint-as-candidate branch April 3, 2024 04:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants