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
Conversation
04baf65
to
842c64e
Compare
ipn/ipnlocal/local.go
Outdated
// 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 { |
There was a problem hiding this comment.
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?)
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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).
c4dbe66
to
e75a5d5
Compare
6ac0e60
to
8dbc130
Compare
21c6b93
to
7425f20
Compare
There was a problem hiding this 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
7425f20
to
7ef24ac
Compare
a1665c4
to
e8203ca
Compare
7101c9b
to
582c339
Compare
f43cd1a
to
c148cb5
Compare
a1fe08c
to
a928645
Compare
bb28358
to
75a6355
Compare
There was a problem hiding this 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.
467671f
to
fc74857
Compare
da97feb
to
1b625cb
Compare
3868392
to
d6bb151
Compare
There was a problem hiding this 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.
1f83685
to
6f542f5
Compare
Updates tailscale/corp#17516 Signed-off-by: Claire Wang <claire@tailscale.com>
6f542f5
to
e59431f
Compare
Suggest exit node cli