diff --git a/management/internals/server/boot.go b/management/internals/server/boot.go index 5d312ef94..626018a41 100644 --- a/management/internals/server/boot.go +++ b/management/internals/server/boot.go @@ -150,6 +150,11 @@ 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") + return gRPCAPIHandler }) } diff --git a/management/internals/shared/grpc/proxy_service.go b/management/internals/shared/grpc/proxy_service.go new file mode 100644 index 000000000..7a7af324f --- /dev/null +++ b/management/internals/shared/grpc/proxy_service.go @@ -0,0 +1,242 @@ +package grpc + +import ( + "context" + "io" + "sync" + + log "github.com/sirupsen/logrus" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/peer" + "google.golang.org/grpc/status" + "google.golang.org/protobuf/types/known/timestamppb" + + "github.com/netbirdio/netbird/shared/management/proto" +) + +// ProxyServiceServer implements the ProxyService gRPC server +type ProxyServiceServer struct { + proto.UnimplementedProxyServiceServer + + // Map of connected proxies: proxy_id -> proxy connection + connectedProxies sync.Map + + // Channel for broadcasting service updates to all proxies + updatesChan chan *proto.ServiceUpdate +} + +// proxyConnection represents a connected proxy +type proxyConnection struct { + proxyID string + stream proto.ProxyService_StreamServer + sendChan chan *proto.ManagementMessage + ctx context.Context + cancel context.CancelFunc + mu sync.RWMutex +} + +// NewProxyServiceServer creates a new proxy service server +func NewProxyServiceServer() *ProxyServiceServer { + return &ProxyServiceServer{ + updatesChan: make(chan *proto.ServiceUpdate, 100), + } +} + +// Stream handles the bidirectional stream with proxy clients +func (s *ProxyServiceServer) Stream(stream proto.ProxyService_StreamServer) error { + ctx := stream.Context() + + peerInfo := "" + if p, ok := peer.FromContext(ctx); ok { + peerInfo = p.Addr.String() + } + + log.Infof("New proxy connection from %s", peerInfo) + + firstMsg, err := stream.Recv() + if err != nil { + log.Errorf("Failed to receive ProxyHello: %v", err) + return status.Errorf(codes.InvalidArgument, "expected ProxyHello message") + } + + hello := firstMsg.GetHello() + if hello == nil { + log.Error("First message is not ProxyHello") + return status.Errorf(codes.InvalidArgument, "first message must be ProxyHello") + } + + proxyID := hello.GetProxyId() + if proxyID == "" { + return status.Errorf(codes.InvalidArgument, "proxy_id is required") + } + + log.Infof("Proxy %s connected (version: %s, started: %s)", + proxyID, hello.GetVersion(), hello.GetStartedAt().AsTime()) + + connCtx, cancel := context.WithCancel(ctx) + conn := &proxyConnection{ + proxyID: proxyID, + stream: stream, + sendChan: make(chan *proto.ManagementMessage, 100), + ctx: connCtx, + cancel: cancel, + } + + s.connectedProxies.Store(proxyID, conn) + defer func() { + s.connectedProxies.Delete(proxyID) + cancel() + log.Infof("Proxy %s disconnected", proxyID) + }() + + if err := s.sendSnapshot(conn); err != nil { + log.Errorf("Failed to send snapshot to proxy %s: %v", proxyID, err) + return err + } + + errChan := make(chan error, 2) + go s.sender(conn, errChan) + + go s.receiver(conn, errChan) + + select { + case err := <-errChan: + return err + case <-connCtx.Done(): + return connCtx.Err() + } +} + +// sendSnapshot sends initial snapshot of all services to proxy +func (s *ProxyServiceServer) sendSnapshot(conn *proxyConnection) error { + // TODO: Get actual services from database/store + // For now, sending test service + testService := &proto.ExposedServiceConfig{ + Id: "test", + Domain: "test.netbird.io", + PathMappings: map[string]string{ + "/": "100.116.118.156:8181", + }, + SetupKey: "some-key", + Auth: &proto.AuthConfig{ + AuthType: &proto.AuthConfig_BearerAuth{ + BearerAuth: &proto.BearerAuthConfig{ + Enabled: true, + }, + }, + }, + } + + snapshot := &proto.ServicesSnapshot{ + Services: []*proto.ExposedServiceConfig{testService}, + Timestamp: timestamppb.Now(), + } + + msg := &proto.ManagementMessage{ + Payload: &proto.ManagementMessage_Snapshot{ + Snapshot: snapshot, + }, + } + + log.Infof("Sending snapshot to proxy %s with %d services", conn.proxyID, len(snapshot.Services)) + + if err := conn.stream.Send(msg); err != nil { + return status.Errorf(codes.Internal, "failed to send snapshot: %v", err) + } + + return nil +} + +// sender handles sending messages to proxy +func (s *ProxyServiceServer) sender(conn *proxyConnection, errChan chan<- error) { + for { + select { + case msg := <-conn.sendChan: + if err := conn.stream.Send(msg); err != nil { + log.Errorf("Failed to send message to proxy %s: %v", conn.proxyID, err) + errChan <- err + return + } + case <-conn.ctx.Done(): + return + } + } +} + +// receiver handles receiving messages from proxy +func (s *ProxyServiceServer) receiver(conn *proxyConnection, errChan chan<- error) { + for { + msg, err := conn.stream.Recv() + if err == io.EOF { + log.Infof("Proxy %s closed connection", conn.proxyID) + errChan <- nil + return + } + if err != nil { + log.Errorf("Failed to receive from proxy %s: %v", conn.proxyID, err) + errChan <- err + return + } + + // Handle different message types + switch payload := msg.GetPayload().(type) { + case *proto.ProxyMessage_RequestData: + s.handleAccessLog(conn.proxyID, payload.RequestData) + case *proto.ProxyMessage_Hello: + log.Warnf("Received unexpected ProxyHello from %s after initial handshake", conn.proxyID) + default: + log.Warnf("Received unknown message type from proxy %s", conn.proxyID) + } + } +} + +// handleAccessLog processes access log from proxy +func (s *ProxyServiceServer) handleAccessLog(proxyID string, data *proto.ProxyRequestData) { + log.WithFields(log.Fields{ + "proxy_id": proxyID, + "service_id": data.GetServiceId(), + "host": data.GetHost(), + "path": data.GetPath(), + "method": data.GetMethod(), + "response_code": data.GetResponseCode(), + "duration_ms": data.GetDurationMs(), + "source_ip": data.GetSourceIp(), + "auth_mechanism": data.GetAuthMechanism(), + "user_id": data.GetUserId(), + "auth_success": data.GetAuthSuccess(), + }).Info("Access log from proxy") + + // TODO: Store access log in database/metrics system +} + +// SendServiceUpdate broadcasts a service update to all connected proxies +// This should be called by management when services are created/updated/removed +func (s *ProxyServiceServer) SendServiceUpdate(update *proto.ServiceUpdate) { + updateMsg := &proto.ManagementMessage{ + Payload: &proto.ManagementMessage_Update{ + Update: update, + }, + } + + // Send to all connected proxies + s.connectedProxies.Range(func(key, value interface{}) bool { + conn := value.(*proxyConnection) + select { + case conn.sendChan <- updateMsg: + log.Debugf("Sent service update to proxy %s", conn.proxyID) + default: + log.Warnf("Failed to send service update to proxy %s (channel full)", conn.proxyID) + } + return true + }) +} + +// GetConnectedProxies returns list of connected proxy IDs +func (s *ProxyServiceServer) GetConnectedProxies() []string { + var proxies []string + s.connectedProxies.Range(func(key, value interface{}) bool { + proxies = append(proxies, key.(string)) + return true + }) + return proxies +} diff --git a/proxy/pkg/grpc/client.go b/proxy/pkg/grpc/client.go new file mode 100644 index 000000000..65c04f41c --- /dev/null +++ b/proxy/pkg/grpc/client.go @@ -0,0 +1,325 @@ +package grpc + +import ( + "context" + "fmt" + "io" + "strings" + "sync" + "time" + + log "github.com/sirupsen/logrus" + "google.golang.org/grpc" + "google.golang.org/grpc/credentials/insecure" + "google.golang.org/grpc/keepalive" + "google.golang.org/protobuf/types/known/timestamppb" + + "github.com/netbirdio/netbird/shared/management/proto" +) + +const ( + reconnectInterval = 5 * time.Second + proxyVersion = "0.1.0" +) + +// ServiceUpdateHandler is called when services are added/updated/removed +type ServiceUpdateHandler func(update *proto.ServiceUpdate) error + +// Client manages the gRPC connection to management server +type Client struct { + proxyID string + managementURL string + conn *grpc.ClientConn + stream proto.ProxyService_StreamClient + serviceUpdateHandler ServiceUpdateHandler + accessLogChan chan *proto.ProxyRequestData + ctx context.Context + cancel context.CancelFunc + mu sync.RWMutex + connected bool +} + +// ClientConfig holds client configuration +type ClientConfig struct { + ProxyID string + ManagementURL string + ServiceUpdateHandler ServiceUpdateHandler +} + +// NewClient creates a new gRPC client for proxy-management communication +func NewClient(config ClientConfig) *Client { + ctx, cancel := context.WithCancel(context.Background()) + + return &Client{ + proxyID: config.ProxyID, + managementURL: config.ManagementURL, + serviceUpdateHandler: config.ServiceUpdateHandler, + accessLogChan: make(chan *proto.ProxyRequestData, 1000), + ctx: ctx, + cancel: cancel, + } +} + +// Start connects to management server and maintains connection +func (c *Client) Start() error { + go c.connectionLoop() + return nil +} + +// Stop closes the connection +func (c *Client) Stop() error { + c.cancel() + c.mu.Lock() + defer c.mu.Unlock() + + if c.stream != nil { + // Try to close stream gracefully + _ = c.stream.CloseSend() + } + + if c.conn != nil { + return c.conn.Close() + } + + return nil +} + +// SendAccessLog queues an access log to be sent to management +func (c *Client) SendAccessLog(log *proto.ProxyRequestData) { + select { + case c.accessLogChan <- log: + default: + // Channel full, drop log + } +} + +// IsConnected returns whether client is connected to management +func (c *Client) IsConnected() bool { + c.mu.RLock() + defer c.mu.RUnlock() + return c.connected +} + +// connectionLoop maintains connection to management server +func (c *Client) connectionLoop() { + for { + select { + case <-c.ctx.Done(): + return + default: + } + + log.Infof("Connecting to management server at %s", c.managementURL) + + if err := c.connect(); err != nil { + log.Errorf("Failed to connect to management: %v", err) + c.setConnected(false) + + select { + case <-c.ctx.Done(): + return + case <-time.After(reconnectInterval): + continue + } + } + + // Handle connection + if err := c.handleConnection(); err != nil { + log.Errorf("Connection error: %v", err) + c.setConnected(false) + } + + // Reconnect after delay + select { + case <-c.ctx.Done(): + return + case <-time.After(reconnectInterval): + } + } +} + +// connect establishes connection to management server +func (c *Client) connect() error { + // Strip scheme from URL if present (gRPC doesn't use http:// or https://) + target := c.managementURL + target = strings.TrimPrefix(target, "http://") + target = strings.TrimPrefix(target, "https://") + + // Create gRPC connection + opts := []grpc.DialOption{ + grpc.WithTransportCredentials(insecure.NewCredentials()), // TODO: Add TLS + grpc.WithKeepaliveParams(keepalive.ClientParameters{ + Time: 20 * time.Second, + Timeout: 10 * time.Second, + PermitWithoutStream: true, + }), + } + + conn, err := grpc.Dial(target, opts...) + if err != nil { + return fmt.Errorf("failed to dial: %w", err) + } + + c.mu.Lock() + c.conn = conn + c.mu.Unlock() + + // Create stream + client := proto.NewProxyServiceClient(conn) + stream, err := client.Stream(c.ctx) + if err != nil { + conn.Close() + return fmt.Errorf("failed to create stream: %w", err) + } + + c.mu.Lock() + c.stream = stream + c.mu.Unlock() + + // Send ProxyHello + hello := &proto.ProxyMessage{ + Payload: &proto.ProxyMessage_Hello{ + Hello: &proto.ProxyHello{ + ProxyId: c.proxyID, + Version: proxyVersion, + StartedAt: timestamppb.Now(), + }, + }, + } + + if err := stream.Send(hello); err != nil { + conn.Close() + return fmt.Errorf("failed to send hello: %w", err) + } + + c.setConnected(true) + log.Info("Successfully connected to management server") + + return nil +} + +// handleConnection manages the active connection +func (c *Client) handleConnection() error { + errChan := make(chan error, 2) + + // Start sender goroutine + go c.sender(errChan) + + // Start receiver goroutine + go c.receiver(errChan) + + // Wait for error + return <-errChan +} + +// sender sends messages to management +func (c *Client) sender(errChan chan<- error) { + for { + select { + case <-c.ctx.Done(): + errChan <- c.ctx.Err() + return + + case accessLog := <-c.accessLogChan: + msg := &proto.ProxyMessage{ + Payload: &proto.ProxyMessage_RequestData{ + RequestData: accessLog, + }, + } + + c.mu.RLock() + stream := c.stream + c.mu.RUnlock() + + if stream == nil { + continue + } + + if err := stream.Send(msg); err != nil { + log.Errorf("Failed to send access log: %v", err) + errChan <- err + return + } + } + } +} + +// receiver receives messages from management +func (c *Client) receiver(errChan chan<- error) { + for { + c.mu.RLock() + stream := c.stream + c.mu.RUnlock() + + if stream == nil { + errChan <- fmt.Errorf("stream is nil") + return + } + + msg, err := stream.Recv() + if err == io.EOF { + log.Info("Management server closed connection") + errChan <- io.EOF + return + } + if err != nil { + log.Errorf("Failed to receive: %v", err) + errChan <- err + return + } + + // Handle message + switch payload := msg.GetPayload().(type) { + case *proto.ManagementMessage_Snapshot: + c.handleSnapshot(payload.Snapshot) + case *proto.ManagementMessage_Update: + c.handleServiceUpdate(payload.Update) + default: + log.Warnf("Received unknown message type") + } + } +} + +// handleSnapshot processes initial services snapshot +func (c *Client) handleSnapshot(snapshot *proto.ServicesSnapshot) { + log.Infof("Received services snapshot with %d services", len(snapshot.Services)) + + if c.serviceUpdateHandler == nil { + log.Warn("No service update handler configured") + return + } + + // Process each service as a CREATED update + for _, service := range snapshot.Services { + update := &proto.ServiceUpdate{ + Type: proto.ServiceUpdate_CREATED, + Service: service, + ServiceId: service.Id, + } + + if err := c.serviceUpdateHandler(update); err != nil { + log.Errorf("Failed to handle service %s: %v", service.Id, err) + } + } +} + +// handleServiceUpdate processes incremental service update +func (c *Client) handleServiceUpdate(update *proto.ServiceUpdate) { + log.Infof("Received service update: %s %s", update.Type, update.ServiceId) + + if c.serviceUpdateHandler == nil { + log.Warn("No service update handler configured") + return + } + + if err := c.serviceUpdateHandler(update); err != nil { + log.Errorf("Failed to handle service update: %v", err) + } +} + +// setConnected updates connected status +func (c *Client) setConnected(connected bool) { + c.mu.Lock() + defer c.mu.Unlock() + c.connected = connected +} diff --git a/proxy/pkg/grpc/proto/proxy.pb.go b/proxy/pkg/grpc/proto/proxy.pb.go deleted file mode 100644 index 654212151..000000000 --- a/proxy/pkg/grpc/proto/proxy.pb.go +++ /dev/null @@ -1,1796 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.26.0 -// protoc v6.33.0 -// source: pkg/grpc/proto/proxy.proto - -package proto - -import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - timestamppb "google.golang.org/protobuf/types/known/timestamppb" - reflect "reflect" - sync "sync" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -type ProxyEvent_EventType int32 - -const ( - ProxyEvent_UNKNOWN ProxyEvent_EventType = 0 - ProxyEvent_STARTED ProxyEvent_EventType = 1 - ProxyEvent_STOPPED ProxyEvent_EventType = 2 - ProxyEvent_ERROR ProxyEvent_EventType = 3 - ProxyEvent_BACKEND_UNAVAILABLE ProxyEvent_EventType = 4 - ProxyEvent_BACKEND_RECOVERED ProxyEvent_EventType = 5 - ProxyEvent_CONFIG_UPDATED ProxyEvent_EventType = 6 -) - -// Enum value maps for ProxyEvent_EventType. -var ( - ProxyEvent_EventType_name = map[int32]string{ - 0: "UNKNOWN", - 1: "STARTED", - 2: "STOPPED", - 3: "ERROR", - 4: "BACKEND_UNAVAILABLE", - 5: "BACKEND_RECOVERED", - 6: "CONFIG_UPDATED", - } - ProxyEvent_EventType_value = map[string]int32{ - "UNKNOWN": 0, - "STARTED": 1, - "STOPPED": 2, - "ERROR": 3, - "BACKEND_UNAVAILABLE": 4, - "BACKEND_RECOVERED": 5, - "CONFIG_UPDATED": 6, - } -) - -func (x ProxyEvent_EventType) Enum() *ProxyEvent_EventType { - p := new(ProxyEvent_EventType) - *p = x - return p -} - -func (x ProxyEvent_EventType) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (ProxyEvent_EventType) Descriptor() protoreflect.EnumDescriptor { - return file_pkg_grpc_proto_proxy_proto_enumTypes[0].Descriptor() -} - -func (ProxyEvent_EventType) Type() protoreflect.EnumType { - return &file_pkg_grpc_proto_proxy_proto_enumTypes[0] -} - -func (x ProxyEvent_EventType) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Use ProxyEvent_EventType.Descriptor instead. -func (ProxyEvent_EventType) EnumDescriptor() ([]byte, []int) { - return file_pkg_grpc_proto_proxy_proto_rawDescGZIP(), []int{3, 0} -} - -type ProxyLog_LogLevel int32 - -const ( - ProxyLog_DEBUG ProxyLog_LogLevel = 0 - ProxyLog_INFO ProxyLog_LogLevel = 1 - ProxyLog_WARN ProxyLog_LogLevel = 2 - ProxyLog_ERROR ProxyLog_LogLevel = 3 -) - -// Enum value maps for ProxyLog_LogLevel. -var ( - ProxyLog_LogLevel_name = map[int32]string{ - 0: "DEBUG", - 1: "INFO", - 2: "WARN", - 3: "ERROR", - } - ProxyLog_LogLevel_value = map[string]int32{ - "DEBUG": 0, - "INFO": 1, - "WARN": 2, - "ERROR": 3, - } -) - -func (x ProxyLog_LogLevel) Enum() *ProxyLog_LogLevel { - p := new(ProxyLog_LogLevel) - *p = x - return p -} - -func (x ProxyLog_LogLevel) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (ProxyLog_LogLevel) Descriptor() protoreflect.EnumDescriptor { - return file_pkg_grpc_proto_proxy_proto_enumTypes[1].Descriptor() -} - -func (ProxyLog_LogLevel) Type() protoreflect.EnumType { - return &file_pkg_grpc_proto_proxy_proto_enumTypes[1] -} - -func (x ProxyLog_LogLevel) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Use ProxyLog_LogLevel.Descriptor instead. -func (ProxyLog_LogLevel) EnumDescriptor() ([]byte, []int) { - return file_pkg_grpc_proto_proxy_proto_rawDescGZIP(), []int{4, 0} -} - -type ControlCommand_CommandType int32 - -const ( - ControlCommand_UNKNOWN ControlCommand_CommandType = 0 - ControlCommand_RELOAD_CONFIG ControlCommand_CommandType = 1 - ControlCommand_ENABLE_DEBUG ControlCommand_CommandType = 2 - ControlCommand_DISABLE_DEBUG ControlCommand_CommandType = 3 - ControlCommand_GET_STATS ControlCommand_CommandType = 4 - ControlCommand_SHUTDOWN ControlCommand_CommandType = 5 -) - -// Enum value maps for ControlCommand_CommandType. -var ( - ControlCommand_CommandType_name = map[int32]string{ - 0: "UNKNOWN", - 1: "RELOAD_CONFIG", - 2: "ENABLE_DEBUG", - 3: "DISABLE_DEBUG", - 4: "GET_STATS", - 5: "SHUTDOWN", - } - ControlCommand_CommandType_value = map[string]int32{ - "UNKNOWN": 0, - "RELOAD_CONFIG": 1, - "ENABLE_DEBUG": 2, - "DISABLE_DEBUG": 3, - "GET_STATS": 4, - "SHUTDOWN": 5, - } -) - -func (x ControlCommand_CommandType) Enum() *ControlCommand_CommandType { - p := new(ControlCommand_CommandType) - *p = x - return p -} - -func (x ControlCommand_CommandType) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (ControlCommand_CommandType) Descriptor() protoreflect.EnumDescriptor { - return file_pkg_grpc_proto_proxy_proto_enumTypes[2].Descriptor() -} - -func (ControlCommand_CommandType) Type() protoreflect.EnumType { - return &file_pkg_grpc_proto_proxy_proto_enumTypes[2] -} - -func (x ControlCommand_CommandType) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Use ControlCommand_CommandType.Descriptor instead. -func (ControlCommand_CommandType) EnumDescriptor() ([]byte, []int) { - return file_pkg_grpc_proto_proxy_proto_rawDescGZIP(), []int{7, 0} -} - -type ExposedServiceEvent_EventType int32 - -const ( - ExposedServiceEvent_UNKNOWN ExposedServiceEvent_EventType = 0 - ExposedServiceEvent_CREATED ExposedServiceEvent_EventType = 1 - ExposedServiceEvent_UPDATED ExposedServiceEvent_EventType = 2 - ExposedServiceEvent_REMOVED ExposedServiceEvent_EventType = 3 -) - -// Enum value maps for ExposedServiceEvent_EventType. -var ( - ExposedServiceEvent_EventType_name = map[int32]string{ - 0: "UNKNOWN", - 1: "CREATED", - 2: "UPDATED", - 3: "REMOVED", - } - ExposedServiceEvent_EventType_value = map[string]int32{ - "UNKNOWN": 0, - "CREATED": 1, - "UPDATED": 2, - "REMOVED": 3, - } -) - -func (x ExposedServiceEvent_EventType) Enum() *ExposedServiceEvent_EventType { - p := new(ExposedServiceEvent_EventType) - *p = x - return p -} - -func (x ExposedServiceEvent_EventType) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (ExposedServiceEvent_EventType) Descriptor() protoreflect.EnumDescriptor { - return file_pkg_grpc_proto_proxy_proto_enumTypes[3].Descriptor() -} - -func (ExposedServiceEvent_EventType) Type() protoreflect.EnumType { - return &file_pkg_grpc_proto_proxy_proto_enumTypes[3] -} - -func (x ExposedServiceEvent_EventType) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Use ExposedServiceEvent_EventType.Descriptor instead. -func (ExposedServiceEvent_EventType) EnumDescriptor() ([]byte, []int) { - return file_pkg_grpc_proto_proxy_proto_rawDescGZIP(), []int{9, 0} -} - -// ProxyMessage represents messages sent from proxy to control service -type ProxyMessage struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // Types that are assignable to Message: - // - // *ProxyMessage_Stats - // *ProxyMessage_Event - // *ProxyMessage_Log - // *ProxyMessage_Heartbeat - // *ProxyMessage_RequestData - Message isProxyMessage_Message `protobuf_oneof:"message"` -} - -func (x *ProxyMessage) Reset() { - *x = ProxyMessage{} - if protoimpl.UnsafeEnabled { - mi := &file_pkg_grpc_proto_proxy_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ProxyMessage) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ProxyMessage) ProtoMessage() {} - -func (x *ProxyMessage) ProtoReflect() protoreflect.Message { - mi := &file_pkg_grpc_proto_proxy_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ProxyMessage.ProtoReflect.Descriptor instead. -func (*ProxyMessage) Descriptor() ([]byte, []int) { - return file_pkg_grpc_proto_proxy_proto_rawDescGZIP(), []int{0} -} - -func (m *ProxyMessage) GetMessage() isProxyMessage_Message { - if m != nil { - return m.Message - } - return nil -} - -func (x *ProxyMessage) GetStats() *ProxyStats { - if x, ok := x.GetMessage().(*ProxyMessage_Stats); ok { - return x.Stats - } - return nil -} - -func (x *ProxyMessage) GetEvent() *ProxyEvent { - if x, ok := x.GetMessage().(*ProxyMessage_Event); ok { - return x.Event - } - return nil -} - -func (x *ProxyMessage) GetLog() *ProxyLog { - if x, ok := x.GetMessage().(*ProxyMessage_Log); ok { - return x.Log - } - return nil -} - -func (x *ProxyMessage) GetHeartbeat() *ProxyHeartbeat { - if x, ok := x.GetMessage().(*ProxyMessage_Heartbeat); ok { - return x.Heartbeat - } - return nil -} - -func (x *ProxyMessage) GetRequestData() *ProxyRequestData { - if x, ok := x.GetMessage().(*ProxyMessage_RequestData); ok { - return x.RequestData - } - return nil -} - -type isProxyMessage_Message interface { - isProxyMessage_Message() -} - -type ProxyMessage_Stats struct { - Stats *ProxyStats `protobuf:"bytes,1,opt,name=stats,proto3,oneof"` -} - -type ProxyMessage_Event struct { - Event *ProxyEvent `protobuf:"bytes,2,opt,name=event,proto3,oneof"` -} - -type ProxyMessage_Log struct { - Log *ProxyLog `protobuf:"bytes,3,opt,name=log,proto3,oneof"` -} - -type ProxyMessage_Heartbeat struct { - Heartbeat *ProxyHeartbeat `protobuf:"bytes,4,opt,name=heartbeat,proto3,oneof"` -} - -type ProxyMessage_RequestData struct { - RequestData *ProxyRequestData `protobuf:"bytes,5,opt,name=request_data,json=requestData,proto3,oneof"` -} - -func (*ProxyMessage_Stats) isProxyMessage_Message() {} - -func (*ProxyMessage_Event) isProxyMessage_Message() {} - -func (*ProxyMessage_Log) isProxyMessage_Message() {} - -func (*ProxyMessage_Heartbeat) isProxyMessage_Message() {} - -func (*ProxyMessage_RequestData) isProxyMessage_Message() {} - -// ControlMessage represents messages sent from control service to proxy -type ControlMessage struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // Types that are assignable to Message: - // - // *ControlMessage_Event - // *ControlMessage_Command - // *ControlMessage_Config - // *ControlMessage_ExposedService - Message isControlMessage_Message `protobuf_oneof:"message"` -} - -func (x *ControlMessage) Reset() { - *x = ControlMessage{} - if protoimpl.UnsafeEnabled { - mi := &file_pkg_grpc_proto_proxy_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ControlMessage) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ControlMessage) ProtoMessage() {} - -func (x *ControlMessage) ProtoReflect() protoreflect.Message { - mi := &file_pkg_grpc_proto_proxy_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ControlMessage.ProtoReflect.Descriptor instead. -func (*ControlMessage) Descriptor() ([]byte, []int) { - return file_pkg_grpc_proto_proxy_proto_rawDescGZIP(), []int{1} -} - -func (m *ControlMessage) GetMessage() isControlMessage_Message { - if m != nil { - return m.Message - } - return nil -} - -func (x *ControlMessage) GetEvent() *ControlEvent { - if x, ok := x.GetMessage().(*ControlMessage_Event); ok { - return x.Event - } - return nil -} - -func (x *ControlMessage) GetCommand() *ControlCommand { - if x, ok := x.GetMessage().(*ControlMessage_Command); ok { - return x.Command - } - return nil -} - -func (x *ControlMessage) GetConfig() *ControlConfig { - if x, ok := x.GetMessage().(*ControlMessage_Config); ok { - return x.Config - } - return nil -} - -func (x *ControlMessage) GetExposedService() *ExposedServiceEvent { - if x, ok := x.GetMessage().(*ControlMessage_ExposedService); ok { - return x.ExposedService - } - return nil -} - -type isControlMessage_Message interface { - isControlMessage_Message() -} - -type ControlMessage_Event struct { - Event *ControlEvent `protobuf:"bytes,1,opt,name=event,proto3,oneof"` -} - -type ControlMessage_Command struct { - Command *ControlCommand `protobuf:"bytes,2,opt,name=command,proto3,oneof"` -} - -type ControlMessage_Config struct { - Config *ControlConfig `protobuf:"bytes,3,opt,name=config,proto3,oneof"` -} - -type ControlMessage_ExposedService struct { - ExposedService *ExposedServiceEvent `protobuf:"bytes,4,opt,name=exposed_service,json=exposedService,proto3,oneof"` -} - -func (*ControlMessage_Event) isControlMessage_Message() {} - -func (*ControlMessage_Command) isControlMessage_Message() {} - -func (*ControlMessage_Config) isControlMessage_Message() {} - -func (*ControlMessage_ExposedService) isControlMessage_Message() {} - -// ProxyStats contains proxy statistics -type ProxyStats struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Timestamp *timestamppb.Timestamp `protobuf:"bytes,1,opt,name=timestamp,proto3" json:"timestamp,omitempty"` - TotalRequests uint64 `protobuf:"varint,2,opt,name=total_requests,json=totalRequests,proto3" json:"total_requests,omitempty"` - ActiveConnections uint64 `protobuf:"varint,3,opt,name=active_connections,json=activeConnections,proto3" json:"active_connections,omitempty"` - BytesSent uint64 `protobuf:"varint,4,opt,name=bytes_sent,json=bytesSent,proto3" json:"bytes_sent,omitempty"` - BytesReceived uint64 `protobuf:"varint,5,opt,name=bytes_received,json=bytesReceived,proto3" json:"bytes_received,omitempty"` - CpuUsage float64 `protobuf:"fixed64,6,opt,name=cpu_usage,json=cpuUsage,proto3" json:"cpu_usage,omitempty"` - MemoryUsageMb float64 `protobuf:"fixed64,7,opt,name=memory_usage_mb,json=memoryUsageMb,proto3" json:"memory_usage_mb,omitempty"` - StatusCodeCounts map[string]uint64 `protobuf:"bytes,8,rep,name=status_code_counts,json=statusCodeCounts,proto3" json:"status_code_counts,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` -} - -func (x *ProxyStats) Reset() { - *x = ProxyStats{} - if protoimpl.UnsafeEnabled { - mi := &file_pkg_grpc_proto_proxy_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ProxyStats) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ProxyStats) ProtoMessage() {} - -func (x *ProxyStats) ProtoReflect() protoreflect.Message { - mi := &file_pkg_grpc_proto_proxy_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ProxyStats.ProtoReflect.Descriptor instead. -func (*ProxyStats) Descriptor() ([]byte, []int) { - return file_pkg_grpc_proto_proxy_proto_rawDescGZIP(), []int{2} -} - -func (x *ProxyStats) GetTimestamp() *timestamppb.Timestamp { - if x != nil { - return x.Timestamp - } - return nil -} - -func (x *ProxyStats) GetTotalRequests() uint64 { - if x != nil { - return x.TotalRequests - } - return 0 -} - -func (x *ProxyStats) GetActiveConnections() uint64 { - if x != nil { - return x.ActiveConnections - } - return 0 -} - -func (x *ProxyStats) GetBytesSent() uint64 { - if x != nil { - return x.BytesSent - } - return 0 -} - -func (x *ProxyStats) GetBytesReceived() uint64 { - if x != nil { - return x.BytesReceived - } - return 0 -} - -func (x *ProxyStats) GetCpuUsage() float64 { - if x != nil { - return x.CpuUsage - } - return 0 -} - -func (x *ProxyStats) GetMemoryUsageMb() float64 { - if x != nil { - return x.MemoryUsageMb - } - return 0 -} - -func (x *ProxyStats) GetStatusCodeCounts() map[string]uint64 { - if x != nil { - return x.StatusCodeCounts - } - return nil -} - -// ProxyEvent represents events from the proxy -type ProxyEvent struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Timestamp *timestamppb.Timestamp `protobuf:"bytes,1,opt,name=timestamp,proto3" json:"timestamp,omitempty"` - Type ProxyEvent_EventType `protobuf:"varint,2,opt,name=type,proto3,enum=proxy.ProxyEvent_EventType" json:"type,omitempty"` - Message string `protobuf:"bytes,3,opt,name=message,proto3" json:"message,omitempty"` - Metadata map[string]string `protobuf:"bytes,4,rep,name=metadata,proto3" json:"metadata,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` -} - -func (x *ProxyEvent) Reset() { - *x = ProxyEvent{} - if protoimpl.UnsafeEnabled { - mi := &file_pkg_grpc_proto_proxy_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ProxyEvent) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ProxyEvent) ProtoMessage() {} - -func (x *ProxyEvent) ProtoReflect() protoreflect.Message { - mi := &file_pkg_grpc_proto_proxy_proto_msgTypes[3] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ProxyEvent.ProtoReflect.Descriptor instead. -func (*ProxyEvent) Descriptor() ([]byte, []int) { - return file_pkg_grpc_proto_proxy_proto_rawDescGZIP(), []int{3} -} - -func (x *ProxyEvent) GetTimestamp() *timestamppb.Timestamp { - if x != nil { - return x.Timestamp - } - return nil -} - -func (x *ProxyEvent) GetType() ProxyEvent_EventType { - if x != nil { - return x.Type - } - return ProxyEvent_UNKNOWN -} - -func (x *ProxyEvent) GetMessage() string { - if x != nil { - return x.Message - } - return "" -} - -func (x *ProxyEvent) GetMetadata() map[string]string { - if x != nil { - return x.Metadata - } - return nil -} - -// ProxyLog represents log entries -type ProxyLog struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Timestamp *timestamppb.Timestamp `protobuf:"bytes,1,opt,name=timestamp,proto3" json:"timestamp,omitempty"` - Level ProxyLog_LogLevel `protobuf:"varint,2,opt,name=level,proto3,enum=proxy.ProxyLog_LogLevel" json:"level,omitempty"` - Message string `protobuf:"bytes,3,opt,name=message,proto3" json:"message,omitempty"` - Fields map[string]string `protobuf:"bytes,4,rep,name=fields,proto3" json:"fields,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` -} - -func (x *ProxyLog) Reset() { - *x = ProxyLog{} - if protoimpl.UnsafeEnabled { - mi := &file_pkg_grpc_proto_proxy_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ProxyLog) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ProxyLog) ProtoMessage() {} - -func (x *ProxyLog) ProtoReflect() protoreflect.Message { - mi := &file_pkg_grpc_proto_proxy_proto_msgTypes[4] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ProxyLog.ProtoReflect.Descriptor instead. -func (*ProxyLog) Descriptor() ([]byte, []int) { - return file_pkg_grpc_proto_proxy_proto_rawDescGZIP(), []int{4} -} - -func (x *ProxyLog) GetTimestamp() *timestamppb.Timestamp { - if x != nil { - return x.Timestamp - } - return nil -} - -func (x *ProxyLog) GetLevel() ProxyLog_LogLevel { - if x != nil { - return x.Level - } - return ProxyLog_DEBUG -} - -func (x *ProxyLog) GetMessage() string { - if x != nil { - return x.Message - } - return "" -} - -func (x *ProxyLog) GetFields() map[string]string { - if x != nil { - return x.Fields - } - return nil -} - -// ProxyHeartbeat is sent periodically to keep connection alive -type ProxyHeartbeat struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Timestamp *timestamppb.Timestamp `protobuf:"bytes,1,opt,name=timestamp,proto3" json:"timestamp,omitempty"` - ProxyId string `protobuf:"bytes,2,opt,name=proxy_id,json=proxyId,proto3" json:"proxy_id,omitempty"` -} - -func (x *ProxyHeartbeat) Reset() { - *x = ProxyHeartbeat{} - if protoimpl.UnsafeEnabled { - mi := &file_pkg_grpc_proto_proxy_proto_msgTypes[5] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ProxyHeartbeat) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ProxyHeartbeat) ProtoMessage() {} - -func (x *ProxyHeartbeat) ProtoReflect() protoreflect.Message { - mi := &file_pkg_grpc_proto_proxy_proto_msgTypes[5] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ProxyHeartbeat.ProtoReflect.Descriptor instead. -func (*ProxyHeartbeat) Descriptor() ([]byte, []int) { - return file_pkg_grpc_proto_proxy_proto_rawDescGZIP(), []int{5} -} - -func (x *ProxyHeartbeat) GetTimestamp() *timestamppb.Timestamp { - if x != nil { - return x.Timestamp - } - return nil -} - -func (x *ProxyHeartbeat) GetProxyId() string { - if x != nil { - return x.ProxyId - } - return "" -} - -// ControlEvent represents events from control service -type ControlEvent struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Timestamp *timestamppb.Timestamp `protobuf:"bytes,1,opt,name=timestamp,proto3" json:"timestamp,omitempty"` - EventId string `protobuf:"bytes,2,opt,name=event_id,json=eventId,proto3" json:"event_id,omitempty"` - Message string `protobuf:"bytes,3,opt,name=message,proto3" json:"message,omitempty"` -} - -func (x *ControlEvent) Reset() { - *x = ControlEvent{} - if protoimpl.UnsafeEnabled { - mi := &file_pkg_grpc_proto_proxy_proto_msgTypes[6] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ControlEvent) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ControlEvent) ProtoMessage() {} - -func (x *ControlEvent) ProtoReflect() protoreflect.Message { - mi := &file_pkg_grpc_proto_proxy_proto_msgTypes[6] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ControlEvent.ProtoReflect.Descriptor instead. -func (*ControlEvent) Descriptor() ([]byte, []int) { - return file_pkg_grpc_proto_proxy_proto_rawDescGZIP(), []int{6} -} - -func (x *ControlEvent) GetTimestamp() *timestamppb.Timestamp { - if x != nil { - return x.Timestamp - } - return nil -} - -func (x *ControlEvent) GetEventId() string { - if x != nil { - return x.EventId - } - return "" -} - -func (x *ControlEvent) GetMessage() string { - if x != nil { - return x.Message - } - return "" -} - -// ControlCommand represents commands sent to proxy -type ControlCommand struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - CommandId string `protobuf:"bytes,1,opt,name=command_id,json=commandId,proto3" json:"command_id,omitempty"` - Type ControlCommand_CommandType `protobuf:"varint,2,opt,name=type,proto3,enum=proxy.ControlCommand_CommandType" json:"type,omitempty"` - Parameters map[string]string `protobuf:"bytes,3,rep,name=parameters,proto3" json:"parameters,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` -} - -func (x *ControlCommand) Reset() { - *x = ControlCommand{} - if protoimpl.UnsafeEnabled { - mi := &file_pkg_grpc_proto_proxy_proto_msgTypes[7] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ControlCommand) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ControlCommand) ProtoMessage() {} - -func (x *ControlCommand) ProtoReflect() protoreflect.Message { - mi := &file_pkg_grpc_proto_proxy_proto_msgTypes[7] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ControlCommand.ProtoReflect.Descriptor instead. -func (*ControlCommand) Descriptor() ([]byte, []int) { - return file_pkg_grpc_proto_proxy_proto_rawDescGZIP(), []int{7} -} - -func (x *ControlCommand) GetCommandId() string { - if x != nil { - return x.CommandId - } - return "" -} - -func (x *ControlCommand) GetType() ControlCommand_CommandType { - if x != nil { - return x.Type - } - return ControlCommand_UNKNOWN -} - -func (x *ControlCommand) GetParameters() map[string]string { - if x != nil { - return x.Parameters - } - return nil -} - -// ControlConfig contains configuration updates from control service -type ControlConfig struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - ConfigVersion string `protobuf:"bytes,1,opt,name=config_version,json=configVersion,proto3" json:"config_version,omitempty"` - Settings map[string]string `protobuf:"bytes,2,rep,name=settings,proto3" json:"settings,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` -} - -func (x *ControlConfig) Reset() { - *x = ControlConfig{} - if protoimpl.UnsafeEnabled { - mi := &file_pkg_grpc_proto_proxy_proto_msgTypes[8] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ControlConfig) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ControlConfig) ProtoMessage() {} - -func (x *ControlConfig) ProtoReflect() protoreflect.Message { - mi := &file_pkg_grpc_proto_proxy_proto_msgTypes[8] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ControlConfig.ProtoReflect.Descriptor instead. -func (*ControlConfig) Descriptor() ([]byte, []int) { - return file_pkg_grpc_proto_proxy_proto_rawDescGZIP(), []int{8} -} - -func (x *ControlConfig) GetConfigVersion() string { - if x != nil { - return x.ConfigVersion - } - return "" -} - -func (x *ControlConfig) GetSettings() map[string]string { - if x != nil { - return x.Settings - } - return nil -} - -// ExposedServiceEvent represents exposed service lifecycle events -type ExposedServiceEvent struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Timestamp *timestamppb.Timestamp `protobuf:"bytes,1,opt,name=timestamp,proto3" json:"timestamp,omitempty"` - Type ExposedServiceEvent_EventType `protobuf:"varint,2,opt,name=type,proto3,enum=proxy.ExposedServiceEvent_EventType" json:"type,omitempty"` - ServiceId string `protobuf:"bytes,3,opt,name=service_id,json=serviceId,proto3" json:"service_id,omitempty"` - PeerConfig *PeerConfig `protobuf:"bytes,4,opt,name=peer_config,json=peerConfig,proto3" json:"peer_config,omitempty"` - UpstreamConfig *UpstreamConfig `protobuf:"bytes,5,opt,name=upstream_config,json=upstreamConfig,proto3" json:"upstream_config,omitempty"` -} - -func (x *ExposedServiceEvent) Reset() { - *x = ExposedServiceEvent{} - if protoimpl.UnsafeEnabled { - mi := &file_pkg_grpc_proto_proxy_proto_msgTypes[9] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ExposedServiceEvent) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ExposedServiceEvent) ProtoMessage() {} - -func (x *ExposedServiceEvent) ProtoReflect() protoreflect.Message { - mi := &file_pkg_grpc_proto_proxy_proto_msgTypes[9] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ExposedServiceEvent.ProtoReflect.Descriptor instead. -func (*ExposedServiceEvent) Descriptor() ([]byte, []int) { - return file_pkg_grpc_proto_proxy_proto_rawDescGZIP(), []int{9} -} - -func (x *ExposedServiceEvent) GetTimestamp() *timestamppb.Timestamp { - if x != nil { - return x.Timestamp - } - return nil -} - -func (x *ExposedServiceEvent) GetType() ExposedServiceEvent_EventType { - if x != nil { - return x.Type - } - return ExposedServiceEvent_UNKNOWN -} - -func (x *ExposedServiceEvent) GetServiceId() string { - if x != nil { - return x.ServiceId - } - return "" -} - -func (x *ExposedServiceEvent) GetPeerConfig() *PeerConfig { - if x != nil { - return x.PeerConfig - } - return nil -} - -func (x *ExposedServiceEvent) GetUpstreamConfig() *UpstreamConfig { - if x != nil { - return x.UpstreamConfig - } - return nil -} - -// PeerConfig contains WireGuard peer configuration -type PeerConfig struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - PeerId string `protobuf:"bytes,1,opt,name=peer_id,json=peerId,proto3" json:"peer_id,omitempty"` - PublicKey string `protobuf:"bytes,2,opt,name=public_key,json=publicKey,proto3" json:"public_key,omitempty"` - AllowedIps []string `protobuf:"bytes,3,rep,name=allowed_ips,json=allowedIps,proto3" json:"allowed_ips,omitempty"` - Endpoint string `protobuf:"bytes,4,opt,name=endpoint,proto3" json:"endpoint,omitempty"` - TunnelIp string `protobuf:"bytes,5,opt,name=tunnel_ip,json=tunnelIp,proto3" json:"tunnel_ip,omitempty"` - PersistentKeepalive uint32 `protobuf:"varint,6,opt,name=persistent_keepalive,json=persistentKeepalive,proto3" json:"persistent_keepalive,omitempty"` -} - -func (x *PeerConfig) Reset() { - *x = PeerConfig{} - if protoimpl.UnsafeEnabled { - mi := &file_pkg_grpc_proto_proxy_proto_msgTypes[10] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *PeerConfig) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*PeerConfig) ProtoMessage() {} - -func (x *PeerConfig) ProtoReflect() protoreflect.Message { - mi := &file_pkg_grpc_proto_proxy_proto_msgTypes[10] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use PeerConfig.ProtoReflect.Descriptor instead. -func (*PeerConfig) Descriptor() ([]byte, []int) { - return file_pkg_grpc_proto_proxy_proto_rawDescGZIP(), []int{10} -} - -func (x *PeerConfig) GetPeerId() string { - if x != nil { - return x.PeerId - } - return "" -} - -func (x *PeerConfig) GetPublicKey() string { - if x != nil { - return x.PublicKey - } - return "" -} - -func (x *PeerConfig) GetAllowedIps() []string { - if x != nil { - return x.AllowedIps - } - return nil -} - -func (x *PeerConfig) GetEndpoint() string { - if x != nil { - return x.Endpoint - } - return "" -} - -func (x *PeerConfig) GetTunnelIp() string { - if x != nil { - return x.TunnelIp - } - return "" -} - -func (x *PeerConfig) GetPersistentKeepalive() uint32 { - if x != nil { - return x.PersistentKeepalive - } - return 0 -} - -// UpstreamConfig contains reverse proxy upstream configuration -type UpstreamConfig struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Domain string `protobuf:"bytes,1,opt,name=domain,proto3" json:"domain,omitempty"` - PathMappings map[string]string `protobuf:"bytes,2,rep,name=path_mappings,json=pathMappings,proto3" json:"path_mappings,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` // path -> port -} - -func (x *UpstreamConfig) Reset() { - *x = UpstreamConfig{} - if protoimpl.UnsafeEnabled { - mi := &file_pkg_grpc_proto_proxy_proto_msgTypes[11] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *UpstreamConfig) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*UpstreamConfig) ProtoMessage() {} - -func (x *UpstreamConfig) ProtoReflect() protoreflect.Message { - mi := &file_pkg_grpc_proto_proxy_proto_msgTypes[11] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use UpstreamConfig.ProtoReflect.Descriptor instead. -func (*UpstreamConfig) Descriptor() ([]byte, []int) { - return file_pkg_grpc_proto_proxy_proto_rawDescGZIP(), []int{11} -} - -func (x *UpstreamConfig) GetDomain() string { - if x != nil { - return x.Domain - } - return "" -} - -func (x *UpstreamConfig) GetPathMappings() map[string]string { - if x != nil { - return x.PathMappings - } - return nil -} - -// ProxyRequestData contains metadata about requests routed through the reverse proxy -type ProxyRequestData struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Timestamp *timestamppb.Timestamp `protobuf:"bytes,1,opt,name=timestamp,proto3" json:"timestamp,omitempty"` - ServiceId string `protobuf:"bytes,2,opt,name=service_id,json=serviceId,proto3" json:"service_id,omitempty"` - Path string `protobuf:"bytes,3,opt,name=path,proto3" json:"path,omitempty"` - DurationMs int64 `protobuf:"varint,4,opt,name=duration_ms,json=durationMs,proto3" json:"duration_ms,omitempty"` - Method string `protobuf:"bytes,5,opt,name=method,proto3" json:"method,omitempty"` // HTTP method (GET, POST, PUT, DELETE, etc.) - ResponseCode int32 `protobuf:"varint,6,opt,name=response_code,json=responseCode,proto3" json:"response_code,omitempty"` - SourceIp string `protobuf:"bytes,7,opt,name=source_ip,json=sourceIp,proto3" json:"source_ip,omitempty"` -} - -func (x *ProxyRequestData) Reset() { - *x = ProxyRequestData{} - if protoimpl.UnsafeEnabled { - mi := &file_pkg_grpc_proto_proxy_proto_msgTypes[12] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ProxyRequestData) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ProxyRequestData) ProtoMessage() {} - -func (x *ProxyRequestData) ProtoReflect() protoreflect.Message { - mi := &file_pkg_grpc_proto_proxy_proto_msgTypes[12] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ProxyRequestData.ProtoReflect.Descriptor instead. -func (*ProxyRequestData) Descriptor() ([]byte, []int) { - return file_pkg_grpc_proto_proxy_proto_rawDescGZIP(), []int{12} -} - -func (x *ProxyRequestData) GetTimestamp() *timestamppb.Timestamp { - if x != nil { - return x.Timestamp - } - return nil -} - -func (x *ProxyRequestData) GetServiceId() string { - if x != nil { - return x.ServiceId - } - return "" -} - -func (x *ProxyRequestData) GetPath() string { - if x != nil { - return x.Path - } - return "" -} - -func (x *ProxyRequestData) GetDurationMs() int64 { - if x != nil { - return x.DurationMs - } - return 0 -} - -func (x *ProxyRequestData) GetMethod() string { - if x != nil { - return x.Method - } - return "" -} - -func (x *ProxyRequestData) GetResponseCode() int32 { - if x != nil { - return x.ResponseCode - } - return 0 -} - -func (x *ProxyRequestData) GetSourceIp() string { - if x != nil { - return x.SourceIp - } - return "" -} - -var File_pkg_grpc_proto_proxy_proto protoreflect.FileDescriptor - -var file_pkg_grpc_proto_proxy_proto_rawDesc = []byte{ - 0x0a, 0x1a, 0x70, 0x6b, 0x67, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x2f, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x05, 0x70, 0x72, - 0x6f, 0x78, 0x79, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x89, 0x02, 0x0a, 0x0c, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x4d, 0x65, - 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x29, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x74, 0x73, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x50, 0x72, 0x6f, - 0x78, 0x79, 0x53, 0x74, 0x61, 0x74, 0x73, 0x48, 0x00, 0x52, 0x05, 0x73, 0x74, 0x61, 0x74, 0x73, - 0x12, 0x29, 0x0a, 0x05, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x11, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x45, 0x76, 0x65, - 0x6e, 0x74, 0x48, 0x00, 0x52, 0x05, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x12, 0x23, 0x0a, 0x03, 0x6c, - 0x6f, 0x67, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, - 0x2e, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x4c, 0x6f, 0x67, 0x48, 0x00, 0x52, 0x03, 0x6c, 0x6f, 0x67, - 0x12, 0x35, 0x0a, 0x09, 0x68, 0x65, 0x61, 0x72, 0x74, 0x62, 0x65, 0x61, 0x74, 0x18, 0x04, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x50, 0x72, 0x6f, 0x78, - 0x79, 0x48, 0x65, 0x61, 0x72, 0x74, 0x62, 0x65, 0x61, 0x74, 0x48, 0x00, 0x52, 0x09, 0x68, 0x65, - 0x61, 0x72, 0x74, 0x62, 0x65, 0x61, 0x74, 0x12, 0x3c, 0x0a, 0x0c, 0x72, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x5f, 0x64, 0x61, 0x74, 0x61, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, - 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x44, 0x61, 0x74, 0x61, 0x48, 0x00, 0x52, 0x0b, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x44, 0x61, 0x74, 0x61, 0x42, 0x09, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, - 0x22, 0xf2, 0x01, 0x0a, 0x0e, 0x43, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x4d, 0x65, 0x73, 0x73, - 0x61, 0x67, 0x65, 0x12, 0x2b, 0x0a, 0x05, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x43, 0x6f, 0x6e, 0x74, 0x72, - 0x6f, 0x6c, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x48, 0x00, 0x52, 0x05, 0x65, 0x76, 0x65, 0x6e, 0x74, - 0x12, 0x31, 0x0a, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x15, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x43, 0x6f, 0x6e, 0x74, 0x72, 0x6f, - 0x6c, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x48, 0x00, 0x52, 0x07, 0x63, 0x6f, 0x6d, 0x6d, - 0x61, 0x6e, 0x64, 0x12, 0x2e, 0x0a, 0x06, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x18, 0x03, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x43, 0x6f, 0x6e, 0x74, - 0x72, 0x6f, 0x6c, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x48, 0x00, 0x52, 0x06, 0x63, 0x6f, 0x6e, - 0x66, 0x69, 0x67, 0x12, 0x45, 0x0a, 0x0f, 0x65, 0x78, 0x70, 0x6f, 0x73, 0x65, 0x64, 0x5f, 0x73, - 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x70, - 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x45, 0x78, 0x70, 0x6f, 0x73, 0x65, 0x64, 0x53, 0x65, 0x72, 0x76, - 0x69, 0x63, 0x65, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x48, 0x00, 0x52, 0x0e, 0x65, 0x78, 0x70, 0x6f, - 0x73, 0x65, 0x64, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x42, 0x09, 0x0a, 0x07, 0x6d, 0x65, - 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0xc3, 0x03, 0x0a, 0x0a, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x53, - 0x74, 0x61, 0x74, 0x73, 0x12, 0x38, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, - 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, - 0x61, 0x6d, 0x70, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x25, - 0x0a, 0x0e, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x73, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0d, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x73, 0x12, 0x2d, 0x0a, 0x12, 0x61, 0x63, 0x74, 0x69, 0x76, 0x65, 0x5f, - 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, - 0x04, 0x52, 0x11, 0x61, 0x63, 0x74, 0x69, 0x76, 0x65, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, - 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x1d, 0x0a, 0x0a, 0x62, 0x79, 0x74, 0x65, 0x73, 0x5f, 0x73, 0x65, - 0x6e, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, 0x62, 0x79, 0x74, 0x65, 0x73, 0x53, - 0x65, 0x6e, 0x74, 0x12, 0x25, 0x0a, 0x0e, 0x62, 0x79, 0x74, 0x65, 0x73, 0x5f, 0x72, 0x65, 0x63, - 0x65, 0x69, 0x76, 0x65, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0d, 0x62, 0x79, 0x74, - 0x65, 0x73, 0x52, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x64, 0x12, 0x1b, 0x0a, 0x09, 0x63, 0x70, - 0x75, 0x5f, 0x75, 0x73, 0x61, 0x67, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x01, 0x52, 0x08, 0x63, - 0x70, 0x75, 0x55, 0x73, 0x61, 0x67, 0x65, 0x12, 0x26, 0x0a, 0x0f, 0x6d, 0x65, 0x6d, 0x6f, 0x72, - 0x79, 0x5f, 0x75, 0x73, 0x61, 0x67, 0x65, 0x5f, 0x6d, 0x62, 0x18, 0x07, 0x20, 0x01, 0x28, 0x01, - 0x52, 0x0d, 0x6d, 0x65, 0x6d, 0x6f, 0x72, 0x79, 0x55, 0x73, 0x61, 0x67, 0x65, 0x4d, 0x62, 0x12, - 0x55, 0x0a, 0x12, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x5f, 0x63, - 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x18, 0x08, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x27, 0x2e, 0x70, 0x72, - 0x6f, 0x78, 0x79, 0x2e, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x53, 0x74, 0x61, 0x74, 0x73, 0x2e, 0x53, - 0x74, 0x61, 0x74, 0x75, 0x73, 0x43, 0x6f, 0x64, 0x65, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x45, - 0x6e, 0x74, 0x72, 0x79, 0x52, 0x10, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x43, 0x6f, 0x64, 0x65, - 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x1a, 0x43, 0x0a, 0x15, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, - 0x43, 0x6f, 0x64, 0x65, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, - 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, - 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, - 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x8f, 0x03, 0x0a, 0x0a, - 0x50, 0x72, 0x6f, 0x78, 0x79, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x12, 0x38, 0x0a, 0x09, 0x74, 0x69, - 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, - 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, - 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, - 0x74, 0x61, 0x6d, 0x70, 0x12, 0x2f, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x0e, 0x32, 0x1b, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x50, 0x72, 0x6f, 0x78, 0x79, - 0x45, 0x76, 0x65, 0x6e, 0x74, 0x2e, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x52, - 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, - 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, - 0x3b, 0x0a, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x18, 0x04, 0x20, 0x03, 0x28, - 0x0b, 0x32, 0x1f, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x45, - 0x76, 0x65, 0x6e, 0x74, 0x2e, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x45, 0x6e, 0x74, - 0x72, 0x79, 0x52, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x1a, 0x3b, 0x0a, 0x0d, - 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, - 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, - 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, - 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x81, 0x01, 0x0a, 0x09, 0x45, 0x76, - 0x65, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, - 0x57, 0x4e, 0x10, 0x00, 0x12, 0x0b, 0x0a, 0x07, 0x53, 0x54, 0x41, 0x52, 0x54, 0x45, 0x44, 0x10, - 0x01, 0x12, 0x0b, 0x0a, 0x07, 0x53, 0x54, 0x4f, 0x50, 0x50, 0x45, 0x44, 0x10, 0x02, 0x12, 0x09, - 0x0a, 0x05, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x10, 0x03, 0x12, 0x17, 0x0a, 0x13, 0x42, 0x41, 0x43, - 0x4b, 0x45, 0x4e, 0x44, 0x5f, 0x55, 0x4e, 0x41, 0x56, 0x41, 0x49, 0x4c, 0x41, 0x42, 0x4c, 0x45, - 0x10, 0x04, 0x12, 0x15, 0x0a, 0x11, 0x42, 0x41, 0x43, 0x4b, 0x45, 0x4e, 0x44, 0x5f, 0x52, 0x45, - 0x43, 0x4f, 0x56, 0x45, 0x52, 0x45, 0x44, 0x10, 0x05, 0x12, 0x12, 0x0a, 0x0e, 0x43, 0x4f, 0x4e, - 0x46, 0x49, 0x47, 0x5f, 0x55, 0x50, 0x44, 0x41, 0x54, 0x45, 0x44, 0x10, 0x06, 0x22, 0xb4, 0x02, - 0x0a, 0x08, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x4c, 0x6f, 0x67, 0x12, 0x38, 0x0a, 0x09, 0x74, 0x69, - 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, - 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, - 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, - 0x74, 0x61, 0x6d, 0x70, 0x12, 0x2e, 0x0a, 0x05, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x0e, 0x32, 0x18, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x50, 0x72, 0x6f, 0x78, - 0x79, 0x4c, 0x6f, 0x67, 0x2e, 0x4c, 0x6f, 0x67, 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x52, 0x05, 0x6c, - 0x65, 0x76, 0x65, 0x6c, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, - 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x33, - 0x0a, 0x06, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1b, - 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x4c, 0x6f, 0x67, 0x2e, - 0x46, 0x69, 0x65, 0x6c, 0x64, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x06, 0x66, 0x69, 0x65, - 0x6c, 0x64, 0x73, 0x1a, 0x39, 0x0a, 0x0b, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x73, 0x45, 0x6e, 0x74, - 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x34, - 0x0a, 0x08, 0x4c, 0x6f, 0x67, 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x12, 0x09, 0x0a, 0x05, 0x44, 0x45, - 0x42, 0x55, 0x47, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x49, 0x4e, 0x46, 0x4f, 0x10, 0x01, 0x12, - 0x08, 0x0a, 0x04, 0x57, 0x41, 0x52, 0x4e, 0x10, 0x02, 0x12, 0x09, 0x0a, 0x05, 0x45, 0x52, 0x52, - 0x4f, 0x52, 0x10, 0x03, 0x22, 0x65, 0x0a, 0x0e, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x48, 0x65, 0x61, - 0x72, 0x74, 0x62, 0x65, 0x61, 0x74, 0x12, 0x38, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, - 0x61, 0x6d, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, - 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, - 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, - 0x12, 0x19, 0x0a, 0x08, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x07, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x49, 0x64, 0x22, 0x7d, 0x0a, 0x0c, 0x43, - 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x12, 0x38, 0x0a, 0x09, 0x74, - 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, - 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, - 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, - 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x19, 0x0a, 0x08, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x5f, 0x69, - 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x49, 0x64, - 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0xdd, 0x02, 0x0a, 0x0e, 0x43, - 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x1d, 0x0a, - 0x0a, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x09, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x49, 0x64, 0x12, 0x35, 0x0a, 0x04, - 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x21, 0x2e, 0x70, 0x72, 0x6f, - 0x78, 0x79, 0x2e, 0x43, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, - 0x64, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, - 0x79, 0x70, 0x65, 0x12, 0x45, 0x0a, 0x0a, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, - 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2e, - 0x43, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x50, - 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0a, - 0x70, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x73, 0x1a, 0x3d, 0x0a, 0x0f, 0x50, 0x61, - 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, - 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, - 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, - 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x6f, 0x0a, 0x0b, 0x43, 0x6f, 0x6d, - 0x6d, 0x61, 0x6e, 0x64, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x4e, 0x4b, 0x4e, - 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x11, 0x0a, 0x0d, 0x52, 0x45, 0x4c, 0x4f, 0x41, 0x44, 0x5f, - 0x43, 0x4f, 0x4e, 0x46, 0x49, 0x47, 0x10, 0x01, 0x12, 0x10, 0x0a, 0x0c, 0x45, 0x4e, 0x41, 0x42, - 0x4c, 0x45, 0x5f, 0x44, 0x45, 0x42, 0x55, 0x47, 0x10, 0x02, 0x12, 0x11, 0x0a, 0x0d, 0x44, 0x49, - 0x53, 0x41, 0x42, 0x4c, 0x45, 0x5f, 0x44, 0x45, 0x42, 0x55, 0x47, 0x10, 0x03, 0x12, 0x0d, 0x0a, - 0x09, 0x47, 0x45, 0x54, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x53, 0x10, 0x04, 0x12, 0x0c, 0x0a, 0x08, - 0x53, 0x48, 0x55, 0x54, 0x44, 0x4f, 0x57, 0x4e, 0x10, 0x05, 0x22, 0xb3, 0x01, 0x0a, 0x0d, 0x43, - 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x25, 0x0a, 0x0e, - 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x56, 0x65, 0x72, 0x73, - 0x69, 0x6f, 0x6e, 0x12, 0x3e, 0x0a, 0x08, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x18, - 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x43, 0x6f, - 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x53, 0x65, 0x74, 0x74, - 0x69, 0x6e, 0x67, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x08, 0x73, 0x65, 0x74, 0x74, 0x69, - 0x6e, 0x67, 0x73, 0x1a, 0x3b, 0x0a, 0x0d, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x45, - 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, - 0x22, 0xdd, 0x02, 0x0a, 0x13, 0x45, 0x78, 0x70, 0x6f, 0x73, 0x65, 0x64, 0x53, 0x65, 0x72, 0x76, - 0x69, 0x63, 0x65, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x12, 0x38, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, - 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, - 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, - 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, - 0x6d, 0x70, 0x12, 0x38, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, - 0x32, 0x24, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x45, 0x78, 0x70, 0x6f, 0x73, 0x65, 0x64, - 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x2e, 0x45, 0x76, 0x65, - 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x1d, 0x0a, 0x0a, - 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x09, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x49, 0x64, 0x12, 0x32, 0x0a, 0x0b, 0x70, - 0x65, 0x65, 0x72, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x11, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x50, 0x65, 0x65, 0x72, 0x43, 0x6f, 0x6e, - 0x66, 0x69, 0x67, 0x52, 0x0a, 0x70, 0x65, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, - 0x3e, 0x0a, 0x0f, 0x75, 0x70, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x5f, 0x63, 0x6f, 0x6e, 0x66, - 0x69, 0x67, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, - 0x2e, 0x55, 0x70, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, - 0x0e, 0x75, 0x70, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x22, - 0x3f, 0x0a, 0x09, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0b, 0x0a, 0x07, - 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x0b, 0x0a, 0x07, 0x43, 0x52, 0x45, - 0x41, 0x54, 0x45, 0x44, 0x10, 0x01, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x50, 0x44, 0x41, 0x54, 0x45, - 0x44, 0x10, 0x02, 0x12, 0x0b, 0x0a, 0x07, 0x52, 0x45, 0x4d, 0x4f, 0x56, 0x45, 0x44, 0x10, 0x03, - 0x22, 0xd1, 0x01, 0x0a, 0x0a, 0x50, 0x65, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, - 0x17, 0x0a, 0x07, 0x70, 0x65, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x06, 0x70, 0x65, 0x65, 0x72, 0x49, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x70, 0x75, 0x62, 0x6c, - 0x69, 0x63, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x70, 0x75, - 0x62, 0x6c, 0x69, 0x63, 0x4b, 0x65, 0x79, 0x12, 0x1f, 0x0a, 0x0b, 0x61, 0x6c, 0x6c, 0x6f, 0x77, - 0x65, 0x64, 0x5f, 0x69, 0x70, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0a, 0x61, 0x6c, - 0x6c, 0x6f, 0x77, 0x65, 0x64, 0x49, 0x70, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x65, 0x6e, 0x64, 0x70, - 0x6f, 0x69, 0x6e, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x65, 0x6e, 0x64, 0x70, - 0x6f, 0x69, 0x6e, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x74, 0x75, 0x6e, 0x6e, 0x65, 0x6c, 0x5f, 0x69, - 0x70, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x74, 0x75, 0x6e, 0x6e, 0x65, 0x6c, 0x49, - 0x70, 0x12, 0x31, 0x0a, 0x14, 0x70, 0x65, 0x72, 0x73, 0x69, 0x73, 0x74, 0x65, 0x6e, 0x74, 0x5f, - 0x6b, 0x65, 0x65, 0x70, 0x61, 0x6c, 0x69, 0x76, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0d, 0x52, - 0x13, 0x70, 0x65, 0x72, 0x73, 0x69, 0x73, 0x74, 0x65, 0x6e, 0x74, 0x4b, 0x65, 0x65, 0x70, 0x61, - 0x6c, 0x69, 0x76, 0x65, 0x22, 0xb7, 0x01, 0x0a, 0x0e, 0x55, 0x70, 0x73, 0x74, 0x72, 0x65, 0x61, - 0x6d, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x16, 0x0a, 0x06, 0x64, 0x6f, 0x6d, 0x61, 0x69, - 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x12, - 0x4c, 0x0a, 0x0d, 0x70, 0x61, 0x74, 0x68, 0x5f, 0x6d, 0x61, 0x70, 0x70, 0x69, 0x6e, 0x67, 0x73, - 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x27, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x55, - 0x70, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x50, 0x61, - 0x74, 0x68, 0x4d, 0x61, 0x70, 0x70, 0x69, 0x6e, 0x67, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, - 0x0c, 0x70, 0x61, 0x74, 0x68, 0x4d, 0x61, 0x70, 0x70, 0x69, 0x6e, 0x67, 0x73, 0x1a, 0x3f, 0x0a, - 0x11, 0x50, 0x61, 0x74, 0x68, 0x4d, 0x61, 0x70, 0x70, 0x69, 0x6e, 0x67, 0x73, 0x45, 0x6e, 0x74, - 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0xfa, - 0x01, 0x0a, 0x10, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x44, - 0x61, 0x74, 0x61, 0x12, 0x38, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, - 0x6d, 0x70, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x1d, 0x0a, - 0x0a, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x09, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, - 0x70, 0x61, 0x74, 0x68, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x70, 0x61, 0x74, 0x68, - 0x12, 0x1f, 0x0a, 0x0b, 0x64, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x6d, 0x73, 0x18, - 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0a, 0x64, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4d, - 0x73, 0x12, 0x16, 0x0a, 0x06, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x06, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x23, 0x0a, 0x0d, 0x72, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x05, - 0x52, 0x0c, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x1b, - 0x0a, 0x09, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x69, 0x70, 0x18, 0x07, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x08, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x49, 0x70, 0x32, 0x48, 0x0a, 0x0c, 0x50, - 0x72, 0x6f, 0x78, 0x79, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x38, 0x0a, 0x06, 0x53, - 0x74, 0x72, 0x65, 0x61, 0x6d, 0x12, 0x15, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x43, 0x6f, - 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x1a, 0x13, 0x2e, 0x70, - 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, - 0x65, 0x28, 0x01, 0x30, 0x01, 0x42, 0x33, 0x5a, 0x31, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, - 0x63, 0x6f, 0x6d, 0x2f, 0x6e, 0x65, 0x74, 0x62, 0x69, 0x72, 0x64, 0x69, 0x6f, 0x2f, 0x6e, 0x65, - 0x74, 0x62, 0x69, 0x72, 0x64, 0x2f, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2f, 0x70, 0x6b, 0x67, 0x2f, - 0x67, 0x72, 0x70, 0x63, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x33, -} - -var ( - file_pkg_grpc_proto_proxy_proto_rawDescOnce sync.Once - file_pkg_grpc_proto_proxy_proto_rawDescData = file_pkg_grpc_proto_proxy_proto_rawDesc -) - -func file_pkg_grpc_proto_proxy_proto_rawDescGZIP() []byte { - file_pkg_grpc_proto_proxy_proto_rawDescOnce.Do(func() { - file_pkg_grpc_proto_proxy_proto_rawDescData = protoimpl.X.CompressGZIP(file_pkg_grpc_proto_proxy_proto_rawDescData) - }) - return file_pkg_grpc_proto_proxy_proto_rawDescData -} - -var file_pkg_grpc_proto_proxy_proto_enumTypes = make([]protoimpl.EnumInfo, 4) -var file_pkg_grpc_proto_proxy_proto_msgTypes = make([]protoimpl.MessageInfo, 19) -var file_pkg_grpc_proto_proxy_proto_goTypes = []interface{}{ - (ProxyEvent_EventType)(0), // 0: proxy.ProxyEvent.EventType - (ProxyLog_LogLevel)(0), // 1: proxy.ProxyLog.LogLevel - (ControlCommand_CommandType)(0), // 2: proxy.ControlCommand.CommandType - (ExposedServiceEvent_EventType)(0), // 3: proxy.ExposedServiceEvent.EventType - (*ProxyMessage)(nil), // 4: proxy.ProxyMessage - (*ControlMessage)(nil), // 5: proxy.ControlMessage - (*ProxyStats)(nil), // 6: proxy.ProxyStats - (*ProxyEvent)(nil), // 7: proxy.ProxyEvent - (*ProxyLog)(nil), // 8: proxy.ProxyLog - (*ProxyHeartbeat)(nil), // 9: proxy.ProxyHeartbeat - (*ControlEvent)(nil), // 10: proxy.ControlEvent - (*ControlCommand)(nil), // 11: proxy.ControlCommand - (*ControlConfig)(nil), // 12: proxy.ControlConfig - (*ExposedServiceEvent)(nil), // 13: proxy.ExposedServiceEvent - (*PeerConfig)(nil), // 14: proxy.PeerConfig - (*UpstreamConfig)(nil), // 15: proxy.UpstreamConfig - (*ProxyRequestData)(nil), // 16: proxy.ProxyRequestData - nil, // 17: proxy.ProxyStats.StatusCodeCountsEntry - nil, // 18: proxy.ProxyEvent.MetadataEntry - nil, // 19: proxy.ProxyLog.FieldsEntry - nil, // 20: proxy.ControlCommand.ParametersEntry - nil, // 21: proxy.ControlConfig.SettingsEntry - nil, // 22: proxy.UpstreamConfig.PathMappingsEntry - (*timestamppb.Timestamp)(nil), // 23: google.protobuf.Timestamp -} -var file_pkg_grpc_proto_proxy_proto_depIdxs = []int32{ - 6, // 0: proxy.ProxyMessage.stats:type_name -> proxy.ProxyStats - 7, // 1: proxy.ProxyMessage.event:type_name -> proxy.ProxyEvent - 8, // 2: proxy.ProxyMessage.log:type_name -> proxy.ProxyLog - 9, // 3: proxy.ProxyMessage.heartbeat:type_name -> proxy.ProxyHeartbeat - 16, // 4: proxy.ProxyMessage.request_data:type_name -> proxy.ProxyRequestData - 10, // 5: proxy.ControlMessage.event:type_name -> proxy.ControlEvent - 11, // 6: proxy.ControlMessage.command:type_name -> proxy.ControlCommand - 12, // 7: proxy.ControlMessage.config:type_name -> proxy.ControlConfig - 13, // 8: proxy.ControlMessage.exposed_service:type_name -> proxy.ExposedServiceEvent - 23, // 9: proxy.ProxyStats.timestamp:type_name -> google.protobuf.Timestamp - 17, // 10: proxy.ProxyStats.status_code_counts:type_name -> proxy.ProxyStats.StatusCodeCountsEntry - 23, // 11: proxy.ProxyEvent.timestamp:type_name -> google.protobuf.Timestamp - 0, // 12: proxy.ProxyEvent.type:type_name -> proxy.ProxyEvent.EventType - 18, // 13: proxy.ProxyEvent.metadata:type_name -> proxy.ProxyEvent.MetadataEntry - 23, // 14: proxy.ProxyLog.timestamp:type_name -> google.protobuf.Timestamp - 1, // 15: proxy.ProxyLog.level:type_name -> proxy.ProxyLog.LogLevel - 19, // 16: proxy.ProxyLog.fields:type_name -> proxy.ProxyLog.FieldsEntry - 23, // 17: proxy.ProxyHeartbeat.timestamp:type_name -> google.protobuf.Timestamp - 23, // 18: proxy.ControlEvent.timestamp:type_name -> google.protobuf.Timestamp - 2, // 19: proxy.ControlCommand.type:type_name -> proxy.ControlCommand.CommandType - 20, // 20: proxy.ControlCommand.parameters:type_name -> proxy.ControlCommand.ParametersEntry - 21, // 21: proxy.ControlConfig.settings:type_name -> proxy.ControlConfig.SettingsEntry - 23, // 22: proxy.ExposedServiceEvent.timestamp:type_name -> google.protobuf.Timestamp - 3, // 23: proxy.ExposedServiceEvent.type:type_name -> proxy.ExposedServiceEvent.EventType - 14, // 24: proxy.ExposedServiceEvent.peer_config:type_name -> proxy.PeerConfig - 15, // 25: proxy.ExposedServiceEvent.upstream_config:type_name -> proxy.UpstreamConfig - 22, // 26: proxy.UpstreamConfig.path_mappings:type_name -> proxy.UpstreamConfig.PathMappingsEntry - 23, // 27: proxy.ProxyRequestData.timestamp:type_name -> google.protobuf.Timestamp - 5, // 28: proxy.ProxyService.Stream:input_type -> proxy.ControlMessage - 4, // 29: proxy.ProxyService.Stream:output_type -> proxy.ProxyMessage - 29, // [29:30] is the sub-list for method output_type - 28, // [28:29] is the sub-list for method input_type - 28, // [28:28] is the sub-list for extension type_name - 28, // [28:28] is the sub-list for extension extendee - 0, // [0:28] is the sub-list for field type_name -} - -func init() { file_pkg_grpc_proto_proxy_proto_init() } -func file_pkg_grpc_proto_proxy_proto_init() { - if File_pkg_grpc_proto_proxy_proto != nil { - return - } - if !protoimpl.UnsafeEnabled { - file_pkg_grpc_proto_proxy_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ProxyMessage); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_pkg_grpc_proto_proxy_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ControlMessage); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_pkg_grpc_proto_proxy_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ProxyStats); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_pkg_grpc_proto_proxy_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ProxyEvent); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_pkg_grpc_proto_proxy_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ProxyLog); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_pkg_grpc_proto_proxy_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ProxyHeartbeat); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_pkg_grpc_proto_proxy_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ControlEvent); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_pkg_grpc_proto_proxy_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ControlCommand); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_pkg_grpc_proto_proxy_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ControlConfig); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_pkg_grpc_proto_proxy_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ExposedServiceEvent); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_pkg_grpc_proto_proxy_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*PeerConfig); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_pkg_grpc_proto_proxy_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*UpstreamConfig); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_pkg_grpc_proto_proxy_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ProxyRequestData); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - file_pkg_grpc_proto_proxy_proto_msgTypes[0].OneofWrappers = []interface{}{ - (*ProxyMessage_Stats)(nil), - (*ProxyMessage_Event)(nil), - (*ProxyMessage_Log)(nil), - (*ProxyMessage_Heartbeat)(nil), - (*ProxyMessage_RequestData)(nil), - } - file_pkg_grpc_proto_proxy_proto_msgTypes[1].OneofWrappers = []interface{}{ - (*ControlMessage_Event)(nil), - (*ControlMessage_Command)(nil), - (*ControlMessage_Config)(nil), - (*ControlMessage_ExposedService)(nil), - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_pkg_grpc_proto_proxy_proto_rawDesc, - NumEnums: 4, - NumMessages: 19, - NumExtensions: 0, - NumServices: 1, - }, - GoTypes: file_pkg_grpc_proto_proxy_proto_goTypes, - DependencyIndexes: file_pkg_grpc_proto_proxy_proto_depIdxs, - EnumInfos: file_pkg_grpc_proto_proxy_proto_enumTypes, - MessageInfos: file_pkg_grpc_proto_proxy_proto_msgTypes, - }.Build() - File_pkg_grpc_proto_proxy_proto = out.File - file_pkg_grpc_proto_proxy_proto_rawDesc = nil - file_pkg_grpc_proto_proxy_proto_goTypes = nil - file_pkg_grpc_proto_proxy_proto_depIdxs = nil -} diff --git a/proxy/pkg/grpc/proto/proxy.proto b/proxy/pkg/grpc/proto/proxy.proto deleted file mode 100644 index 52a0e9c6e..000000000 --- a/proxy/pkg/grpc/proto/proxy.proto +++ /dev/null @@ -1,159 +0,0 @@ -syntax = "proto3"; - -package proxy; - -option go_package = "github.com/netbirdio/netbird/proxy/pkg/grpc/proto"; - -import "google/protobuf/timestamp.proto"; - -// ProxyService defines the bidirectional streaming service -// The proxy runs this service, control service connects as client -service ProxyService { - // Stream establishes a bidirectional stream between proxy and control service - // Control service (client) sends ControlMessage, Proxy (server) sends ProxyMessage - rpc Stream(stream ControlMessage) returns (stream ProxyMessage); -} - -// ProxyMessage represents messages sent from proxy to control service -message ProxyMessage { - oneof message { - ProxyStats stats = 1; - ProxyEvent event = 2; - ProxyLog log = 3; - ProxyHeartbeat heartbeat = 4; - ProxyRequestData request_data = 5; - } -} - -// ControlMessage represents messages sent from control service to proxy -message ControlMessage { - oneof message { - ControlEvent event = 1; - ControlCommand command = 2; - ControlConfig config = 3; - ExposedServiceEvent exposed_service = 4; - } -} - -// ProxyStats contains proxy statistics -message ProxyStats { - google.protobuf.Timestamp timestamp = 1; - uint64 total_requests = 2; - uint64 active_connections = 3; - uint64 bytes_sent = 4; - uint64 bytes_received = 5; - double cpu_usage = 6; - double memory_usage_mb = 7; - map status_code_counts = 8; -} - -// ProxyEvent represents events from the proxy -message ProxyEvent { - google.protobuf.Timestamp timestamp = 1; - EventType type = 2; - string message = 3; - map metadata = 4; - - enum EventType { - UNKNOWN = 0; - STARTED = 1; - STOPPED = 2; - ERROR = 3; - BACKEND_UNAVAILABLE = 4; - BACKEND_RECOVERED = 5; - CONFIG_UPDATED = 6; - } -} - -// ProxyLog represents log entries -message ProxyLog { - google.protobuf.Timestamp timestamp = 1; - LogLevel level = 2; - string message = 3; - map fields = 4; - - enum LogLevel { - DEBUG = 0; - INFO = 1; - WARN = 2; - ERROR = 3; - } -} - -// ProxyHeartbeat is sent periodically to keep connection alive -message ProxyHeartbeat { - google.protobuf.Timestamp timestamp = 1; - string proxy_id = 2; -} - -// ControlEvent represents events from control service -message ControlEvent { - google.protobuf.Timestamp timestamp = 1; - string event_id = 2; - string message = 3; -} - -// ControlCommand represents commands sent to proxy -message ControlCommand { - string command_id = 1; - CommandType type = 2; - map parameters = 3; - - enum CommandType { - UNKNOWN = 0; - RELOAD_CONFIG = 1; - ENABLE_DEBUG = 2; - DISABLE_DEBUG = 3; - GET_STATS = 4; - SHUTDOWN = 5; - } -} - -// ControlConfig contains configuration updates from control service -message ControlConfig { - string config_version = 1; - map settings = 2; -} - -// ExposedServiceEvent represents exposed service lifecycle events -message ExposedServiceEvent { - google.protobuf.Timestamp timestamp = 1; - EventType type = 2; - string service_id = 3; - PeerConfig peer_config = 4; - UpstreamConfig upstream_config = 5; - - enum EventType { - UNKNOWN = 0; - CREATED = 1; - UPDATED = 2; - REMOVED = 3; - } -} - -// PeerConfig contains WireGuard peer configuration -message PeerConfig { - string peer_id = 1; - string public_key = 2; - repeated string allowed_ips = 3; - string endpoint = 4; - string tunnel_ip = 5; - uint32 persistent_keepalive = 6; -} - -// UpstreamConfig contains reverse proxy upstream configuration -message UpstreamConfig { - string domain = 1; - map path_mappings = 2; // path -> port -} - -// ProxyRequestData contains metadata about requests routed through the reverse proxy -message ProxyRequestData { - google.protobuf.Timestamp timestamp = 1; - string service_id = 2; - string path = 3; - int64 duration_ms = 4; - string method = 5; // HTTP method (GET, POST, PUT, DELETE, etc.) - int32 response_code = 6; - string source_ip = 7; -} \ No newline at end of file diff --git a/proxy/pkg/grpc/proto/proxy_grpc.pb.go b/proxy/pkg/grpc/proto/proxy_grpc.pb.go deleted file mode 100644 index d0088a790..000000000 --- a/proxy/pkg/grpc/proto/proxy_grpc.pb.go +++ /dev/null @@ -1,137 +0,0 @@ -// 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 { - // Stream establishes a bidirectional stream between proxy and control service - // Control service (client) sends ControlMessage, Proxy (server) sends ProxyMessage - 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], "/proxy.ProxyService/Stream", opts...) - if err != nil { - return nil, err - } - x := &proxyServiceStreamClient{stream} - return x, nil -} - -type ProxyService_StreamClient interface { - Send(*ControlMessage) error - Recv() (*ProxyMessage, error) - grpc.ClientStream -} - -type proxyServiceStreamClient struct { - grpc.ClientStream -} - -func (x *proxyServiceStreamClient) Send(m *ControlMessage) error { - return x.ClientStream.SendMsg(m) -} - -func (x *proxyServiceStreamClient) Recv() (*ProxyMessage, error) { - m := new(ProxyMessage) - 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 { - // Stream establishes a bidirectional stream between proxy and control service - // Control service (client) sends ControlMessage, Proxy (server) sends ProxyMessage - 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(*ProxyMessage) error - Recv() (*ControlMessage, error) - grpc.ServerStream -} - -type proxyServiceStreamServer struct { - grpc.ServerStream -} - -func (x *proxyServiceStreamServer) Send(m *ProxyMessage) error { - return x.ServerStream.SendMsg(m) -} - -func (x *proxyServiceStreamServer) Recv() (*ControlMessage, error) { - m := new(ControlMessage) - 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: "proxy.ProxyService", - HandlerType: (*ProxyServiceServer)(nil), - Methods: []grpc.MethodDesc{}, - Streams: []grpc.StreamDesc{ - { - StreamName: "Stream", - Handler: _ProxyService_Stream_Handler, - ServerStreams: true, - ClientStreams: true, - }, - }, - Metadata: "pkg/grpc/proto/proxy.proto", -} diff --git a/proxy/pkg/grpc/server.go b/proxy/pkg/grpc/server.go deleted file mode 100644 index 21c3d68ba..000000000 --- a/proxy/pkg/grpc/server.go +++ /dev/null @@ -1,274 +0,0 @@ -package grpc - -import ( - "context" - "fmt" - "net" - "sync" - "time" - - log "github.com/sirupsen/logrus" - "google.golang.org/grpc" - "google.golang.org/grpc/keepalive" - - pb "github.com/netbirdio/netbird/proxy/pkg/grpc/proto" -) - -// StreamHandler handles incoming messages from control service -type StreamHandler interface { - HandleControlEvent(ctx context.Context, event *pb.ControlEvent) error - HandleControlCommand(ctx context.Context, command *pb.ControlCommand) error - HandleControlConfig(ctx context.Context, config *pb.ControlConfig) error - HandleExposedServiceEvent(ctx context.Context, event *pb.ExposedServiceEvent) error -} - -// Server represents the gRPC server running on the proxy -type Server struct { - pb.UnimplementedProxyServiceServer - - listenAddr string - grpcServer *grpc.Server - handler StreamHandler - - mu sync.RWMutex - streams map[string]*StreamContext - isRunning bool -} - -// StreamContext holds the context for each active stream -type StreamContext struct { - stream pb.ProxyService_StreamServer - sendChan chan *pb.ProxyMessage - ctx context.Context - cancel context.CancelFunc - controlID string // ID of the connected control service -} - -// Config holds gRPC server configuration -type Config struct { - ListenAddr string - Handler StreamHandler -} - -// NewServer creates a new gRPC server -func NewServer(config Config) *Server { - return &Server{ - listenAddr: config.ListenAddr, - handler: config.Handler, - streams: make(map[string]*StreamContext), - } -} - -// Start starts the gRPC server -func (s *Server) Start() error { - s.mu.Lock() - if s.isRunning { - s.mu.Unlock() - return fmt.Errorf("gRPC server already running") - } - s.isRunning = true - s.mu.Unlock() - - lis, err := net.Listen("tcp", s.listenAddr) - if err != nil { - s.mu.Lock() - s.isRunning = false - s.mu.Unlock() - return fmt.Errorf("failed to listen: %w", err) - } - - s.grpcServer = grpc.NewServer( - grpc.KeepaliveParams(keepalive.ServerParameters{ - Time: 30 * time.Second, - Timeout: 10 * time.Second, - }), - grpc.KeepaliveEnforcementPolicy(keepalive.EnforcementPolicy{ - MinTime: 10 * time.Second, - PermitWithoutStream: true, - }), - ) - - pb.RegisterProxyServiceServer(s.grpcServer, s) - - log.Infof("gRPC server listening on %s", s.listenAddr) - - if err := s.grpcServer.Serve(lis); err != nil { - s.mu.Lock() - s.isRunning = false - s.mu.Unlock() - return fmt.Errorf("failed to serve: %w", err) - } - - return nil -} - -// Stop gracefully stops the gRPC server -func (s *Server) Stop(ctx context.Context) error { - s.mu.Lock() - if !s.isRunning { - s.mu.Unlock() - return fmt.Errorf("gRPC server not running") - } - s.mu.Unlock() - - log.Info("Stopping gRPC server...") - - s.mu.Lock() - for _, streamCtx := range s.streams { - streamCtx.cancel() - close(streamCtx.sendChan) - } - s.streams = make(map[string]*StreamContext) - s.mu.Unlock() - - stopped := make(chan struct{}) - go func() { - s.grpcServer.GracefulStop() - close(stopped) - }() - - select { - case <-stopped: - log.Info("gRPC server stopped gracefully") - case <-ctx.Done(): - log.Warn("gRPC server graceful stop timeout, forcing stop") - s.grpcServer.Stop() - } - - s.mu.Lock() - s.isRunning = false - s.mu.Unlock() - - return nil -} - -// Stream implements the bidirectional streaming RPC -// The control service connects as client, proxy is server -// Control service sends ControlMessage, Proxy sends ProxyMessage -func (s *Server) Stream(stream pb.ProxyService_StreamServer) error { - ctx, cancel := context.WithCancel(stream.Context()) - defer cancel() - - controlID := fmt.Sprintf("control-%d", time.Now().Unix()) - - streamCtx := &StreamContext{ - stream: stream, - sendChan: make(chan *pb.ProxyMessage, 100), - ctx: ctx, - cancel: cancel, - controlID: controlID, - } - - s.mu.Lock() - s.streams[controlID] = streamCtx - s.mu.Unlock() - - log.Infof("Control service connected: %s", controlID) - - sendDone := make(chan error, 1) - go s.sendLoop(streamCtx, sendDone) - - recvDone := make(chan error, 1) - go s.receiveLoop(streamCtx, recvDone) - - select { - case err := <-sendDone: - log.Infof("Control service %s send loop ended: %v", controlID, err) - return err - case err := <-recvDone: - log.Infof("Control service %s receive loop ended: %v", controlID, err) - return err - case <-ctx.Done(): - log.Infof("Control service %s context done: %v", controlID, ctx.Err()) - return ctx.Err() - } -} - -// sendLoop handles sending ProxyMessages to the control service -func (s *Server) sendLoop(streamCtx *StreamContext, done chan<- error) { - for { - select { - case msg, ok := <-streamCtx.sendChan: - if !ok { - done <- nil - return - } - - if err := streamCtx.stream.Send(msg); err != nil { - log.Errorf("Failed to send message to control service: %v", err) - done <- err - return - } - - case <-streamCtx.ctx.Done(): - done <- streamCtx.ctx.Err() - return - } - } -} - -// receiveLoop handles receiving ControlMessages from the control service -func (s *Server) receiveLoop(streamCtx *StreamContext, done chan<- error) { - for { - controlMsg, err := streamCtx.stream.Recv() - if err != nil { - log.Debugf("Stream receive error: %v", err) - done <- err - return - } - - switch m := controlMsg.Message.(type) { - case *pb.ControlMessage_Event: - if s.handler != nil { - if err := s.handler.HandleControlEvent(streamCtx.ctx, m.Event); err != nil { - log.Errorf("Failed to handle control event: %v", err) - } - } - - case *pb.ControlMessage_Command: - if s.handler != nil { - if err := s.handler.HandleControlCommand(streamCtx.ctx, m.Command); err != nil { - log.Errorf("Failed to handle control command: %v", err) - } - } - - case *pb.ControlMessage_Config: - if s.handler != nil { - if err := s.handler.HandleControlConfig(streamCtx.ctx, m.Config); err != nil { - log.Errorf("Failed to handle control config: %v", err) - } - } - - case *pb.ControlMessage_ExposedService: - if s.handler != nil { - if err := s.handler.HandleExposedServiceEvent(streamCtx.ctx, m.ExposedService); err != nil { - log.Errorf("Failed to handle exposed service event: %v", err) - } - } - - default: - log.Warnf("Received unknown control message type: %T", m) - } - } -} - -// SendProxyMessage sends a ProxyMessage to all connected control services -func (s *Server) SendProxyMessage(msg *pb.ProxyMessage) { - s.mu.RLock() - defer s.mu.RUnlock() - - for _, streamCtx := range s.streams { - select { - case streamCtx.sendChan <- msg: - default: - log.Warn("Send channel full, dropping message") - } - } -} - -// GetActiveStreams returns the number of active streams -func (s *Server) GetActiveStreams() int { - s.mu.RLock() - defer s.mu.RUnlock() - return len(s.streams) -} diff --git a/proxy/pkg/proxy/server.go b/proxy/pkg/proxy/server.go index 00f85ff34..bd9658575 100644 --- a/proxy/pkg/proxy/server.go +++ b/proxy/pkg/proxy/server.go @@ -4,7 +4,6 @@ import ( "context" "fmt" "sync" - "time" log "github.com/sirupsen/logrus" "google.golang.org/protobuf/types/known/timestamppb" @@ -13,13 +12,13 @@ import ( "github.com/netbirdio/netbird/proxy/internal/auth/methods" "github.com/netbirdio/netbird/proxy/internal/reverseproxy" grpcpkg "github.com/netbirdio/netbird/proxy/pkg/grpc" - pb "github.com/netbirdio/netbird/proxy/pkg/grpc/proto" + pb "github.com/netbirdio/netbird/shared/management/proto" ) -// Server represents the reverse proxy server with integrated gRPC control server +// Server represents the reverse proxy server with integrated gRPC client type Server struct { config Config - grpcServer *grpcpkg.Server + grpcClient *grpcpkg.Client proxy *reverseproxy.Proxy mu sync.RWMutex @@ -69,7 +68,6 @@ type UpstreamConfig struct { // NewServer creates a new reverse proxy server instance func NewServer(config Config) (*Server, error) { - // Validate config if err := config.Validate(); err != nil { return nil, fmt.Errorf("invalid configuration: %w", err) } @@ -86,41 +84,41 @@ func NewServer(config Config) (*Server, error) { exposedServices: make(map[string]*ExposedServiceConfig), } - // Create reverse proxy using embedded config proxy, err := reverseproxy.New(config.ReverseProxy) if err != nil { return nil, fmt.Errorf("failed to create reverse proxy: %w", err) } - - // Set request data callback - proxy.SetRequestCallback(func(data reverseproxy.RequestData) { - log.WithFields(log.Fields{ - "service_id": data.ServiceID, - "host": data.Host, - "method": data.Method, - "path": data.Path, - "response_code": data.ResponseCode, - "duration_ms": data.DurationMs, - "source_ip": data.SourceIP, - "auth_mechanism": data.AuthMechanism, - "user_id": data.UserID, - "auth_success": data.AuthSuccess, - }).Info("Access log received") - }) - if err != nil { - return nil, fmt.Errorf("failed to create reverse proxy: %w", err) - } server.proxy = proxy - // Create gRPC server if enabled - if config.EnableGRPC && config.GRPCListenAddress != "" { - grpcConfig := grpcpkg.Config{ - ListenAddr: config.GRPCListenAddress, - Handler: server, // Server implements StreamHandler interface - } - server.grpcServer = grpcpkg.NewServer(grpcConfig) + if config.ReverseProxy.ManagementURL == "" { + return nil, fmt.Errorf("management URL is required") } + grpcClient := grpcpkg.NewClient(grpcpkg.ClientConfig{ + ProxyID: config.ProxyID, + ManagementURL: config.ReverseProxy.ManagementURL, + ServiceUpdateHandler: server.handleServiceUpdate, + }) + server.grpcClient = grpcClient + + // Set request data callback to send access logs to management + proxy.SetRequestCallback(func(data reverseproxy.RequestData) { + accessLog := &pb.ProxyRequestData{ + Timestamp: timestamppb.Now(), + ServiceId: data.ServiceID, + Host: data.Host, + Path: data.Path, + DurationMs: data.DurationMs, + Method: data.Method, + ResponseCode: data.ResponseCode, + SourceIp: data.SourceIP, + AuthMechanism: data.AuthMechanism, + UserId: data.UserID, + AuthSuccess: data.AuthSuccess, + } + server.grpcClient.SendAccessLog(accessLog) + }) + return server, nil } @@ -136,7 +134,6 @@ func (s *Server) Start() error { log.Infof("Starting proxy reverse proxy server on %s", s.config.ReverseProxy.ListenAddress) - // Start reverse proxy if err := s.proxy.Start(); err != nil { s.mu.Lock() s.isRunning = false @@ -144,47 +141,20 @@ func (s *Server) Start() error { return fmt.Errorf("failed to start reverse proxy: %w", err) } - // Start gRPC server if configured - if s.grpcServer != nil { + s.mu.Lock() + s.grpcRunning = true + s.mu.Unlock() + + if err := s.grpcClient.Start(); err != nil { s.mu.Lock() - s.grpcRunning = true + s.isRunning = false + s.grpcRunning = false s.mu.Unlock() - - go func() { - log.Infof("Starting gRPC control server on %s", s.config.GRPCListenAddress) - if err := s.grpcServer.Start(); err != nil { - log.Errorf("gRPC server error: %v", err) - s.mu.Lock() - s.grpcRunning = false - s.mu.Unlock() - } - }() - - // Send started event - time.Sleep(100 * time.Millisecond) // Give gRPC server time to start - s.sendProxyEvent(pb.ProxyEvent_STARTED, "Proxy server started") + return fmt.Errorf("failed to start gRPC client: %w", err) } - // Enable Bearer authentication for the test route - // OIDC configuration is set globally in the proxy config above - testAuthConfig := &auth.Config{ - Bearer: &methods.BearerConfig{ - Enabled: true, - }, - } - - // Register main protected route with auth - // The /auth/callback endpoint is automatically handled globally for all routes - if err := s.proxy.AddRoute( - &reverseproxy.RouteConfig{ - ID: "test", - Domain: "test.netbird.io", - PathMappings: map[string]string{"/": "100.116.118.156:8181"}, - AuthConfig: testAuthConfig, - SetupKey: "88B2382A-93D2-47A9-A80F-D0055D741636", - }); err != nil { - log.Warn("Failed to add test route: ", err) - } + log.Info("Proxy started and connected to management") + log.Info("Waiting for service configurations from management...") <-s.shutdownCtx.Done() return nil @@ -208,17 +178,12 @@ func (s *Server) Stop(ctx context.Context) error { defer cancel() } - // Send stopped event before shutdown - if s.grpcServer != nil && s.grpcRunning { - s.sendProxyEvent(pb.ProxyEvent_STOPPED, "Proxy server shutting down") - } + var proxyErr, grpcErr error - var caddyErr, grpcErr error - - // Shutdown gRPC server first - if s.grpcServer != nil && s.grpcRunning { - if err := s.grpcServer.Stop(ctx); err != nil { - grpcErr = fmt.Errorf("gRPC server shutdown failed: %w", err) + // Stop gRPC client first + if s.grpcRunning { + if err := s.grpcClient.Stop(); err != nil { + grpcErr = fmt.Errorf("gRPC client shutdown failed: %w", err) log.Error(grpcErr) } s.mu.Lock() @@ -228,16 +193,16 @@ func (s *Server) Stop(ctx context.Context) error { // Shutdown reverse proxy if err := s.proxy.Stop(ctx); err != nil { - caddyErr = fmt.Errorf("reverse proxy shutdown failed: %w", err) - log.Error(caddyErr) + proxyErr = fmt.Errorf("reverse proxy shutdown failed: %w", err) + log.Error(proxyErr) } s.mu.Lock() s.isRunning = false s.mu.Unlock() - if caddyErr != nil { - return caddyErr + if proxyErr != nil { + return proxyErr } if grpcErr != nil { return grpcErr @@ -259,119 +224,173 @@ func (s *Server) GetConfig() Config { return s.config } -// GetStats returns a copy of current statistics -func (s *Server) GetStats() *pb.ProxyStats { - s.stats.mu.RLock() - defer s.stats.mu.RUnlock() - - return &pb.ProxyStats{ - Timestamp: timestamppb.Now(), - TotalRequests: s.stats.totalRequests, - ActiveConnections: s.stats.activeConns, - BytesSent: s.stats.bytesSent, - BytesReceived: s.stats.bytesReceived, - } -} - -// StreamHandler interface implementation - -// HandleControlEvent handles incoming control events -// This is where ExposedService events will be routed -func (s *Server) HandleControlEvent(ctx context.Context, event *pb.ControlEvent) error { +// handleServiceUpdate processes service updates from management +func (s *Server) handleServiceUpdate(update *pb.ServiceUpdate) error { log.WithFields(log.Fields{ - "event_id": event.EventId, - "message": event.Message, - }).Info("Received control event") + "service_id": update.ServiceId, + "type": update.Type.String(), + }).Info("Received service update from management") - // TODO: Parse event type and route to appropriate handler - // if event.Type == "ExposedServiceCreated" { - // return s.handleExposedServiceCreated(ctx, event) - // } else if event.Type == "ExposedServiceUpdated" { - // return s.handleExposedServiceUpdated(ctx, event) - // } else if event.Type == "ExposedServiceRemoved" { - // return s.handleExposedServiceRemoved(ctx, event) - // } + switch update.Type { + case pb.ServiceUpdate_CREATED: + if update.Service == nil { + return fmt.Errorf("service config is nil for CREATED update") + } + return s.addServiceFromProto(update.Service) - return nil -} + case pb.ServiceUpdate_UPDATED: + if update.Service == nil { + return fmt.Errorf("service config is nil for UPDATED update") + } + return s.updateServiceFromProto(update.Service) -// HandleControlCommand handles incoming control commands -func (s *Server) HandleControlCommand(ctx context.Context, command *pb.ControlCommand) error { - log.WithFields(log.Fields{ - "command_id": command.CommandId, - "type": command.Type.String(), - }).Info("Received control command") - - switch command.Type { - case pb.ControlCommand_GET_STATS: - // Stats are automatically sent, just log - log.Debug("Stats requested via command") - case pb.ControlCommand_RELOAD_CONFIG: - log.Info("Config reload requested (not implemented yet)") - case pb.ControlCommand_ENABLE_DEBUG: - log.SetLevel(log.DebugLevel) - log.Info("Debug logging enabled") - case pb.ControlCommand_DISABLE_DEBUG: - log.SetLevel(log.InfoLevel) - log.Info("Debug logging disabled") - case pb.ControlCommand_SHUTDOWN: - log.Warn("Shutdown command received") - go func() { - time.Sleep(1 * time.Second) - s.cancelFunc() // Trigger graceful shutdown - }() - } - - return nil -} - -// HandleControlConfig handles incoming configuration updates -func (s *Server) HandleControlConfig(ctx context.Context, config *pb.ControlConfig) error { - log.WithFields(log.Fields{ - "config_version": config.ConfigVersion, - "settings": config.Settings, - }).Info("Received config update") - return nil -} - -// HandleExposedServiceEvent handles exposed service lifecycle events -func (s *Server) HandleExposedServiceEvent(ctx context.Context, event *pb.ExposedServiceEvent) error { - log.WithFields(log.Fields{ - "service_id": event.ServiceId, - "type": event.Type.String(), - }).Info("Received exposed service event") - - // Convert proto types to internal types - peerConfig := &PeerConfig{ - PeerID: event.PeerConfig.PeerId, - PublicKey: event.PeerConfig.PublicKey, - AllowedIPs: event.PeerConfig.AllowedIps, - Endpoint: event.PeerConfig.Endpoint, - TunnelIP: event.PeerConfig.TunnelIp, - } - - upstreamConfig := &UpstreamConfig{ - Domain: event.UpstreamConfig.Domain, - PathMappings: event.UpstreamConfig.PathMappings, - } - - // Route to appropriate handler based on event type - switch event.Type { - case pb.ExposedServiceEvent_CREATED: - return s.handleExposedServiceCreated(event.ServiceId, peerConfig, upstreamConfig) - - case pb.ExposedServiceEvent_UPDATED: - return s.handleExposedServiceUpdated(event.ServiceId, peerConfig, upstreamConfig) - - case pb.ExposedServiceEvent_REMOVED: - return s.handleExposedServiceRemoved(event.ServiceId) + case pb.ServiceUpdate_REMOVED: + return s.removeService(update.ServiceId) default: - return fmt.Errorf("unknown exposed service event type: %v", event.Type) + return fmt.Errorf("unknown service update type: %v", update.Type) } } -// Exposed Service Handlers +// addServiceFromProto adds a service from proto config +func (s *Server) addServiceFromProto(serviceConfig *pb.ExposedServiceConfig) error { + s.mu.Lock() + defer s.mu.Unlock() + + // Check if service already exists + if _, exists := s.exposedServices[serviceConfig.Id]; exists { + log.Warnf("Service %s already exists, updating instead", serviceConfig.Id) + return s.updateServiceFromProtoLocked(serviceConfig) + } + + log.WithFields(log.Fields{ + "service_id": serviceConfig.Id, + "domain": serviceConfig.Domain, + }).Info("Adding service from management") + + // Convert proto auth config to internal auth config + var authConfig *auth.Config + if serviceConfig.Auth != nil { + authConfig = convertProtoAuthConfig(serviceConfig.Auth) + } + + // Add route to proxy + route := &reverseproxy.RouteConfig{ + ID: serviceConfig.Id, + Domain: serviceConfig.Domain, + PathMappings: serviceConfig.PathMappings, + AuthConfig: authConfig, + SetupKey: serviceConfig.SetupKey, + } + + if err := s.proxy.AddRoute(route); err != nil { + return fmt.Errorf("failed to add route: %w", err) + } + + // Store service config (simplified, no peer config for now) + s.exposedServices[serviceConfig.Id] = &ExposedServiceConfig{ + ServiceID: serviceConfig.Id, + UpstreamConfig: &UpstreamConfig{ + Domain: serviceConfig.Domain, + PathMappings: serviceConfig.PathMappings, + }, + } + + log.Infof("Service %s added successfully", serviceConfig.Id) + return nil +} + +// updateServiceFromProto updates an existing service from proto config +func (s *Server) updateServiceFromProto(serviceConfig *pb.ExposedServiceConfig) error { + s.mu.Lock() + defer s.mu.Unlock() + return s.updateServiceFromProtoLocked(serviceConfig) +} + +func (s *Server) updateServiceFromProtoLocked(serviceConfig *pb.ExposedServiceConfig) error { + log.WithFields(log.Fields{ + "service_id": serviceConfig.Id, + "domain": serviceConfig.Domain, + }).Info("Updating service from management") + + // Convert proto auth config to internal auth config + var authConfig *auth.Config + if serviceConfig.Auth != nil { + authConfig = convertProtoAuthConfig(serviceConfig.Auth) + } + + // Update route in proxy + route := &reverseproxy.RouteConfig{ + ID: serviceConfig.Id, + Domain: serviceConfig.Domain, + PathMappings: serviceConfig.PathMappings, + AuthConfig: authConfig, + SetupKey: serviceConfig.SetupKey, + } + + if err := s.proxy.UpdateRoute(route); err != nil { + return fmt.Errorf("failed to update route: %w", err) + } + + // Update service config + s.exposedServices[serviceConfig.Id] = &ExposedServiceConfig{ + ServiceID: serviceConfig.Id, + UpstreamConfig: &UpstreamConfig{ + Domain: serviceConfig.Domain, + PathMappings: serviceConfig.PathMappings, + }, + } + + log.Infof("Service %s updated successfully", serviceConfig.Id) + return nil +} + +// removeService removes a service +func (s *Server) removeService(serviceID string) error { + s.mu.Lock() + defer s.mu.Unlock() + + log.WithFields(log.Fields{ + "service_id": serviceID, + }).Info("Removing service from management") + + // Remove route from proxy + if err := s.proxy.RemoveRoute(serviceID); err != nil { + return fmt.Errorf("failed to remove route: %w", err) + } + + // Remove service config + delete(s.exposedServices, serviceID) + + log.Infof("Service %s removed successfully", serviceID) + return nil +} + +// convertProtoAuthConfig converts proto auth config to internal auth config +func convertProtoAuthConfig(protoAuth *pb.AuthConfig) *auth.Config { + authConfig := &auth.Config{} + + switch authType := protoAuth.AuthType.(type) { + case *pb.AuthConfig_BasicAuth: + authConfig.BasicAuth = &methods.BasicAuthConfig{ + Username: authType.BasicAuth.Username, + Password: authType.BasicAuth.Password, + } + case *pb.AuthConfig_PinAuth: + authConfig.PIN = &methods.PINConfig{ + PIN: authType.PinAuth.Pin, + Header: authType.PinAuth.Header, + } + case *pb.AuthConfig_BearerAuth: + authConfig.Bearer = &methods.BearerConfig{ + Enabled: authType.BearerAuth.Enabled, + } + } + + return authConfig +} + +// Exposed Service Handlers (deprecated - keeping for backwards compatibility) // handleExposedServiceCreated handles the creation of a new exposed service func (s *Server) handleExposedServiceCreated(serviceID string, peerConfig *PeerConfig, upstreamConfig *UpstreamConfig) error { @@ -538,17 +557,6 @@ func (s *Server) GetExposedService(serviceID string) (*ExposedServiceConfig, err return service, nil } -// Helper methods - -func (s *Server) sendProxyEvent(eventType pb.ProxyEvent_EventType, message string) { - // This would typically be called to send events - // The actual sending happens via the gRPC stream - log.WithFields(log.Fields{ - "type": eventType.String(), - "message": message, - }).Debug("Proxy event") -} - // Stats methods func (s *Stats) IncrementRequests() { diff --git a/shared/management/proto/generate.sh b/shared/management/proto/generate.sh index 207630ae7..7cb0f75a5 100755 --- a/shared/management/proto/generate.sh +++ b/shared/management/proto/generate.sh @@ -14,4 +14,5 @@ cd "$script_path" go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.26 go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.1 protoc -I ./ ./management.proto --go_out=../ --go-grpc_out=../ +protoc -I ./ ./proxy_service.proto --go_out=../ --go-grpc_out=../ cd "$old_pwd" diff --git a/shared/management/proto/management.pb.go b/shared/management/proto/management.pb.go index 84b74bf8c..dd5c9e1fc 100644 --- a/shared/management/proto/management.pb.go +++ b/shared/management/proto/management.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.26.0 -// protoc v6.33.3 +// protoc v6.33.0 // source: management.proto package proto @@ -1607,17 +1607,19 @@ func (x *FlowConfig) GetDnsCollection() bool { return false } -// JWTConfig represents JWT authentication configuration +// JWTConfig represents JWT authentication configuration for validating tokens. type JWTConfig struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Issuer string `protobuf:"bytes,1,opt,name=issuer,proto3" json:"issuer,omitempty"` + Issuer string `protobuf:"bytes,1,opt,name=issuer,proto3" json:"issuer,omitempty"` + // Deprecated: audience is kept for backwards compatibility only. Use audiences instead in the client code but populate this field. Audience string `protobuf:"bytes,2,opt,name=audience,proto3" json:"audience,omitempty"` KeysLocation string `protobuf:"bytes,3,opt,name=keysLocation,proto3" json:"keysLocation,omitempty"` MaxTokenAge int64 `protobuf:"varint,4,opt,name=maxTokenAge,proto3" json:"maxTokenAge,omitempty"` - // audiences + // audiences contains the list of valid audiences for JWT validation. + // Tokens matching any audience in this list are considered valid. Audiences []string `protobuf:"bytes,5,rep,name=audiences,proto3" json:"audiences,omitempty"` }