[PR #2383] [MERGED] stricter hostname validation and replace #2636

Closed
opened 2025-12-29 03:22:09 +01:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/juanfont/headscale/pull/2383
Author: @kradalby
Created: 1/27/2025
Status: Merged
Merged: 10/22/2025
Merged by: @kradalby

Base: mainHead: kradalby/validate-hostname


📝 Commits (3)

📊 Changes

16 files changed (+888 additions, -193 deletions)

View changed files

📝 CHANGELOG.md (+14 -0)
📝 CLAUDE.md (+1 -0)
📝 hscontrol/auth.go (+14 -6)
📝 hscontrol/db/node.go (+22 -1)
📝 hscontrol/db/node_test.go (+178 -5)
📝 hscontrol/db/users.go (+2 -4)
📝 hscontrol/state/state.go (+13 -6)
📝 hscontrol/types/node.go (+25 -5)
📝 hscontrol/types/node_test.go (+240 -2)
📝 hscontrol/util/dns.go (+57 -13)
📝 hscontrol/util/dns_test.go (+115 -35)
📝 hscontrol/util/string.go (+5 -0)
📝 hscontrol/util/util.go (+22 -43)
📝 hscontrol/util/util_test.go (+165 -63)
📝 integration/cli_test.go (+6 -6)
📝 integration/general_test.go (+9 -4)

📄 Description

fixes https://github.com/juanfont/headscale/issues/2762

  Client Registration (New Nodes)

  'my-laptop'       → 'my-laptop'        ✓ Valid, accepted as-is
  'My-Laptop'       → 'my-laptop'        ✓ Uppercase → lowercase
  'my_laptop'       → 'invalid-a1b2c3'   ✗ Contains underscore
  'test@host'       → 'invalid-d4e5f6'   ✗ Contains @
  'server-北京-01'  → 'invalid-g7h8i9'   ✗ Contains Chinese chars
  'laptop-🚀'       → 'invalid-j1k2l3'   ✗ Contains emoji
  'very-long-hostname-that-exceeds-sixty-three-characters-and-more'   → 'invalid-m4n5o6'   ✗ Too long (>63 chars)

  Hostinfo Updates (From Tailscale Client) or CLI

  'my-laptop'       → Accepted           ✓ Valid
  'My-Laptop'       → 'my-laptop'        ✓ Lowercased and accepted
  'my_laptop'       → Rejected            ✗ "invalid characters"
  'test@host'       → Rejected            ✗ "invalid characters"
  'server-北京-01'  → Rejected            ✗ "invalid characters"
  '-test'           → Rejected            ✗ "cannot start or end with a hyphen"
  'a'               → Rejected            ✗ "must be at least 2 characters"

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/juanfont/headscale/pull/2383 **Author:** [@kradalby](https://github.com/kradalby) **Created:** 1/27/2025 **Status:** ✅ Merged **Merged:** 10/22/2025 **Merged by:** [@kradalby](https://github.com/kradalby) **Base:** `main` ← **Head:** `kradalby/validate-hostname` --- ### 📝 Commits (3) - [`d7e7185`](https://github.com/juanfont/headscale/commit/d7e718538eb9e3b8d140a98e91ecbe1d3f911b2e) claude: no gists - [`708cbac`](https://github.com/juanfont/headscale/commit/708cbaca094044984e723c8e6616d975e3945876) stricter hostname validation and replace - [`7712b5e`](https://github.com/juanfont/headscale/commit/7712b5e850fb5cb89d06e944f8389630638b8494) changelog: update ### 📊 Changes **16 files changed** (+888 additions, -193 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+14 -0) 📝 `CLAUDE.md` (+1 -0) 📝 `hscontrol/auth.go` (+14 -6) 📝 `hscontrol/db/node.go` (+22 -1) 📝 `hscontrol/db/node_test.go` (+178 -5) 📝 `hscontrol/db/users.go` (+2 -4) 📝 `hscontrol/state/state.go` (+13 -6) 📝 `hscontrol/types/node.go` (+25 -5) 📝 `hscontrol/types/node_test.go` (+240 -2) 📝 `hscontrol/util/dns.go` (+57 -13) 📝 `hscontrol/util/dns_test.go` (+115 -35) 📝 `hscontrol/util/string.go` (+5 -0) 📝 `hscontrol/util/util.go` (+22 -43) 📝 `hscontrol/util/util_test.go` (+165 -63) 📝 `integration/cli_test.go` (+6 -6) 📝 `integration/general_test.go` (+9 -4) </details> ### 📄 Description fixes https://github.com/juanfont/headscale/issues/2762 ``` Client Registration (New Nodes) 'my-laptop' → 'my-laptop' ✓ Valid, accepted as-is 'My-Laptop' → 'my-laptop' ✓ Uppercase → lowercase 'my_laptop' → 'invalid-a1b2c3' ✗ Contains underscore 'test@host' → 'invalid-d4e5f6' ✗ Contains @ 'server-北京-01' → 'invalid-g7h8i9' ✗ Contains Chinese chars 'laptop-🚀' → 'invalid-j1k2l3' ✗ Contains emoji 'very-long-hostname-that-exceeds-sixty-three-characters-and-more' → 'invalid-m4n5o6' ✗ Too long (>63 chars) Hostinfo Updates (From Tailscale Client) or CLI 'my-laptop' → Accepted ✓ Valid 'My-Laptop' → 'my-laptop' ✓ Lowercased and accepted 'my_laptop' → Rejected ✗ "invalid characters" 'test@host' → Rejected ✗ "invalid characters" 'server-北京-01' → Rejected ✗ "invalid characters" '-test' → Rejected ✗ "cannot start or end with a hyphen" 'a' → Rejected ✗ "must be at least 2 characters" ``` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
adam added the pull-request label 2025-12-29 03:22:09 +01:00
adam closed this issue 2025-12-29 03:22:09 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/headscale#2636