mirror of
https://github.com/coder/coder.git
synced 2025-07-12 00:14:10 +00:00
Refactors our DRPC service definitions slightly. In the previous version, I inserted the RPCs from the tailnet proto directly into the Agent service. This makes things hard to deal with because DRPC then generates a new set of methods with new interfaces with the `DRPCAgent_` prefixed. Since you can't have a single method that takes different argument types, we couldn't reuse the implementation of those RFCs without a lot of extra classes and pass-thru methods. Instead, the "right" way to do it is to integrate at the DRPC layer. So, we have two DRPC services available over the Agent websocket, and register them both on the DRPC `mux`. Since the tailnet proto RPC service is now for both clients and agents, I renamed some things to clarify and shorten. This PR also removes the `TailnetAPI` implementation from the `agentapi` package, and the next PR in the stack replaces it with the implementation from the `tailnet` package.
95 lines
1.8 KiB
Protocol Buffer
95 lines
1.8 KiB
Protocol Buffer
syntax = "proto3";
|
|
option go_package = "github.com/coder/coder/v2/tailnet/proto";
|
|
|
|
package coder.tailnet.v2;
|
|
|
|
import "google/protobuf/timestamp.proto";
|
|
|
|
message DERPMap {
|
|
message HomeParams {
|
|
map<int64, double> region_score = 1;
|
|
}
|
|
HomeParams home_params = 1;
|
|
|
|
message Region {
|
|
int64 region_id = 1;
|
|
bool embedded_relay = 2;
|
|
string region_code = 3;
|
|
string region_name = 4;
|
|
bool avoid = 5;
|
|
|
|
message Node {
|
|
string name = 1;
|
|
int64 region_id = 2;
|
|
string host_name = 3;
|
|
string cert_name = 4;
|
|
string ipv4 = 5;
|
|
string ipv6 = 6;
|
|
int32 stun_port = 7;
|
|
bool stun_only = 8;
|
|
int32 derp_port = 9;
|
|
bool insecure_for_tests = 10;
|
|
bool force_http = 11;
|
|
string stun_test_ip = 12;
|
|
bool can_port_80 = 13;
|
|
}
|
|
repeated Node nodes = 6;
|
|
}
|
|
map<int64, Region> regions = 2;
|
|
}
|
|
|
|
message StreamDERPMapsRequest {}
|
|
|
|
// defined in tailnet/coordinator.go
|
|
message Node {
|
|
int64 id = 1;
|
|
google.protobuf.Timestamp as_of = 2;
|
|
bytes key = 3;
|
|
string disco = 4;
|
|
int32 preferred_derp = 5;
|
|
map<string, double> derp_latency = 6;
|
|
map<int32, string> derp_forced_websocket = 7;
|
|
repeated string addresses = 8;
|
|
repeated string allowed_ips = 9;
|
|
repeated string endpoints = 10;
|
|
}
|
|
|
|
message CoordinateRequest {
|
|
message UpdateSelf {
|
|
Node node = 1;
|
|
}
|
|
UpdateSelf update_self = 1;
|
|
|
|
message Disconnect {}
|
|
Disconnect disconnect = 2;
|
|
|
|
message Tunnel {
|
|
bytes id = 1;
|
|
}
|
|
Tunnel add_tunnel = 3;
|
|
Tunnel remove_tunnel = 4;
|
|
}
|
|
|
|
message CoordinateResponse {
|
|
message PeerUpdate {
|
|
bytes id = 1;
|
|
Node node = 2;
|
|
|
|
enum Kind {
|
|
KIND_UNSPECIFIED = 0;
|
|
NODE = 1;
|
|
DISCONNECTED = 2;
|
|
LOST = 3;
|
|
}
|
|
Kind kind = 3;
|
|
|
|
string reason = 4;
|
|
}
|
|
repeated PeerUpdate peer_updates = 1;
|
|
}
|
|
|
|
service Tailnet {
|
|
rpc StreamDERPMaps(StreamDERPMapsRequest) returns (stream DERPMap);
|
|
rpc Coordinate(stream CoordinateRequest) returns (stream CoordinateResponse);
|
|
}
|