net/netcheck: don't use a space in the captive portal challenge

The derpers don't allow whitespace in the challenge.

Change-Id: I93a8b073b846b87854fba127b5c1d80db205f658
Signed-off-by: Andrew Dunham <[email protected]>
This commit is contained in:
Andrew Dunham authored and Andrew Dunham committed 2022-11-08 16:58:54 -05:00
1 parent cba1312dab
commit e85613aa2d
2 files changed
+9 -1

No files matched your search

+5
View File
@@ -85,6 +85,11 @@ func TestNoContent(t *testing.T) {
input: "input",
want: "response input",
},
{
name: "valid challenge hostname",
input: "ts_derp99b.tailscale.com",
want: "response ts_derp99b.tailscale.com",
},
{
name: "invalid challenge",
input: "foo\x00bar",
+4 -1
View File
@@ -1126,7 +1126,10 @@ func (c *Client) checkCaptivePortal(ctx context.Context, dm *tailcfg.DERPMap, pr
return false, err
}
chal := "tailscale " + node.HostName
// Note: the set of valid characters in a challenge and the total
// length is limited; see isChallengeChar in cmd/derper for more
// details.
chal := "ts_" + node.HostName
req.Header.Set("X-Tailscale-Challenge", chal)
r, err := noRedirectClient.Do(req)
if err != nil {