Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions vpn/tunnel.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"net/netip"
"net/url"
"reflect"
"sort"
"strconv"
"sync"
"time"
Expand Down Expand Up @@ -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.

})
out.DeletedAgents[i] = &Agent{
Id: tailnet.UUIDToByteSlice(agent.ID),
Name: agent.Name,
Expand All @@ -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,
Expand Down
Loading