Skip to content

chore(vpn/tunnel): sort outgoing fqdns by length #16520

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

Merged
merged 1 commit into from
Feb 11, 2025
Merged

Conversation

ethanndickson
Copy link
Member

@ethanndickson ethanndickson commented Feb 11, 2025

On the Mac app, we want to display the shortest FQDN - we might as well do the sorting as they leave the tunnel.
Right now it's coming from a map, so it's they arrive in a random order each peer update.

Copy link
Member Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@ethanndickson ethanndickson marked this pull request as ready for review February 11, 2025 07:28
@@ -402,6 +403,9 @@ func (u *updater) createPeerUpdateLocked(update tailnet.WorkspaceUpdate) *PeerUp
for name := range agent.Hosts {
fqdn = append(fqdn, name.WithTrailingDot())
}
sort.Slice(fqdn, func(i, j int) bool {
return len(fqdn[i]) < len(fqdn[j])
Copy link
Member

Choose a reason for hiding this comment

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

Wouldn't a better sort be by the amount of periods?

Copy link
Member Author

Choose a reason for hiding this comment

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

Not necessarily? If we have:

dev.wsname.ethan.coder
dev.wsname.me.coder

I'd want the latter to be shown. I guess we could do number of periods AND length?

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually, I don't think it's worth doing that. We want the shortest name because that's what looks the best in the UI. With all the hostnames we set currently, the shortest name is always going to have the least periods. If we ever change that, we can revisit this.

@ethanndickson ethanndickson merged commit 0e728a7 into main Feb 11, 2025
39 checks passed
@ethanndickson ethanndickson deleted the ethan/sort-fqdns branch February 11, 2025 11:36
@github-actions github-actions bot locked and limited conversation to collaborators Feb 11, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants