Skip to content

Commit 92870f0

Browse files
fix: force lowercase DNS hostnames for VPN (#16613)
Closes coder/coder-desktop-macos#54 I've also double checked that agents with hyphens & underscores play nice once programmed, as do workspaces with hyphens: ``` $ ping6 main_agent-1.main-workspace.admin.coder PING6(56=40+8+8 bytes) fd60:627a:a42b:4e91:88c0:da4a:df4f:b54e --> fd60:627a:a42b:46d4:8b55:e549:e498:e6f5 ``` also fine in Firefox & Safari, though I'm a little surprised underscores work.
1 parent 186a9b5 commit 92870f0

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

tailnet/controllers.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -883,23 +883,30 @@ type Workspace struct {
883883
}
884884

885885
// updateDNSNames updates the DNS names for all agents in the workspace.
886+
// DNS hosts must be all lowercase, or the resolver won't be able to find them.
887+
// Usernames are globally unique & case-insensitive.
888+
// Workspace names are unique per-user & case-insensitive.
889+
// Agent names are unique per-workspace & case-insensitive.
886890
func (w *Workspace) updateDNSNames() error {
891+
wsName := strings.ToLower(w.Name)
892+
username := strings.ToLower(w.ownerUsername)
887893
for id, a := range w.agents {
894+
agentName := strings.ToLower(a.Name)
888895
names := make(map[dnsname.FQDN][]netip.Addr)
889896
// TODO: technically, DNS labels cannot start with numbers, but the rules are often not
890897
// strictly enforced.
891-
fqdn, err := dnsname.ToFQDN(fmt.Sprintf("%s.%s.me.coder.", a.Name, w.Name))
898+
fqdn, err := dnsname.ToFQDN(fmt.Sprintf("%s.%s.me.coder.", agentName, wsName))
892899
if err != nil {
893900
return err
894901
}
895902
names[fqdn] = []netip.Addr{CoderServicePrefix.AddrFromUUID(a.ID)}
896-
fqdn, err = dnsname.ToFQDN(fmt.Sprintf("%s.%s.%s.coder.", a.Name, w.Name, w.ownerUsername))
903+
fqdn, err = dnsname.ToFQDN(fmt.Sprintf("%s.%s.%s.coder.", agentName, wsName, username))
897904
if err != nil {
898905
return err
899906
}
900907
names[fqdn] = []netip.Addr{CoderServicePrefix.AddrFromUUID(a.ID)}
901908
if len(w.agents) == 1 {
902-
fqdn, err := dnsname.ToFQDN(fmt.Sprintf("%s.coder.", w.Name))
909+
fqdn, err := dnsname.ToFQDN(fmt.Sprintf("%s.coder.", wsName))
903910
if err != nil {
904911
return err
905912
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy