mirror of
https://github.com/juanfont/headscale.git
synced 2026-10-10 08:40:07 +09:00
hscontrol: send the logtail instruction on the expired-self frame
It opens a deleted node's stream in place of the initial map.
This commit is contained in:
committed by
Kristoffer Dalby
parent
52a7f8c89c
commit
0c9186d4a3
@@ -742,6 +742,8 @@ func (ns *noiseServer) PollNetMapHandler(
|
||||
KeyExpiry: time.Unix(1, 0).UTC(),
|
||||
Expired: true,
|
||||
},
|
||||
// This frame opens the stream in place of the initial map.
|
||||
Debug: ns.headscale.cfg.TailcfgDebug(),
|
||||
}
|
||||
|
||||
err = writeMapResponse(writer, mapRequest.Compress, true, expired)
|
||||
|
||||
+16
-2
@@ -1158,11 +1158,22 @@ func decodeMapResponse(t *testing.T, compress string, body []byte) tailcfg.MapRe
|
||||
func TestPollNetMapHandler_DeletedNodeGetsExpiredSelf(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
for _, compress := range []string{"", util.ZstdCompression} {
|
||||
t.Run("compress="+compress, func(t *testing.T) {
|
||||
for _, tc := range []struct {
|
||||
compress string
|
||||
logTail bool
|
||||
wantDebug *tailcfg.Debug
|
||||
}{
|
||||
{"", false, &tailcfg.Debug{DisableLogTail: true}},
|
||||
{util.ZstdCompression, false, &tailcfg.Debug{DisableLogTail: true}},
|
||||
{"", true, nil},
|
||||
{util.ZstdCompression, true, nil},
|
||||
} {
|
||||
compress := tc.compress
|
||||
t.Run(fmt.Sprintf("compress=%s/logtail=%t", compress, tc.logTail), func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
app := createTestApp(t)
|
||||
app.cfg.LogTail.Enabled = tc.logTail
|
||||
user := app.state.CreateUserForTest("deleted-node-user")
|
||||
node := putTestNodeInStore(t, app, user, "deleted-node")
|
||||
|
||||
@@ -1190,6 +1201,9 @@ func TestPollNetMapHandler_DeletedNodeGetsExpiredSelf(t *testing.T) {
|
||||
assert.Equal(t, time.Unix(1, 0).UTC(), resp.Node.KeyExpiry,
|
||||
"a fixed ancient KeyExpiry must remain expired despite client clock skew")
|
||||
assert.True(t, resp.Node.Expired)
|
||||
// This frame starts the stream, so it must carry the logtail
|
||||
// instruction the initial map would have.
|
||||
assert.Equal(t, tc.wantDebug, resp.Debug)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user