mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
feat: add tailnet to agent RPC service (#11304)
Adds tailnet.DRPCService to the agent API Supports #10531 but we still need to add version negotiation to the websocket endpoint
This commit is contained in:
@@ -3,6 +3,7 @@ package coderd
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"runtime/pprof"
|
||||
"sync/atomic"
|
||||
@@ -22,6 +23,7 @@ import (
|
||||
"github.com/coder/coder/v2/coderd/httpmw"
|
||||
"github.com/coder/coder/v2/coderd/util/ptr"
|
||||
"github.com/coder/coder/v2/codersdk"
|
||||
"github.com/coder/coder/v2/tailnet"
|
||||
)
|
||||
|
||||
// @Summary Workspace agent RPC API
|
||||
@@ -128,6 +130,13 @@ func (api *API) workspaceAgentRPC(rw http.ResponseWriter, r *http.Request) {
|
||||
UpdateAgentMetricsFn: api.UpdateAgentMetrics,
|
||||
})
|
||||
|
||||
streamID := tailnet.StreamID{
|
||||
Name: fmt.Sprintf("%s-%s-%s", owner.Username, workspace.Name, workspaceAgent.Name),
|
||||
ID: workspaceAgent.ID,
|
||||
Auth: tailnet.AgentTunnelAuth{},
|
||||
}
|
||||
ctx = tailnet.WithStreamID(ctx, streamID)
|
||||
|
||||
closeCtx, closeCtxCancel := context.WithCancel(ctx)
|
||||
go func() {
|
||||
defer closeCtxCancel()
|
||||
|
||||
Reference in New Issue
Block a user