mirror of
https://github.com/coder/coder.git
synced 2025-07-18 14:17:22 +00:00
chore: add protobuf types for tailnet telemetry (#13617)
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@ -3,7 +3,10 @@ option go_package = "github.com/coder/coder/v2/tailnet/proto";
|
|||||||
|
|
||||||
package coder.tailnet.v2;
|
package coder.tailnet.v2;
|
||||||
|
|
||||||
import "google/protobuf/timestamp.proto";
|
import "google/protobuf/timestamp.proto"; // Importing for time.Time
|
||||||
|
import "google/protobuf/duration.proto"; // Importing for time.Duration
|
||||||
|
import "google/protobuf/wrappers.proto"; // Importing for nullable types
|
||||||
|
|
||||||
|
|
||||||
message DERPMap {
|
message DERPMap {
|
||||||
message HomeParams {
|
message HomeParams {
|
||||||
@ -99,7 +102,96 @@ message CoordinateResponse {
|
|||||||
string error = 2;
|
string error = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message Netcheck {
|
||||||
|
bool UDP = 1;
|
||||||
|
bool IPv6 = 2;
|
||||||
|
bool IPv4 = 3;
|
||||||
|
bool IPv6CanSend = 4;
|
||||||
|
bool IPv4CanSend = 5;
|
||||||
|
bool OSHasIPv6 = 6;
|
||||||
|
bool ICMPv4 = 7;
|
||||||
|
|
||||||
|
google.protobuf.BoolValue MappingVariesByDestIP = 8;
|
||||||
|
google.protobuf.BoolValue HairPinning = 9;
|
||||||
|
google.protobuf.BoolValue UPnP = 10;
|
||||||
|
google.protobuf.BoolValue PMP = 11;
|
||||||
|
google.protobuf.BoolValue PCP = 12;
|
||||||
|
|
||||||
|
int64 PreferredDERP = 13; // 0 for unknown
|
||||||
|
|
||||||
|
map<int64, google.protobuf.Duration> RegionLatency = 14;
|
||||||
|
map<int64, google.protobuf.Duration> RegionV4Latency = 15;
|
||||||
|
map<int64, google.protobuf.Duration> RegionV6Latency = 16;
|
||||||
|
|
||||||
|
string GlobalV4 = 17;
|
||||||
|
string GlobalV6 = 18;
|
||||||
|
|
||||||
|
google.protobuf.BoolValue CaptivePortal = 19;
|
||||||
|
}
|
||||||
|
|
||||||
|
message TelemetryEvent {
|
||||||
|
enum Status {
|
||||||
|
CONNECTED = 0;
|
||||||
|
DISCONNECTED = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
enum ClientType {
|
||||||
|
CLI = 0;
|
||||||
|
AGENT = 1;
|
||||||
|
CODERD = 2;
|
||||||
|
WSPROXY = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
enum IPClass {
|
||||||
|
PUBLIC = 0;
|
||||||
|
PRIVATE = 1;
|
||||||
|
LINK_LOCAL = 2;
|
||||||
|
UNIQUE_LOCAL = 3;
|
||||||
|
LOOPBACK = 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
message IPFields {
|
||||||
|
int32 version = 1;
|
||||||
|
IPClass class = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message P2PEndpoint {
|
||||||
|
string hash = 1;
|
||||||
|
int32 port = 2;
|
||||||
|
IPFields fields = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
bytes id = 1;
|
||||||
|
google.protobuf.Timestamp time = 2;
|
||||||
|
string application = 3;
|
||||||
|
Status status = 4;
|
||||||
|
string disconnection_reason = 5;
|
||||||
|
ClientType client_type = 6;
|
||||||
|
string node_id_self = 7;
|
||||||
|
string node_id_remote = 8;
|
||||||
|
P2PEndpoint p2p_endpoint = 9;
|
||||||
|
map<string, IPFields> log_ip_hashes = 10;
|
||||||
|
string home_derp = 11;
|
||||||
|
repeated string logs = 12;
|
||||||
|
DERPMap derp_map = 13;
|
||||||
|
Netcheck latest_netcheck = 14;
|
||||||
|
|
||||||
|
google.protobuf.Duration connection_age = 15;
|
||||||
|
google.protobuf.Duration connection_setup = 16;
|
||||||
|
google.protobuf.Duration p2p_setup = 17;
|
||||||
|
google.protobuf.Duration derp_latency = 18;
|
||||||
|
google.protobuf.Duration p2p_latency = 19;
|
||||||
|
google.protobuf.FloatValue throughput_mbits = 20;
|
||||||
|
}
|
||||||
|
|
||||||
|
message TelemetryRequest {
|
||||||
|
repeated TelemetryEvent events = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message TelemetryResponse {}
|
||||||
|
|
||||||
service Tailnet {
|
service Tailnet {
|
||||||
|
rpc PostTelemetry(TelemetryRequest) returns (TelemetryResponse);
|
||||||
rpc StreamDERPMaps(StreamDERPMapsRequest) returns (stream DERPMap);
|
rpc StreamDERPMaps(StreamDERPMapsRequest) returns (stream DERPMap);
|
||||||
rpc Coordinate(stream CoordinateRequest) returns (stream CoordinateResponse);
|
rpc Coordinate(stream CoordinateRequest) returns (stream CoordinateResponse);
|
||||||
}
|
}
|
||||||
|
@ -38,6 +38,7 @@ func (drpcEncoding_File_tailnet_proto_tailnet_proto) JSONUnmarshal(buf []byte, m
|
|||||||
type DRPCTailnetClient interface {
|
type DRPCTailnetClient interface {
|
||||||
DRPCConn() drpc.Conn
|
DRPCConn() drpc.Conn
|
||||||
|
|
||||||
|
PostTelemetry(ctx context.Context, in *TelemetryRequest) (*TelemetryResponse, error)
|
||||||
StreamDERPMaps(ctx context.Context, in *StreamDERPMapsRequest) (DRPCTailnet_StreamDERPMapsClient, error)
|
StreamDERPMaps(ctx context.Context, in *StreamDERPMapsRequest) (DRPCTailnet_StreamDERPMapsClient, error)
|
||||||
Coordinate(ctx context.Context) (DRPCTailnet_CoordinateClient, error)
|
Coordinate(ctx context.Context) (DRPCTailnet_CoordinateClient, error)
|
||||||
}
|
}
|
||||||
@ -52,6 +53,15 @@ func NewDRPCTailnetClient(cc drpc.Conn) DRPCTailnetClient {
|
|||||||
|
|
||||||
func (c *drpcTailnetClient) DRPCConn() drpc.Conn { return c.cc }
|
func (c *drpcTailnetClient) DRPCConn() drpc.Conn { return c.cc }
|
||||||
|
|
||||||
|
func (c *drpcTailnetClient) PostTelemetry(ctx context.Context, in *TelemetryRequest) (*TelemetryResponse, error) {
|
||||||
|
out := new(TelemetryResponse)
|
||||||
|
err := c.cc.Invoke(ctx, "/coder.tailnet.v2.Tailnet/PostTelemetry", drpcEncoding_File_tailnet_proto_tailnet_proto{}, in, out)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (c *drpcTailnetClient) StreamDERPMaps(ctx context.Context, in *StreamDERPMapsRequest) (DRPCTailnet_StreamDERPMapsClient, error) {
|
func (c *drpcTailnetClient) StreamDERPMaps(ctx context.Context, in *StreamDERPMapsRequest) (DRPCTailnet_StreamDERPMapsClient, error) {
|
||||||
stream, err := c.cc.NewStream(ctx, "/coder.tailnet.v2.Tailnet/StreamDERPMaps", drpcEncoding_File_tailnet_proto_tailnet_proto{})
|
stream, err := c.cc.NewStream(ctx, "/coder.tailnet.v2.Tailnet/StreamDERPMaps", drpcEncoding_File_tailnet_proto_tailnet_proto{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -132,12 +142,17 @@ func (x *drpcTailnet_CoordinateClient) RecvMsg(m *CoordinateResponse) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type DRPCTailnetServer interface {
|
type DRPCTailnetServer interface {
|
||||||
|
PostTelemetry(context.Context, *TelemetryRequest) (*TelemetryResponse, error)
|
||||||
StreamDERPMaps(*StreamDERPMapsRequest, DRPCTailnet_StreamDERPMapsStream) error
|
StreamDERPMaps(*StreamDERPMapsRequest, DRPCTailnet_StreamDERPMapsStream) error
|
||||||
Coordinate(DRPCTailnet_CoordinateStream) error
|
Coordinate(DRPCTailnet_CoordinateStream) error
|
||||||
}
|
}
|
||||||
|
|
||||||
type DRPCTailnetUnimplementedServer struct{}
|
type DRPCTailnetUnimplementedServer struct{}
|
||||||
|
|
||||||
|
func (s *DRPCTailnetUnimplementedServer) PostTelemetry(context.Context, *TelemetryRequest) (*TelemetryResponse, error) {
|
||||||
|
return nil, drpcerr.WithCode(errors.New("Unimplemented"), drpcerr.Unimplemented)
|
||||||
|
}
|
||||||
|
|
||||||
func (s *DRPCTailnetUnimplementedServer) StreamDERPMaps(*StreamDERPMapsRequest, DRPCTailnet_StreamDERPMapsStream) error {
|
func (s *DRPCTailnetUnimplementedServer) StreamDERPMaps(*StreamDERPMapsRequest, DRPCTailnet_StreamDERPMapsStream) error {
|
||||||
return drpcerr.WithCode(errors.New("Unimplemented"), drpcerr.Unimplemented)
|
return drpcerr.WithCode(errors.New("Unimplemented"), drpcerr.Unimplemented)
|
||||||
}
|
}
|
||||||
@ -148,11 +163,20 @@ func (s *DRPCTailnetUnimplementedServer) Coordinate(DRPCTailnet_CoordinateStream
|
|||||||
|
|
||||||
type DRPCTailnetDescription struct{}
|
type DRPCTailnetDescription struct{}
|
||||||
|
|
||||||
func (DRPCTailnetDescription) NumMethods() int { return 2 }
|
func (DRPCTailnetDescription) NumMethods() int { return 3 }
|
||||||
|
|
||||||
func (DRPCTailnetDescription) Method(n int) (string, drpc.Encoding, drpc.Receiver, interface{}, bool) {
|
func (DRPCTailnetDescription) Method(n int) (string, drpc.Encoding, drpc.Receiver, interface{}, bool) {
|
||||||
switch n {
|
switch n {
|
||||||
case 0:
|
case 0:
|
||||||
|
return "/coder.tailnet.v2.Tailnet/PostTelemetry", drpcEncoding_File_tailnet_proto_tailnet_proto{},
|
||||||
|
func(srv interface{}, ctx context.Context, in1, in2 interface{}) (drpc.Message, error) {
|
||||||
|
return srv.(DRPCTailnetServer).
|
||||||
|
PostTelemetry(
|
||||||
|
ctx,
|
||||||
|
in1.(*TelemetryRequest),
|
||||||
|
)
|
||||||
|
}, DRPCTailnetServer.PostTelemetry, true
|
||||||
|
case 1:
|
||||||
return "/coder.tailnet.v2.Tailnet/StreamDERPMaps", drpcEncoding_File_tailnet_proto_tailnet_proto{},
|
return "/coder.tailnet.v2.Tailnet/StreamDERPMaps", drpcEncoding_File_tailnet_proto_tailnet_proto{},
|
||||||
func(srv interface{}, ctx context.Context, in1, in2 interface{}) (drpc.Message, error) {
|
func(srv interface{}, ctx context.Context, in1, in2 interface{}) (drpc.Message, error) {
|
||||||
return nil, srv.(DRPCTailnetServer).
|
return nil, srv.(DRPCTailnetServer).
|
||||||
@ -161,7 +185,7 @@ func (DRPCTailnetDescription) Method(n int) (string, drpc.Encoding, drpc.Receive
|
|||||||
&drpcTailnet_StreamDERPMapsStream{in2.(drpc.Stream)},
|
&drpcTailnet_StreamDERPMapsStream{in2.(drpc.Stream)},
|
||||||
)
|
)
|
||||||
}, DRPCTailnetServer.StreamDERPMaps, true
|
}, DRPCTailnetServer.StreamDERPMaps, true
|
||||||
case 1:
|
case 2:
|
||||||
return "/coder.tailnet.v2.Tailnet/Coordinate", drpcEncoding_File_tailnet_proto_tailnet_proto{},
|
return "/coder.tailnet.v2.Tailnet/Coordinate", drpcEncoding_File_tailnet_proto_tailnet_proto{},
|
||||||
func(srv interface{}, ctx context.Context, in1, in2 interface{}) (drpc.Message, error) {
|
func(srv interface{}, ctx context.Context, in1, in2 interface{}) (drpc.Message, error) {
|
||||||
return nil, srv.(DRPCTailnetServer).
|
return nil, srv.(DRPCTailnetServer).
|
||||||
@ -178,6 +202,22 @@ func DRPCRegisterTailnet(mux drpc.Mux, impl DRPCTailnetServer) error {
|
|||||||
return mux.Register(impl, DRPCTailnetDescription{})
|
return mux.Register(impl, DRPCTailnetDescription{})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type DRPCTailnet_PostTelemetryStream interface {
|
||||||
|
drpc.Stream
|
||||||
|
SendAndClose(*TelemetryResponse) error
|
||||||
|
}
|
||||||
|
|
||||||
|
type drpcTailnet_PostTelemetryStream struct {
|
||||||
|
drpc.Stream
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *drpcTailnet_PostTelemetryStream) SendAndClose(m *TelemetryResponse) error {
|
||||||
|
if err := x.MsgSend(m, drpcEncoding_File_tailnet_proto_tailnet_proto{}); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return x.CloseSend()
|
||||||
|
}
|
||||||
|
|
||||||
type DRPCTailnet_StreamDERPMapsStream interface {
|
type DRPCTailnet_StreamDERPMapsStream interface {
|
||||||
drpc.Stream
|
drpc.Stream
|
||||||
Send(*DERPMap) error
|
Send(*DERPMap) error
|
||||||
|
@ -6,7 +6,7 @@ import (
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
CurrentMajor = 2
|
CurrentMajor = 2
|
||||||
CurrentMinor = 1
|
CurrentMinor = 2
|
||||||
)
|
)
|
||||||
|
|
||||||
var CurrentVersion = apiversion.New(CurrentMajor, CurrentMinor).WithBackwardCompat(1)
|
var CurrentVersion = apiversion.New(CurrentMajor, CurrentMinor).WithBackwardCompat(1)
|
||||||
|
@ -9,6 +9,7 @@ import (
|
|||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/hashicorp/yamux"
|
"github.com/hashicorp/yamux"
|
||||||
|
"storj.io/drpc/drpcerr"
|
||||||
"storj.io/drpc/drpcmux"
|
"storj.io/drpc/drpcmux"
|
||||||
"storj.io/drpc/drpcserver"
|
"storj.io/drpc/drpcserver"
|
||||||
"tailscale.com/tailcfg"
|
"tailscale.com/tailcfg"
|
||||||
@ -123,6 +124,10 @@ type DRPCService struct {
|
|||||||
DerpMapFn func() *tailcfg.DERPMap
|
DerpMapFn func() *tailcfg.DERPMap
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (*DRPCService) PostTelemetry(context.Context, *proto.TelemetryRequest) (*proto.TelemetryResponse, error) {
|
||||||
|
return nil, drpcerr.WithCode(xerrors.New("Unimplemented"), drpcerr.Unimplemented)
|
||||||
|
}
|
||||||
|
|
||||||
func (s *DRPCService) StreamDERPMaps(_ *proto.StreamDERPMapsRequest, stream proto.DRPCTailnet_StreamDERPMapsStream) error {
|
func (s *DRPCService) StreamDERPMaps(_ *proto.StreamDERPMapsRequest, stream proto.DRPCTailnet_StreamDERPMapsStream) error {
|
||||||
defer stream.Close()
|
defer stream.Close()
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user