mirror of
https://github.com/netbirdio/netbird.git
synced 2026-04-18 00:06:38 +00:00
proxy service proto
This commit is contained in:
@@ -150,7 +150,6 @@ func (s *BaseServer) GRPCServer() *grpc.Server {
|
||||
}
|
||||
mgmtProto.RegisterManagementServiceServer(gRPCAPIHandler, srv)
|
||||
|
||||
// Register ProxyService for proxy connections
|
||||
proxyService := nbgrpc.NewProxyServiceServer()
|
||||
mgmtProto.RegisterProxyServiceServer(gRPCAPIHandler, proxyService)
|
||||
log.Info("ProxyService registered on gRPC server")
|
||||
|
||||
1239
shared/management/proto/proxy_service.pb.go
Normal file
1239
shared/management/proto/proxy_service.pb.go
Normal file
File diff suppressed because it is too large
Load Diff
102
shared/management/proto/proxy_service.proto
Normal file
102
shared/management/proto/proxy_service.proto
Normal file
@@ -0,0 +1,102 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package management;
|
||||
|
||||
option go_package = "/proto";
|
||||
|
||||
import "google/protobuf/timestamp.proto";
|
||||
|
||||
// ProxyService - Management is the SERVER, Proxy is the CLIENT
|
||||
// Proxy initiates connection to management
|
||||
service ProxyService {
|
||||
// Bidirectional stream for proxy-management communication
|
||||
rpc Stream(stream ProxyMessage) returns (stream ManagementMessage);
|
||||
}
|
||||
|
||||
// Messages FROM Proxy TO Management
|
||||
message ProxyMessage {
|
||||
oneof payload {
|
||||
ProxyHello hello = 1; // First message on connect
|
||||
ProxyRequestData request_data = 2; // Real-time access logs
|
||||
}
|
||||
}
|
||||
|
||||
// Proxy identification on connect
|
||||
message ProxyHello {
|
||||
string proxy_id = 1;
|
||||
string version = 2;
|
||||
google.protobuf.Timestamp started_at = 3;
|
||||
}
|
||||
|
||||
// Access log from proxy to management
|
||||
message ProxyRequestData {
|
||||
google.protobuf.Timestamp timestamp = 1;
|
||||
string service_id = 2;
|
||||
string host = 3;
|
||||
string path = 4;
|
||||
int64 duration_ms = 5;
|
||||
string method = 6;
|
||||
int32 response_code = 7;
|
||||
string source_ip = 8;
|
||||
string auth_mechanism = 9;
|
||||
string user_id = 10;
|
||||
bool auth_success = 11;
|
||||
}
|
||||
|
||||
// Messages FROM Management TO Proxy
|
||||
message ManagementMessage {
|
||||
oneof payload {
|
||||
ServicesSnapshot snapshot = 1; // Full snapshot on initial connect
|
||||
ServiceUpdate update = 2; // Incremental service update
|
||||
}
|
||||
}
|
||||
|
||||
// Full snapshot of all services for this proxy
|
||||
message ServicesSnapshot {
|
||||
repeated ExposedServiceConfig services = 1;
|
||||
google.protobuf.Timestamp timestamp = 2;
|
||||
}
|
||||
|
||||
// Incremental service update
|
||||
message ServiceUpdate {
|
||||
enum UpdateType {
|
||||
CREATED = 0;
|
||||
UPDATED = 1;
|
||||
REMOVED = 2;
|
||||
}
|
||||
UpdateType type = 1;
|
||||
ExposedServiceConfig service = 2; // Set for CREATED and UPDATED
|
||||
string service_id = 3; // Service ID (always set)
|
||||
}
|
||||
|
||||
// Exposed service configuration
|
||||
message ExposedServiceConfig {
|
||||
string id = 1;
|
||||
string domain = 2;
|
||||
map<string, string> path_mappings = 3; // path -> target
|
||||
string setup_key = 4;
|
||||
AuthConfig auth = 5;
|
||||
}
|
||||
|
||||
// Authentication configuration
|
||||
message AuthConfig {
|
||||
oneof auth_type {
|
||||
BasicAuthConfig basic_auth = 1;
|
||||
PinAuthConfig pin_auth = 2;
|
||||
BearerAuthConfig bearer_auth = 3;
|
||||
}
|
||||
}
|
||||
|
||||
message BasicAuthConfig {
|
||||
string username = 1;
|
||||
string password = 2;
|
||||
}
|
||||
|
||||
message PinAuthConfig {
|
||||
string pin = 1;
|
||||
string header = 2;
|
||||
}
|
||||
|
||||
message BearerAuthConfig {
|
||||
bool enabled = 1;
|
||||
}
|
||||
135
shared/management/proto/proxy_service_grpc.pb.go
Normal file
135
shared/management/proto/proxy_service_grpc.pb.go
Normal file
@@ -0,0 +1,135 @@
|
||||
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
||||
|
||||
package proto
|
||||
|
||||
import (
|
||||
context "context"
|
||||
grpc "google.golang.org/grpc"
|
||||
codes "google.golang.org/grpc/codes"
|
||||
status "google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the grpc package it is being compiled against.
|
||||
// Requires gRPC-Go v1.32.0 or later.
|
||||
const _ = grpc.SupportPackageIsVersion7
|
||||
|
||||
// ProxyServiceClient is the client API for ProxyService service.
|
||||
//
|
||||
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
|
||||
type ProxyServiceClient interface {
|
||||
// Bidirectional stream for proxy-management communication
|
||||
Stream(ctx context.Context, opts ...grpc.CallOption) (ProxyService_StreamClient, error)
|
||||
}
|
||||
|
||||
type proxyServiceClient struct {
|
||||
cc grpc.ClientConnInterface
|
||||
}
|
||||
|
||||
func NewProxyServiceClient(cc grpc.ClientConnInterface) ProxyServiceClient {
|
||||
return &proxyServiceClient{cc}
|
||||
}
|
||||
|
||||
func (c *proxyServiceClient) Stream(ctx context.Context, opts ...grpc.CallOption) (ProxyService_StreamClient, error) {
|
||||
stream, err := c.cc.NewStream(ctx, &ProxyService_ServiceDesc.Streams[0], "/management.ProxyService/Stream", opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
x := &proxyServiceStreamClient{stream}
|
||||
return x, nil
|
||||
}
|
||||
|
||||
type ProxyService_StreamClient interface {
|
||||
Send(*ProxyMessage) error
|
||||
Recv() (*ManagementMessage, error)
|
||||
grpc.ClientStream
|
||||
}
|
||||
|
||||
type proxyServiceStreamClient struct {
|
||||
grpc.ClientStream
|
||||
}
|
||||
|
||||
func (x *proxyServiceStreamClient) Send(m *ProxyMessage) error {
|
||||
return x.ClientStream.SendMsg(m)
|
||||
}
|
||||
|
||||
func (x *proxyServiceStreamClient) Recv() (*ManagementMessage, error) {
|
||||
m := new(ManagementMessage)
|
||||
if err := x.ClientStream.RecvMsg(m); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// ProxyServiceServer is the server API for ProxyService service.
|
||||
// All implementations must embed UnimplementedProxyServiceServer
|
||||
// for forward compatibility
|
||||
type ProxyServiceServer interface {
|
||||
// Bidirectional stream for proxy-management communication
|
||||
Stream(ProxyService_StreamServer) error
|
||||
mustEmbedUnimplementedProxyServiceServer()
|
||||
}
|
||||
|
||||
// UnimplementedProxyServiceServer must be embedded to have forward compatible implementations.
|
||||
type UnimplementedProxyServiceServer struct {
|
||||
}
|
||||
|
||||
func (UnimplementedProxyServiceServer) Stream(ProxyService_StreamServer) error {
|
||||
return status.Errorf(codes.Unimplemented, "method Stream not implemented")
|
||||
}
|
||||
func (UnimplementedProxyServiceServer) mustEmbedUnimplementedProxyServiceServer() {}
|
||||
|
||||
// UnsafeProxyServiceServer may be embedded to opt out of forward compatibility for this service.
|
||||
// Use of this interface is not recommended, as added methods to ProxyServiceServer will
|
||||
// result in compilation errors.
|
||||
type UnsafeProxyServiceServer interface {
|
||||
mustEmbedUnimplementedProxyServiceServer()
|
||||
}
|
||||
|
||||
func RegisterProxyServiceServer(s grpc.ServiceRegistrar, srv ProxyServiceServer) {
|
||||
s.RegisterService(&ProxyService_ServiceDesc, srv)
|
||||
}
|
||||
|
||||
func _ProxyService_Stream_Handler(srv interface{}, stream grpc.ServerStream) error {
|
||||
return srv.(ProxyServiceServer).Stream(&proxyServiceStreamServer{stream})
|
||||
}
|
||||
|
||||
type ProxyService_StreamServer interface {
|
||||
Send(*ManagementMessage) error
|
||||
Recv() (*ProxyMessage, error)
|
||||
grpc.ServerStream
|
||||
}
|
||||
|
||||
type proxyServiceStreamServer struct {
|
||||
grpc.ServerStream
|
||||
}
|
||||
|
||||
func (x *proxyServiceStreamServer) Send(m *ManagementMessage) error {
|
||||
return x.ServerStream.SendMsg(m)
|
||||
}
|
||||
|
||||
func (x *proxyServiceStreamServer) Recv() (*ProxyMessage, error) {
|
||||
m := new(ProxyMessage)
|
||||
if err := x.ServerStream.RecvMsg(m); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// ProxyService_ServiceDesc is the grpc.ServiceDesc for ProxyService service.
|
||||
// It's only intended for direct use with grpc.RegisterService,
|
||||
// and not to be introspected or modified (even as a copy)
|
||||
var ProxyService_ServiceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "management.ProxyService",
|
||||
HandlerType: (*ProxyServiceServer)(nil),
|
||||
Methods: []grpc.MethodDesc{},
|
||||
Streams: []grpc.StreamDesc{
|
||||
{
|
||||
StreamName: "Stream",
|
||||
Handler: _ProxyService_Stream_Handler,
|
||||
ServerStreams: true,
|
||||
ClientStreams: true,
|
||||
},
|
||||
},
|
||||
Metadata: "proxy_service.proto",
|
||||
}
|
||||
Reference in New Issue
Block a user