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 <andrew@tailscale.com>
andrew/net-tsaddr-mapviaaddr
Andrew Dunham 2 years ago committed by Andrew Dunham
parent cba1312dab
commit e85613aa2d

@ -85,6 +85,11 @@ func TestNoContent(t *testing.T) {
input: "input", input: "input",
want: "response input", want: "response input",
}, },
{
name: "valid challenge hostname",
input: "ts_derp99b.tailscale.com",
want: "response ts_derp99b.tailscale.com",
},
{ {
name: "invalid challenge", name: "invalid challenge",
input: "foo\x00bar", input: "foo\x00bar",

@ -1126,7 +1126,10 @@ func (c *Client) checkCaptivePortal(ctx context.Context, dm *tailcfg.DERPMap, pr
return false, err 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) req.Header.Set("X-Tailscale-Challenge", chal)
r, err := noRedirectClient.Do(req) r, err := noRedirectClient.Do(req)
if err != nil { if err != nil {

Loading…
Cancel
Save