- Notifications
You must be signed in to change notification settings - Fork1k
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -10,6 +10,7 @@ import ( | ||
"net/netip" | ||
"net/url" | ||
"reflect" | ||
"sort" | ||
"strconv" | ||
"sync" | ||
"time" | ||
@@ -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]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Wouldn't a better sort be by the amount of periods? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Not necessarily? If we have:
I'd want the latter to be shown. I guess we could do number of periods AND length? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. | ||
}) | ||
out.DeletedAgents[i] = &Agent{ | ||
Id: tailnet.UUIDToByteSlice(agent.ID), | ||
Name: agent.Name, | ||
@@ -424,6 +428,9 @@ func (u *updater) convertAgentsLocked(agents []*tailnet.Agent) []*Agent { | ||
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]) | ||
}) | ||
protoAgent := &Agent{ | ||
Id: tailnet.UUIDToByteSlice(agent.ID), | ||
Name: agent.Name, | ||
Uh oh!
There was an error while loading.Please reload this page.