Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf66d81a

Browse files
committed
added the logic to populate the PeerUpdate after updating the internal tunnel state
1 parente95fa44 commitf66d81a

File tree

1 file changed

+32
-10
lines changed

1 file changed

+32
-10
lines changed

‎vpn/tunnel.go

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,38 @@ func (u *updater) sendUpdateResponse(req *request[*TunnelMessage, *ManagerMessag
397397
// createPeerUpdateLocked creates a PeerUpdate message from a workspace update, populating
398398
// the network status of the agents.
399399
func (u*updater)createPeerUpdateLocked(update tailnet.WorkspaceUpdate)*PeerUpdate {
400+
401+
// this flag is true on the first update after a reconnect
402+
ifupdate.FreshState {
403+
// ignoredWorkspaces is initially populated with the workspaces that are
404+
// in the current update. Later on we populate it with the deleted workspaces too
405+
// so that we don't send duplicate updates.
406+
ignoredWorkspaces:=make(map[uuid.UUID]struct{},len(update.UpsertedWorkspaces))
407+
408+
for_,workspace:=rangeupdate.UpsertedWorkspaces {
409+
ignoredWorkspaces[workspace.ID]=struct{}{}
410+
}
411+
for_,agent:=rangeupdate.UpsertedAgents {
412+
// delete any current agents that are not in the new update
413+
if_,ok:=u.agents[agent.ID];!ok {
414+
delete(u.agents,agent.ID)
415+
update.DeletedAgents=append(update.DeletedAgents,&tailnet.Agent{
416+
ID:agent.ID,
417+
Name:agent.Name,
418+
WorkspaceID:agent.WorkspaceID,
419+
})
420+
if_,ok:=ignoredWorkspaces[agent.WorkspaceID];!ok {
421+
update.DeletedWorkspaces=append(update.DeletedWorkspaces,&tailnet.Workspace{
422+
// other fields cannot be populated because the tunnel
423+
// only stores agents and corresponding workspaceIDs
424+
ID:agent.WorkspaceID,
425+
})
426+
ignoredWorkspaces[agent.WorkspaceID]=struct{}{}
427+
}
428+
}
429+
}
430+
}
431+
400432
out:=&PeerUpdate{
401433
UpsertedWorkspaces:make([]*Workspace,len(update.UpsertedWorkspaces)),
402434
UpsertedAgents:make([]*Agent,len(update.UpsertedAgents)),
@@ -413,16 +445,6 @@ func (u *updater) createPeerUpdateLocked(update tailnet.WorkspaceUpdate) *PeerUp
413445
delete(u.agents,agent.ID)
414446
}
415447

416-
// this flag is true on the first update after a reconnect
417-
ifupdate.FreshState {
418-
for_,agent:=rangeupdate.UpsertedAgents {
419-
// delete any current agents that are not in the new update
420-
if_,ok:=u.agents[agent.ID];!ok {
421-
delete(u.agents,agent.ID)
422-
}
423-
}
424-
}
425-
426448
fori,ws:=rangeupdate.UpsertedWorkspaces {
427449
out.UpsertedWorkspaces[i]=&Workspace{
428450
Id:tailnet.UUIDToByteSlice(ws.ID),

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp