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

fix(wsconncache): only allow one peer per connection#5886

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
bpmct merged 1 commit intomainfromcolin/wsconncache-fix
Jan 26, 2023
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletionscoderd/workspaceagents.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -402,11 +402,6 @@ func (api *API) workspaceAgentListeningPorts(rw http.ResponseWriter, r *http.Req

func (api*API)dialWorkspaceAgentTailnet(r*http.Request,agentID uuid.UUID) (*codersdk.AgentConn,error) {
clientConn,serverConn:=net.Pipe()
gofunc() {
<-r.Context().Done()
_=clientConn.Close()
_=serverConn.Close()
}()

derpMap:=api.DERPMap.Clone()
for_,region:=rangederpMap.Regions {
Expand DownExpand Up@@ -453,7 +448,16 @@ func (api *API) dialWorkspaceAgentTailnet(r *http.Request, agentID uuid.UUID) (*
}

sendNodes,_:=tailnet.ServeCoordinator(clientConn,func(node []*tailnet.Node)error {
returnconn.UpdateNodes(node)
err:=conn.RemoveAllPeers()
iferr!=nil {
returnxerrors.Errorf("remove all peers: %w",err)
}

err=conn.UpdateNodes(node)
iferr!=nil {
returnxerrors.Errorf("update nodes: %w",err)
}
returnnil
})
conn.SetNodeCallback(sendNodes)
gofunc() {
Expand All@@ -465,6 +469,10 @@ func (api *API) dialWorkspaceAgentTailnet(r *http.Request, agentID uuid.UUID) (*
}()
return&codersdk.AgentConn{
Conn:conn,
CloseFunc:func() {
_=clientConn.Close()
_=serverConn.Close()
},
},nil
}

Expand Down
25 changes: 25 additions & 0 deletionstailnet/conn.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -325,6 +325,31 @@ func (c *Conn) SetDERPMap(derpMap *tailcfg.DERPMap) {
c.wireguardEngine.SetDERPMap(derpMap)
}

func (c*Conn)RemoveAllPeers()error {
c.mutex.Lock()
deferc.mutex.Unlock()

c.netMap.Peers= []*tailcfg.Node{}
c.peerMap=map[tailcfg.NodeID]*tailcfg.Node{}
netMapCopy:=*c.netMap
c.wireguardEngine.SetNetworkMap(&netMapCopy)
cfg,err:=nmcfg.WGCfg(c.netMap,Logger(c.logger.Named("wgconfig")),netmap.AllowSingleHosts,"")
iferr!=nil {
returnxerrors.Errorf("update wireguard config: %w",err)
}
err=c.wireguardEngine.Reconfig(cfg,c.wireguardRouter,&dns.Config{},&tailcfg.Debug{})
iferr!=nil {
ifc.isClosed() {
returnnil
}
iferrors.Is(err,wgengine.ErrNoChanges) {
returnnil
}
returnxerrors.Errorf("reconfig: %w",err)
}
returnnil
}

// UpdateNodes connects with a set of peers. This can be constantly updated,
// and peers will continually be reconnected as necessary.
func (c*Conn)UpdateNodes(nodes []*Node)error {
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp