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

cmd/tailscale, ipn/ipnlocal: add suggest exit node CLI option #11407

Merged
merged 1 commit into from Apr 15, 2024

Conversation

clairew
Copy link
Member

@clairew clairew commented Mar 13, 2024

Suggest exit node cli

  • requires control to send suggest exit node node attribute for each potential candidate

@clairew clairew force-pushed the clairew/cli-suggest-exit-node branch 2 times, most recently from 04baf65 to 842c64e Compare March 13, 2024 19:53
client/tailscale/localclient.go Outdated Show resolved Hide resolved
cmd/tailscale/cli/exitnode.go Show resolved Hide resolved
ipn/ipnlocal/local.go Outdated Show resolved Hide resolved
ipn/ipnlocal/local.go Outdated Show resolved Hide resolved
ipn/ipnlocal/local.go Outdated Show resolved Hide resolved
ipn/ipnlocal/local.go Outdated Show resolved Hide resolved
// longLatDistance returns an estimated distance given two lists of float64 values that represent polar coordinates.
// The first index is latitude and the second index is longitude.
// Value is returned in meters. We tolerate up to 100km difference in accuracy.
func longLatDistance(firstDistance []float64, secondDistance []float64) float64 {

Choose a reason for hiding this comment

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

If we only want to know which distances are bigger/smaller can we do away with all the math.Pi / 180 s and much of the trig stuff? could we do just sqrt(diffLat^2 + diffLong^2) ? (or even just diffLat+diffLong? how does math work?)

Choose a reason for hiding this comment

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

And are they polar coords or latitude, longitude pairs? because those are different right?

And if they're latitude, longitude pairs does this algo work around wherever the zero lines are?

Copy link
Member Author

Choose a reason for hiding this comment

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

used haversine formula. geographic coordinates.

Copy link

Choose a reason for hiding this comment

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

ok, yep, looking at the call site I see we're calling with latitude and longitude, so the variables shouldn't be called 'distance' I think? seems confusing?

Copy link

Choose a reason for hiding this comment

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

Does this formula work for eg 179 degrees longitude to -179 degrees longitude? Maybe we should add some tests?

Copy link
Member

Choose a reason for hiding this comment

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

Latitude and longitude needs the fancy math because one degree of longitude is a different linear distance depending on latitude. I believe one degree of latitude is always the same linear distance.

This is already the simplified version that assumes the world is a sphere (it is not).

@clairew clairew force-pushed the clairew/cli-suggest-exit-node branch 4 times, most recently from c4dbe66 to e75a5d5 Compare March 14, 2024 13:29
@clairew clairew force-pushed the clairew/cli-suggest-exit-node branch 3 times, most recently from 6ac0e60 to 8dbc130 Compare April 2, 2024 18:13
@clairew clairew requested a review from sailorfrag April 2, 2024 18:14
@clairew clairew marked this pull request as ready for review April 2, 2024 18:14
@clairew clairew force-pushed the clairew/cli-suggest-exit-node branch 2 times, most recently from 21c6b93 to 7425f20 Compare April 3, 2024 14:56
Copy link
Contributor

@nickoneill nickoneill left a comment

Choose a reason for hiding this comment

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

couple more doc clarifications

client/tailscale/localclient.go Outdated Show resolved Hide resolved
wgengine/magicsock/magicsock.go Outdated Show resolved Hide resolved
ipn/ipnlocal/local.go Outdated Show resolved Hide resolved
@clairew clairew force-pushed the clairew/cli-suggest-exit-node branch from 7425f20 to 7ef24ac Compare April 3, 2024 17:15
client/tailscale/apitype/apitype.go Outdated Show resolved Hide resolved
client/tailscale/localclient.go Outdated Show resolved Hide resolved
client/tailscale/apitype/apitype.go Show resolved Hide resolved
cmd/tailscale/cli/exitnode.go Outdated Show resolved Hide resolved
cmd/tailscale/cli/exitnode.go Outdated Show resolved Hide resolved
ipn/ipnlocal/local.go Outdated Show resolved Hide resolved
ipn/ipnlocal/local.go Outdated Show resolved Hide resolved
ipn/ipnlocal/local.go Outdated Show resolved Hide resolved
ipn/localapi/localapi.go Outdated Show resolved Hide resolved
ipn/localapi/localapi.go Outdated Show resolved Hide resolved
@clairew clairew force-pushed the clairew/cli-suggest-exit-node branch 2 times, most recently from a1665c4 to e8203ca Compare April 4, 2024 20:32
@clairew clairew requested a review from sailorfrag April 4, 2024 20:32
@clairew clairew force-pushed the clairew/cli-suggest-exit-node branch 2 times, most recently from 7101c9b to 582c339 Compare April 4, 2024 20:46
client/tailscale/localclient.go Outdated Show resolved Hide resolved
client/tailscale/localclient.go Outdated Show resolved Hide resolved
ipn/localapi/localapi.go Outdated Show resolved Hide resolved
ipn/localapi/localapi.go Show resolved Hide resolved
cmd/tailscale/cli/exitnode.go Outdated Show resolved Hide resolved
ipn/ipnlocal/local.go Outdated Show resolved Hide resolved
ipn/ipnlocal/local.go Outdated Show resolved Hide resolved
ipn/ipnlocal/local.go Show resolved Hide resolved
ipn/ipnlocal/local_test.go Show resolved Hide resolved
ipn/ipnlocal/local_test.go Show resolved Hide resolved
@clairew clairew force-pushed the clairew/cli-suggest-exit-node branch from f43cd1a to c148cb5 Compare April 5, 2024 23:20
@clairew clairew requested a review from sailorfrag April 5, 2024 23:23
@clairew clairew force-pushed the clairew/cli-suggest-exit-node branch 2 times, most recently from a1fe08c to a928645 Compare April 5, 2024 23:46
@clairew clairew force-pushed the clairew/cli-suggest-exit-node branch from bb28358 to 75a6355 Compare April 9, 2024 14:56
Copy link
Member

@sailorfrag sailorfrag left a comment

Choose a reason for hiding this comment

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

Okay, some minor additional things and you're good.

Also it looks like the new CLI subcommand is failing tests because it's missing some documentation?

I think you'll need to wait a couple days to merge until the release is cut.

ipn/ipnlocal/local.go Outdated Show resolved Hide resolved
ipn/ipnlocal/local.go Outdated Show resolved Hide resolved
ipn/ipnlocal/local.go Show resolved Hide resolved
ipn/ipnlocal/local.go Outdated Show resolved Hide resolved
ipn/ipnlocal/local.go Show resolved Hide resolved
ipn/ipnlocal/local.go Outdated Show resolved Hide resolved
ipn/ipnlocal/local.go Outdated Show resolved Hide resolved
ipn/ipnlocal/local.go Outdated Show resolved Hide resolved
@clairew clairew force-pushed the clairew/cli-suggest-exit-node branch 5 times, most recently from 467671f to fc74857 Compare April 10, 2024 18:23
ipn/ipnlocal/local_test.go Outdated Show resolved Hide resolved
ipn/ipnlocal/local_test.go Outdated Show resolved Hide resolved
ipn/ipnlocal/local_test.go Outdated Show resolved Hide resolved
ipn/ipnlocal/local.go Outdated Show resolved Hide resolved
ipn/ipnlocal/local.go Outdated Show resolved Hide resolved
@bradfitz bradfitz changed the title Add suggest exit node cli cmd/tailscale, ipn/ipnlocal: add suggest exit node CLI option Apr 11, 2024
@clairew clairew force-pushed the clairew/cli-suggest-exit-node branch 3 times, most recently from da97feb to 1b625cb Compare April 11, 2024 17:42
@clairew clairew requested a review from sailorfrag April 11, 2024 18:04
@clairew clairew force-pushed the clairew/cli-suggest-exit-node branch 3 times, most recently from 3868392 to d6bb151 Compare April 15, 2024 13:46
Copy link
Member

@sailorfrag sailorfrag left a comment

Choose a reason for hiding this comment

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

Should be good to go after these small things.

client/tailscale/apitype/apitype.go Outdated Show resolved Hide resolved
client/tailscale/localclient.go Outdated Show resolved Hide resolved
ipn/ipnlocal/local.go Outdated Show resolved Hide resolved
ipn/ipnlocal/local.go Show resolved Hide resolved
@clairew clairew force-pushed the clairew/cli-suggest-exit-node branch 3 times, most recently from 1f83685 to 6f542f5 Compare April 15, 2024 16:21
ipn/ipnlocal/local.go Outdated Show resolved Hide resolved
Updates tailscale/corp#17516

Signed-off-by: Claire Wang <claire@tailscale.com>
@clairew clairew force-pushed the clairew/cli-suggest-exit-node branch from 6f542f5 to e59431f Compare April 15, 2024 19:41
@clairew clairew merged commit 9171b21 into main Apr 15, 2024
48 checks passed
@clairew clairew deleted the clairew/cli-suggest-exit-node branch April 15, 2024 22:14
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.

None yet

6 participants