Files
coder/enterprise/tailnet/workspaceproxy.go
T
Spike Curtis d6154c4310 chore: remove tailnet v1 API support (#14641)
Drops support for v1 of the tailnet API, which was the original coordination protocol where we only sent node updates, never marked them lost or disconnected.

v2 of the tailnet API went GA for CLI clients in Coder 2.8.0, so clients older than that would stop working.
2024-09-12 07:56:31 +04:00

48 lines
1.2 KiB
Go

package tailnet
import (
"context"
"net"
"github.com/google/uuid"
"cdr.dev/slog"
"github.com/coder/coder/v2/apiversion"
agpl "github.com/coder/coder/v2/tailnet"
)
type ClientService struct {
*agpl.ClientService
}
// NewClientService returns a ClientService based on the given Coordinator pointer. The pointer is
// loaded on each processed connection.
func NewClientService(options agpl.ClientServiceOptions) (*ClientService, error) {
s, err := agpl.NewClientService(options)
if err != nil {
return nil, err
}
return &ClientService{ClientService: s}, nil
}
func (s *ClientService) ServeMultiAgentClient(ctx context.Context, version string, conn net.Conn, id uuid.UUID) error {
major, _, err := apiversion.Parse(version)
if err != nil {
s.Logger.Warn(ctx, "serve client called with unparsable version", slog.Error(err))
return err
}
switch major {
case 2:
auth := agpl.SingleTailnetCoordinateeAuth{}
streamID := agpl.StreamID{
Name: id.String(),
ID: id,
Auth: auth,
}
return s.ServeConnV2(ctx, conn, streamID)
default:
s.Logger.Warn(ctx, "serve client called with unsupported version", slog.F("version", version))
return agpl.ErrUnsupportedVersion
}
}