diff --git a/BUILD.bazel b/BUILD.bazel index a142069715..0f04ad4d1e 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -1,5 +1,4 @@ -load("@bazel_skylib//rules:common_settings.bzl", "bool_flag") -load("@bazel_skylib//rules:common_settings.bzl", "string_flag") +load("@bazel_skylib//rules:common_settings.bzl", "bool_flag", "string_flag") load("@bazel_gazelle//:def.bzl", "gazelle") load("@rules_pkg//:pkg.bzl", "pkg_tar") load("@io_bazel_rules_go//go:def.bzl", "nogo") @@ -130,9 +129,10 @@ gazelle( go_lint_config( name = "go_lint_config", exclude_filter = [ - "mock_", - ".pb.go", + ".connect.go", ".gen.go", + ".pb.go", + "mock_", ], visibility = [ "//visibility:public", @@ -250,6 +250,11 @@ write_source_files( "//dispatcher/mgmtapi:write_files", "//doc/command:write_files", "//gateway/mgmtapi:write_files", + "//pkg/proto/control_plane/v1/control_planeconnect:write_files", + "//pkg/proto/daemon/v1/daemonconnect:write_files", + "//pkg/proto/discovery/v1/discoveryconnect:write_files", + "//pkg/proto/gateway/v1/gatewayconnect:write_files", + "//pkg/proto/hidden_segment/v1/hidden_segmentconnect:write_files", "//private/ca/api:write_files", "//private/mgmtapi/cppki/api:write_files", "//private/mgmtapi/health/api:write_files", diff --git a/Makefile b/Makefile index 25e994ea58..52aa4a9acc 100644 --- a/Makefile +++ b/Makefile @@ -79,7 +79,7 @@ protobuf: rm -f pkg/proto/*/*.pb.go cp -r bazel-bin/pkg/proto/*/go_default_library_/github.com/scionproto/scion/pkg/proto/* pkg/proto cp -r bazel-bin/pkg/proto/*/*/go_default_library_/github.com/scionproto/scion/pkg/proto/* pkg/proto - chmod 0644 pkg/proto/*/*.pb.go + chmod 0644 pkg/proto/*/*.pb.go pkg/proto/*/*/*.pb.go mocks: tools/gomocks.py @@ -142,7 +142,7 @@ lint-protobuf: lint-protobuf-buf lint-protobuf-buf: $(info ==> $@) - @tools/quiet bazel run --config=quiet @buf_bin//file:buf -- check lint + @tools/quiet bazel run --config=quiet @buf//:buf -- lint $(PWD) --path $(PWD)/proto lint-openapi: lint-openapi-spectral diff --git a/WORKSPACE b/WORKSPACE index 53b4207e4f..64c7aaac18 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -2,7 +2,7 @@ workspace( name = "com_github_scionproto_scion", ) -load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive", "http_file") +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") # linter rules http_archive( @@ -46,6 +46,8 @@ aspect_bazel_lib_register_toolchains() # Bazel rules for Golang http_archive( name = "io_bazel_rules_go", + patch_args = ["-p0"], + patches = ["//patches:io_bazel_rules_go/import.patch"], sha256 = "af47f30e9cbd70ae34e49866e201b3f77069abb111183f2c0297e7e74ba6bbc0", urls = [ "https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.47.0/rules_go-v0.47.0.zip", @@ -204,6 +206,15 @@ load("@tester_debian10_packages//:packages.bzl", tester_debian_packages_install_ tester_debian_packages_install_deps() +# Buf CLI +http_archive( + name = "buf", + build_file_content = "exports_files([\"buf\"])", + sha256 = "16253b6702dd447ef941b01c9c386a2ab7c8d20bbbc86a5efa5953270f6c9010", + strip_prefix = "buf/bin", + urls = ["https://github.com/bufbuild/buf/releases/download/v1.32.2/buf-Linux-x86_64.tar.gz"], +) + # protobuf/gRPC http_archive( name = "rules_proto_grpc", @@ -236,16 +247,6 @@ http_archive( ], ) -http_file( - name = "buf_bin", - downloaded_file_path = "buf", - executable = True, - sha256 = "5faf15ed0a3cd4bd0919ba5fcb95334c1fd2ba32770df289d615138fa188d36a", - urls = [ - "https://github.com/bufbuild/buf/releases/download/v0.20.5/buf-Linux-x86_64", - ], -) - load("//tools/lint/python:deps.bzl", "python_lint_deps") python_lint_deps(python_interpreter) diff --git a/buf.yaml b/buf.yaml index a6b06a30cf..0e3ca5a8ce 100644 --- a/buf.yaml +++ b/buf.yaml @@ -1,8 +1,7 @@ -build: - roots: - - . - excludes: - - anapaya/protobuf +version: v1 +breaking: + use: + - FILE lint: use: - DEFAULT diff --git a/go.mod b/go.mod index b830145a55..b11d4d5b6d 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,7 @@ module github.com/scionproto/scion require ( + connectrpc.com/connect v1.16.2 github.com/antlr/antlr4/runtime/Go/antlr v0.0.0-20220209173558-ad29539cd2e9 github.com/bazelbuild/rules_go v0.47.1 github.com/buildkite/go-buildkite/v2 v2.9.0 diff --git a/go.sum b/go.sum index e1191c31f9..f0f6ba9db9 100644 --- a/go.sum +++ b/go.sum @@ -1,4 +1,6 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +connectrpc.com/connect v1.16.2 h1:ybd6y+ls7GOlb7Bh5C8+ghA6SvCBajHwxssO2CGFjqE= +connectrpc.com/connect v1.16.2/go.mod h1:n2kgwskMHXC+lVqb18wngEpF95ldBHXjZYJussz5FRc= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= diff --git a/go_deps.bzl b/go_deps.bzl index 0baba4fc0b..fa9fb3e625 100644 --- a/go_deps.bzl +++ b/go_deps.bzl @@ -19,6 +19,12 @@ def go_deps(): sum = "h1:YGD4H+SuIOOqsyoLOpZDWcieM28W47/zRO7f+9V3nvo=", version = "v0.4.5", ) + go_repository( + name = "com_connectrpc_connect", + importpath = "connectrpc.com/connect", + sum = "h1:ybd6y+ls7GOlb7Bh5C8+ghA6SvCBajHwxssO2CGFjqE=", + version = "v1.16.2", + ) go_repository( name = "com_github_ajstarks_svgo", importpath = "github.com/ajstarks/svgo", diff --git a/patches/BUILD.bazel b/patches/BUILD.bazel new file mode 100644 index 0000000000..7bf75c425d --- /dev/null +++ b/patches/BUILD.bazel @@ -0,0 +1 @@ +exports_files(glob(["**/*.patch"])) diff --git a/patches/io_bazel_rules_go/import.patch b/patches/io_bazel_rules_go/import.patch new file mode 100644 index 0000000000..a0527ccb4c --- /dev/null +++ b/patches/io_bazel_rules_go/import.patch @@ -0,0 +1,34 @@ +Patch is copied from https://github.com/abitofhelp/connect-go-example/blob/main/import.patch + +It is required because of the issue described in https://github.com/bazelbuild/rules_go/issues/3951. +The connect protoc plugin generates files in a sub-directory, which is not supported by the rules_go. +This patch allows to override the import path of the generated files. + +There is also an upstream discussion whether there should be support for generating files in +the directory itself rather than in a sub-directory. See: +https://github.com/connectrpc/connect-go/discussions/310 + +--- proto/def.bzl ++++ proto/def.bzl +@@ -123,8 +123,12 @@ def _go_proto_library_impl(ctx): + imports = get_imports(ctx.attr, go.importpath), + importpath = go.importpath, + )) ++ importpath = None ++ if ctx.attr.overrideimportpath: ++ importpath = ctx.attr.overrideimportpath + library = go.new_library( + go, ++ importpath = importpath, + resolver = _proto_library_to_source, + srcs = go_srcs, + ) +@@ -164,6 +168,7 @@ go_proto_library = rule( + "importpath": attr.string(), + "importmap": attr.string(), + "importpath_aliases": attr.string_list(), # experimental, undocumented ++ "overrideimportpath": attr.string(), + "embed": attr.label_list(providers = [GoLibrary]), + "gc_goopts": attr.string_list(), + "compiler": attr.label(providers = [GoProtoCompiler]), +-- diff --git a/pkg/proto/control_plane/experimental/seg_detached_extensions.pb.go b/pkg/proto/control_plane/experimental/seg_detached_extensions.pb.go old mode 100755 new mode 100644 diff --git a/pkg/proto/control_plane/v1/control_planeconnect/BUILD.bazel b/pkg/proto/control_plane/v1/control_planeconnect/BUILD.bazel new file mode 100644 index 0000000000..8b99864ab3 --- /dev/null +++ b/pkg/proto/control_plane/v1/control_planeconnect/BUILD.bazel @@ -0,0 +1,12 @@ +load("//tools/proto:connect.bzl", "go_connect_library") + +go_connect_library( + name = "go_default_library", + files = [ + "cppki.connect.go", + "drkey.connect.go", + "renewal.connect.go", + "seg.connect.go", + ], + proto = "control_plane", +) diff --git a/pkg/proto/control_plane/v1/control_planeconnect/cppki.connect.go b/pkg/proto/control_plane/v1/control_planeconnect/cppki.connect.go new file mode 100644 index 0000000000..0bbe8fd68a --- /dev/null +++ b/pkg/proto/control_plane/v1/control_planeconnect/cppki.connect.go @@ -0,0 +1,146 @@ +// Code generated by protoc-gen-connect-go. DO NOT EDIT. +// +// Source: proto/control_plane/v1/cppki.proto + +package control_planeconnect + +import ( + connect "connectrpc.com/connect" + context "context" + errors "errors" + control_plane "github.com/scionproto/scion/pkg/proto/control_plane" + http "net/http" + strings "strings" +) + +// This is a compile-time assertion to ensure that this generated file and the connect package are +// compatible. If you get a compiler error that this constant is not defined, this code was +// generated with a version of connect newer than the one compiled into your binary. You can fix the +// problem by either regenerating this code with an older version of connect or updating the connect +// version compiled into your binary. +const _ = connect.IsAtLeastVersion1_13_0 + +const ( + // TrustMaterialServiceName is the fully-qualified name of the TrustMaterialService service. + TrustMaterialServiceName = "proto.control_plane.v1.TrustMaterialService" +) + +// These constants are the fully-qualified names of the RPCs defined in this package. They're +// exposed at runtime as Spec.Procedure and as the final two segments of the HTTP route. +// +// Note that these are different from the fully-qualified method names used by +// google.golang.org/protobuf/reflect/protoreflect. To convert from these constants to +// reflection-formatted method names, remove the leading slash and convert the remaining slash to a +// period. +const ( + // TrustMaterialServiceChainsProcedure is the fully-qualified name of the TrustMaterialService's + // Chains RPC. + TrustMaterialServiceChainsProcedure = "/proto.control_plane.v1.TrustMaterialService/Chains" + // TrustMaterialServiceTRCProcedure is the fully-qualified name of the TrustMaterialService's TRC + // RPC. + TrustMaterialServiceTRCProcedure = "/proto.control_plane.v1.TrustMaterialService/TRC" +) + +// These variables are the protoreflect.Descriptor objects for the RPCs defined in this package. +var ( + trustMaterialServiceServiceDescriptor = control_plane.File_proto_control_plane_v1_cppki_proto.Services().ByName("TrustMaterialService") + trustMaterialServiceChainsMethodDescriptor = trustMaterialServiceServiceDescriptor.Methods().ByName("Chains") + trustMaterialServiceTRCMethodDescriptor = trustMaterialServiceServiceDescriptor.Methods().ByName("TRC") +) + +// TrustMaterialServiceClient is a client for the proto.control_plane.v1.TrustMaterialService +// service. +type TrustMaterialServiceClient interface { + Chains(context.Context, *connect.Request[control_plane.ChainsRequest]) (*connect.Response[control_plane.ChainsResponse], error) + TRC(context.Context, *connect.Request[control_plane.TRCRequest]) (*connect.Response[control_plane.TRCResponse], error) +} + +// NewTrustMaterialServiceClient constructs a client for the +// proto.control_plane.v1.TrustMaterialService service. By default, it uses the Connect protocol +// with the binary Protobuf Codec, asks for gzipped responses, and sends uncompressed requests. To +// use the gRPC or gRPC-Web protocols, supply the connect.WithGRPC() or connect.WithGRPCWeb() +// options. +// +// The URL supplied here should be the base URL for the Connect or gRPC server (for example, +// http://api.acme.com or https://acme.com/grpc). +func NewTrustMaterialServiceClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) TrustMaterialServiceClient { + baseURL = strings.TrimRight(baseURL, "/") + return &trustMaterialServiceClient{ + chains: connect.NewClient[control_plane.ChainsRequest, control_plane.ChainsResponse]( + httpClient, + baseURL+TrustMaterialServiceChainsProcedure, + connect.WithSchema(trustMaterialServiceChainsMethodDescriptor), + connect.WithClientOptions(opts...), + ), + tRC: connect.NewClient[control_plane.TRCRequest, control_plane.TRCResponse]( + httpClient, + baseURL+TrustMaterialServiceTRCProcedure, + connect.WithSchema(trustMaterialServiceTRCMethodDescriptor), + connect.WithClientOptions(opts...), + ), + } +} + +// trustMaterialServiceClient implements TrustMaterialServiceClient. +type trustMaterialServiceClient struct { + chains *connect.Client[control_plane.ChainsRequest, control_plane.ChainsResponse] + tRC *connect.Client[control_plane.TRCRequest, control_plane.TRCResponse] +} + +// Chains calls proto.control_plane.v1.TrustMaterialService.Chains. +func (c *trustMaterialServiceClient) Chains(ctx context.Context, req *connect.Request[control_plane.ChainsRequest]) (*connect.Response[control_plane.ChainsResponse], error) { + return c.chains.CallUnary(ctx, req) +} + +// TRC calls proto.control_plane.v1.TrustMaterialService.TRC. +func (c *trustMaterialServiceClient) TRC(ctx context.Context, req *connect.Request[control_plane.TRCRequest]) (*connect.Response[control_plane.TRCResponse], error) { + return c.tRC.CallUnary(ctx, req) +} + +// TrustMaterialServiceHandler is an implementation of the +// proto.control_plane.v1.TrustMaterialService service. +type TrustMaterialServiceHandler interface { + Chains(context.Context, *connect.Request[control_plane.ChainsRequest]) (*connect.Response[control_plane.ChainsResponse], error) + TRC(context.Context, *connect.Request[control_plane.TRCRequest]) (*connect.Response[control_plane.TRCResponse], error) +} + +// NewTrustMaterialServiceHandler builds an HTTP handler from the service implementation. It returns +// the path on which to mount the handler and the handler itself. +// +// By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf +// and JSON codecs. They also support gzip compression. +func NewTrustMaterialServiceHandler(svc TrustMaterialServiceHandler, opts ...connect.HandlerOption) (string, http.Handler) { + trustMaterialServiceChainsHandler := connect.NewUnaryHandler( + TrustMaterialServiceChainsProcedure, + svc.Chains, + connect.WithSchema(trustMaterialServiceChainsMethodDescriptor), + connect.WithHandlerOptions(opts...), + ) + trustMaterialServiceTRCHandler := connect.NewUnaryHandler( + TrustMaterialServiceTRCProcedure, + svc.TRC, + connect.WithSchema(trustMaterialServiceTRCMethodDescriptor), + connect.WithHandlerOptions(opts...), + ) + return "/proto.control_plane.v1.TrustMaterialService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + switch r.URL.Path { + case TrustMaterialServiceChainsProcedure: + trustMaterialServiceChainsHandler.ServeHTTP(w, r) + case TrustMaterialServiceTRCProcedure: + trustMaterialServiceTRCHandler.ServeHTTP(w, r) + default: + http.NotFound(w, r) + } + }) +} + +// UnimplementedTrustMaterialServiceHandler returns CodeUnimplemented from all methods. +type UnimplementedTrustMaterialServiceHandler struct{} + +func (UnimplementedTrustMaterialServiceHandler) Chains(context.Context, *connect.Request[control_plane.ChainsRequest]) (*connect.Response[control_plane.ChainsResponse], error) { + return nil, connect.NewError(connect.CodeUnimplemented, errors.New("proto.control_plane.v1.TrustMaterialService.Chains is not implemented")) +} + +func (UnimplementedTrustMaterialServiceHandler) TRC(context.Context, *connect.Request[control_plane.TRCRequest]) (*connect.Response[control_plane.TRCResponse], error) { + return nil, connect.NewError(connect.CodeUnimplemented, errors.New("proto.control_plane.v1.TrustMaterialService.TRC is not implemented")) +} diff --git a/pkg/proto/control_plane/v1/control_planeconnect/drkey.connect.go b/pkg/proto/control_plane/v1/control_planeconnect/drkey.connect.go new file mode 100644 index 0000000000..ae395ecee9 --- /dev/null +++ b/pkg/proto/control_plane/v1/control_planeconnect/drkey.connect.go @@ -0,0 +1,310 @@ +// Code generated by protoc-gen-connect-go. DO NOT EDIT. +// +// Source: proto/control_plane/v1/drkey.proto + +package control_planeconnect + +import ( + connect "connectrpc.com/connect" + context "context" + errors "errors" + control_plane "github.com/scionproto/scion/pkg/proto/control_plane" + http "net/http" + strings "strings" +) + +// This is a compile-time assertion to ensure that this generated file and the connect package are +// compatible. If you get a compiler error that this constant is not defined, this code was +// generated with a version of connect newer than the one compiled into your binary. You can fix the +// problem by either regenerating this code with an older version of connect or updating the connect +// version compiled into your binary. +const _ = connect.IsAtLeastVersion1_13_0 + +const ( + // DRKeyInterServiceName is the fully-qualified name of the DRKeyInterService service. + DRKeyInterServiceName = "proto.control_plane.v1.DRKeyInterService" + // DRKeyIntraServiceName is the fully-qualified name of the DRKeyIntraService service. + DRKeyIntraServiceName = "proto.control_plane.v1.DRKeyIntraService" +) + +// These constants are the fully-qualified names of the RPCs defined in this package. They're +// exposed at runtime as Spec.Procedure and as the final two segments of the HTTP route. +// +// Note that these are different from the fully-qualified method names used by +// google.golang.org/protobuf/reflect/protoreflect. To convert from these constants to +// reflection-formatted method names, remove the leading slash and convert the remaining slash to a +// period. +const ( + // DRKeyInterServiceDRKeyLevel1Procedure is the fully-qualified name of the DRKeyInterService's + // DRKeyLevel1 RPC. + DRKeyInterServiceDRKeyLevel1Procedure = "/proto.control_plane.v1.DRKeyInterService/DRKeyLevel1" + // DRKeyIntraServiceDRKeyIntraLevel1Procedure is the fully-qualified name of the DRKeyIntraService's + // DRKeyIntraLevel1 RPC. + DRKeyIntraServiceDRKeyIntraLevel1Procedure = "/proto.control_plane.v1.DRKeyIntraService/DRKeyIntraLevel1" + // DRKeyIntraServiceDRKeyASHostProcedure is the fully-qualified name of the DRKeyIntraService's + // DRKeyASHost RPC. + DRKeyIntraServiceDRKeyASHostProcedure = "/proto.control_plane.v1.DRKeyIntraService/DRKeyASHost" + // DRKeyIntraServiceDRKeyHostASProcedure is the fully-qualified name of the DRKeyIntraService's + // DRKeyHostAS RPC. + DRKeyIntraServiceDRKeyHostASProcedure = "/proto.control_plane.v1.DRKeyIntraService/DRKeyHostAS" + // DRKeyIntraServiceDRKeyHostHostProcedure is the fully-qualified name of the DRKeyIntraService's + // DRKeyHostHost RPC. + DRKeyIntraServiceDRKeyHostHostProcedure = "/proto.control_plane.v1.DRKeyIntraService/DRKeyHostHost" + // DRKeyIntraServiceDRKeySecretValueProcedure is the fully-qualified name of the DRKeyIntraService's + // DRKeySecretValue RPC. + DRKeyIntraServiceDRKeySecretValueProcedure = "/proto.control_plane.v1.DRKeyIntraService/DRKeySecretValue" +) + +// These variables are the protoreflect.Descriptor objects for the RPCs defined in this package. +var ( + dRKeyInterServiceServiceDescriptor = control_plane.File_proto_control_plane_v1_drkey_proto.Services().ByName("DRKeyInterService") + dRKeyInterServiceDRKeyLevel1MethodDescriptor = dRKeyInterServiceServiceDescriptor.Methods().ByName("DRKeyLevel1") + dRKeyIntraServiceServiceDescriptor = control_plane.File_proto_control_plane_v1_drkey_proto.Services().ByName("DRKeyIntraService") + dRKeyIntraServiceDRKeyIntraLevel1MethodDescriptor = dRKeyIntraServiceServiceDescriptor.Methods().ByName("DRKeyIntraLevel1") + dRKeyIntraServiceDRKeyASHostMethodDescriptor = dRKeyIntraServiceServiceDescriptor.Methods().ByName("DRKeyASHost") + dRKeyIntraServiceDRKeyHostASMethodDescriptor = dRKeyIntraServiceServiceDescriptor.Methods().ByName("DRKeyHostAS") + dRKeyIntraServiceDRKeyHostHostMethodDescriptor = dRKeyIntraServiceServiceDescriptor.Methods().ByName("DRKeyHostHost") + dRKeyIntraServiceDRKeySecretValueMethodDescriptor = dRKeyIntraServiceServiceDescriptor.Methods().ByName("DRKeySecretValue") +) + +// DRKeyInterServiceClient is a client for the proto.control_plane.v1.DRKeyInterService service. +type DRKeyInterServiceClient interface { + DRKeyLevel1(context.Context, *connect.Request[control_plane.DRKeyLevel1Request]) (*connect.Response[control_plane.DRKeyLevel1Response], error) +} + +// NewDRKeyInterServiceClient constructs a client for the proto.control_plane.v1.DRKeyInterService +// service. By default, it uses the Connect protocol with the binary Protobuf Codec, asks for +// gzipped responses, and sends uncompressed requests. To use the gRPC or gRPC-Web protocols, supply +// the connect.WithGRPC() or connect.WithGRPCWeb() options. +// +// The URL supplied here should be the base URL for the Connect or gRPC server (for example, +// http://api.acme.com or https://acme.com/grpc). +func NewDRKeyInterServiceClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) DRKeyInterServiceClient { + baseURL = strings.TrimRight(baseURL, "/") + return &dRKeyInterServiceClient{ + dRKeyLevel1: connect.NewClient[control_plane.DRKeyLevel1Request, control_plane.DRKeyLevel1Response]( + httpClient, + baseURL+DRKeyInterServiceDRKeyLevel1Procedure, + connect.WithSchema(dRKeyInterServiceDRKeyLevel1MethodDescriptor), + connect.WithClientOptions(opts...), + ), + } +} + +// dRKeyInterServiceClient implements DRKeyInterServiceClient. +type dRKeyInterServiceClient struct { + dRKeyLevel1 *connect.Client[control_plane.DRKeyLevel1Request, control_plane.DRKeyLevel1Response] +} + +// DRKeyLevel1 calls proto.control_plane.v1.DRKeyInterService.DRKeyLevel1. +func (c *dRKeyInterServiceClient) DRKeyLevel1(ctx context.Context, req *connect.Request[control_plane.DRKeyLevel1Request]) (*connect.Response[control_plane.DRKeyLevel1Response], error) { + return c.dRKeyLevel1.CallUnary(ctx, req) +} + +// DRKeyInterServiceHandler is an implementation of the proto.control_plane.v1.DRKeyInterService +// service. +type DRKeyInterServiceHandler interface { + DRKeyLevel1(context.Context, *connect.Request[control_plane.DRKeyLevel1Request]) (*connect.Response[control_plane.DRKeyLevel1Response], error) +} + +// NewDRKeyInterServiceHandler builds an HTTP handler from the service implementation. It returns +// the path on which to mount the handler and the handler itself. +// +// By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf +// and JSON codecs. They also support gzip compression. +func NewDRKeyInterServiceHandler(svc DRKeyInterServiceHandler, opts ...connect.HandlerOption) (string, http.Handler) { + dRKeyInterServiceDRKeyLevel1Handler := connect.NewUnaryHandler( + DRKeyInterServiceDRKeyLevel1Procedure, + svc.DRKeyLevel1, + connect.WithSchema(dRKeyInterServiceDRKeyLevel1MethodDescriptor), + connect.WithHandlerOptions(opts...), + ) + return "/proto.control_plane.v1.DRKeyInterService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + switch r.URL.Path { + case DRKeyInterServiceDRKeyLevel1Procedure: + dRKeyInterServiceDRKeyLevel1Handler.ServeHTTP(w, r) + default: + http.NotFound(w, r) + } + }) +} + +// UnimplementedDRKeyInterServiceHandler returns CodeUnimplemented from all methods. +type UnimplementedDRKeyInterServiceHandler struct{} + +func (UnimplementedDRKeyInterServiceHandler) DRKeyLevel1(context.Context, *connect.Request[control_plane.DRKeyLevel1Request]) (*connect.Response[control_plane.DRKeyLevel1Response], error) { + return nil, connect.NewError(connect.CodeUnimplemented, errors.New("proto.control_plane.v1.DRKeyInterService.DRKeyLevel1 is not implemented")) +} + +// DRKeyIntraServiceClient is a client for the proto.control_plane.v1.DRKeyIntraService service. +type DRKeyIntraServiceClient interface { + DRKeyIntraLevel1(context.Context, *connect.Request[control_plane.DRKeyIntraLevel1Request]) (*connect.Response[control_plane.DRKeyIntraLevel1Response], error) + DRKeyASHost(context.Context, *connect.Request[control_plane.DRKeyASHostRequest]) (*connect.Response[control_plane.DRKeyASHostResponse], error) + DRKeyHostAS(context.Context, *connect.Request[control_plane.DRKeyHostASRequest]) (*connect.Response[control_plane.DRKeyHostASResponse], error) + DRKeyHostHost(context.Context, *connect.Request[control_plane.DRKeyHostHostRequest]) (*connect.Response[control_plane.DRKeyHostHostResponse], error) + DRKeySecretValue(context.Context, *connect.Request[control_plane.DRKeySecretValueRequest]) (*connect.Response[control_plane.DRKeySecretValueResponse], error) +} + +// NewDRKeyIntraServiceClient constructs a client for the proto.control_plane.v1.DRKeyIntraService +// service. By default, it uses the Connect protocol with the binary Protobuf Codec, asks for +// gzipped responses, and sends uncompressed requests. To use the gRPC or gRPC-Web protocols, supply +// the connect.WithGRPC() or connect.WithGRPCWeb() options. +// +// The URL supplied here should be the base URL for the Connect or gRPC server (for example, +// http://api.acme.com or https://acme.com/grpc). +func NewDRKeyIntraServiceClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) DRKeyIntraServiceClient { + baseURL = strings.TrimRight(baseURL, "/") + return &dRKeyIntraServiceClient{ + dRKeyIntraLevel1: connect.NewClient[control_plane.DRKeyIntraLevel1Request, control_plane.DRKeyIntraLevel1Response]( + httpClient, + baseURL+DRKeyIntraServiceDRKeyIntraLevel1Procedure, + connect.WithSchema(dRKeyIntraServiceDRKeyIntraLevel1MethodDescriptor), + connect.WithClientOptions(opts...), + ), + dRKeyASHost: connect.NewClient[control_plane.DRKeyASHostRequest, control_plane.DRKeyASHostResponse]( + httpClient, + baseURL+DRKeyIntraServiceDRKeyASHostProcedure, + connect.WithSchema(dRKeyIntraServiceDRKeyASHostMethodDescriptor), + connect.WithClientOptions(opts...), + ), + dRKeyHostAS: connect.NewClient[control_plane.DRKeyHostASRequest, control_plane.DRKeyHostASResponse]( + httpClient, + baseURL+DRKeyIntraServiceDRKeyHostASProcedure, + connect.WithSchema(dRKeyIntraServiceDRKeyHostASMethodDescriptor), + connect.WithClientOptions(opts...), + ), + dRKeyHostHost: connect.NewClient[control_plane.DRKeyHostHostRequest, control_plane.DRKeyHostHostResponse]( + httpClient, + baseURL+DRKeyIntraServiceDRKeyHostHostProcedure, + connect.WithSchema(dRKeyIntraServiceDRKeyHostHostMethodDescriptor), + connect.WithClientOptions(opts...), + ), + dRKeySecretValue: connect.NewClient[control_plane.DRKeySecretValueRequest, control_plane.DRKeySecretValueResponse]( + httpClient, + baseURL+DRKeyIntraServiceDRKeySecretValueProcedure, + connect.WithSchema(dRKeyIntraServiceDRKeySecretValueMethodDescriptor), + connect.WithClientOptions(opts...), + ), + } +} + +// dRKeyIntraServiceClient implements DRKeyIntraServiceClient. +type dRKeyIntraServiceClient struct { + dRKeyIntraLevel1 *connect.Client[control_plane.DRKeyIntraLevel1Request, control_plane.DRKeyIntraLevel1Response] + dRKeyASHost *connect.Client[control_plane.DRKeyASHostRequest, control_plane.DRKeyASHostResponse] + dRKeyHostAS *connect.Client[control_plane.DRKeyHostASRequest, control_plane.DRKeyHostASResponse] + dRKeyHostHost *connect.Client[control_plane.DRKeyHostHostRequest, control_plane.DRKeyHostHostResponse] + dRKeySecretValue *connect.Client[control_plane.DRKeySecretValueRequest, control_plane.DRKeySecretValueResponse] +} + +// DRKeyIntraLevel1 calls proto.control_plane.v1.DRKeyIntraService.DRKeyIntraLevel1. +func (c *dRKeyIntraServiceClient) DRKeyIntraLevel1(ctx context.Context, req *connect.Request[control_plane.DRKeyIntraLevel1Request]) (*connect.Response[control_plane.DRKeyIntraLevel1Response], error) { + return c.dRKeyIntraLevel1.CallUnary(ctx, req) +} + +// DRKeyASHost calls proto.control_plane.v1.DRKeyIntraService.DRKeyASHost. +func (c *dRKeyIntraServiceClient) DRKeyASHost(ctx context.Context, req *connect.Request[control_plane.DRKeyASHostRequest]) (*connect.Response[control_plane.DRKeyASHostResponse], error) { + return c.dRKeyASHost.CallUnary(ctx, req) +} + +// DRKeyHostAS calls proto.control_plane.v1.DRKeyIntraService.DRKeyHostAS. +func (c *dRKeyIntraServiceClient) DRKeyHostAS(ctx context.Context, req *connect.Request[control_plane.DRKeyHostASRequest]) (*connect.Response[control_plane.DRKeyHostASResponse], error) { + return c.dRKeyHostAS.CallUnary(ctx, req) +} + +// DRKeyHostHost calls proto.control_plane.v1.DRKeyIntraService.DRKeyHostHost. +func (c *dRKeyIntraServiceClient) DRKeyHostHost(ctx context.Context, req *connect.Request[control_plane.DRKeyHostHostRequest]) (*connect.Response[control_plane.DRKeyHostHostResponse], error) { + return c.dRKeyHostHost.CallUnary(ctx, req) +} + +// DRKeySecretValue calls proto.control_plane.v1.DRKeyIntraService.DRKeySecretValue. +func (c *dRKeyIntraServiceClient) DRKeySecretValue(ctx context.Context, req *connect.Request[control_plane.DRKeySecretValueRequest]) (*connect.Response[control_plane.DRKeySecretValueResponse], error) { + return c.dRKeySecretValue.CallUnary(ctx, req) +} + +// DRKeyIntraServiceHandler is an implementation of the proto.control_plane.v1.DRKeyIntraService +// service. +type DRKeyIntraServiceHandler interface { + DRKeyIntraLevel1(context.Context, *connect.Request[control_plane.DRKeyIntraLevel1Request]) (*connect.Response[control_plane.DRKeyIntraLevel1Response], error) + DRKeyASHost(context.Context, *connect.Request[control_plane.DRKeyASHostRequest]) (*connect.Response[control_plane.DRKeyASHostResponse], error) + DRKeyHostAS(context.Context, *connect.Request[control_plane.DRKeyHostASRequest]) (*connect.Response[control_plane.DRKeyHostASResponse], error) + DRKeyHostHost(context.Context, *connect.Request[control_plane.DRKeyHostHostRequest]) (*connect.Response[control_plane.DRKeyHostHostResponse], error) + DRKeySecretValue(context.Context, *connect.Request[control_plane.DRKeySecretValueRequest]) (*connect.Response[control_plane.DRKeySecretValueResponse], error) +} + +// NewDRKeyIntraServiceHandler builds an HTTP handler from the service implementation. It returns +// the path on which to mount the handler and the handler itself. +// +// By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf +// and JSON codecs. They also support gzip compression. +func NewDRKeyIntraServiceHandler(svc DRKeyIntraServiceHandler, opts ...connect.HandlerOption) (string, http.Handler) { + dRKeyIntraServiceDRKeyIntraLevel1Handler := connect.NewUnaryHandler( + DRKeyIntraServiceDRKeyIntraLevel1Procedure, + svc.DRKeyIntraLevel1, + connect.WithSchema(dRKeyIntraServiceDRKeyIntraLevel1MethodDescriptor), + connect.WithHandlerOptions(opts...), + ) + dRKeyIntraServiceDRKeyASHostHandler := connect.NewUnaryHandler( + DRKeyIntraServiceDRKeyASHostProcedure, + svc.DRKeyASHost, + connect.WithSchema(dRKeyIntraServiceDRKeyASHostMethodDescriptor), + connect.WithHandlerOptions(opts...), + ) + dRKeyIntraServiceDRKeyHostASHandler := connect.NewUnaryHandler( + DRKeyIntraServiceDRKeyHostASProcedure, + svc.DRKeyHostAS, + connect.WithSchema(dRKeyIntraServiceDRKeyHostASMethodDescriptor), + connect.WithHandlerOptions(opts...), + ) + dRKeyIntraServiceDRKeyHostHostHandler := connect.NewUnaryHandler( + DRKeyIntraServiceDRKeyHostHostProcedure, + svc.DRKeyHostHost, + connect.WithSchema(dRKeyIntraServiceDRKeyHostHostMethodDescriptor), + connect.WithHandlerOptions(opts...), + ) + dRKeyIntraServiceDRKeySecretValueHandler := connect.NewUnaryHandler( + DRKeyIntraServiceDRKeySecretValueProcedure, + svc.DRKeySecretValue, + connect.WithSchema(dRKeyIntraServiceDRKeySecretValueMethodDescriptor), + connect.WithHandlerOptions(opts...), + ) + return "/proto.control_plane.v1.DRKeyIntraService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + switch r.URL.Path { + case DRKeyIntraServiceDRKeyIntraLevel1Procedure: + dRKeyIntraServiceDRKeyIntraLevel1Handler.ServeHTTP(w, r) + case DRKeyIntraServiceDRKeyASHostProcedure: + dRKeyIntraServiceDRKeyASHostHandler.ServeHTTP(w, r) + case DRKeyIntraServiceDRKeyHostASProcedure: + dRKeyIntraServiceDRKeyHostASHandler.ServeHTTP(w, r) + case DRKeyIntraServiceDRKeyHostHostProcedure: + dRKeyIntraServiceDRKeyHostHostHandler.ServeHTTP(w, r) + case DRKeyIntraServiceDRKeySecretValueProcedure: + dRKeyIntraServiceDRKeySecretValueHandler.ServeHTTP(w, r) + default: + http.NotFound(w, r) + } + }) +} + +// UnimplementedDRKeyIntraServiceHandler returns CodeUnimplemented from all methods. +type UnimplementedDRKeyIntraServiceHandler struct{} + +func (UnimplementedDRKeyIntraServiceHandler) DRKeyIntraLevel1(context.Context, *connect.Request[control_plane.DRKeyIntraLevel1Request]) (*connect.Response[control_plane.DRKeyIntraLevel1Response], error) { + return nil, connect.NewError(connect.CodeUnimplemented, errors.New("proto.control_plane.v1.DRKeyIntraService.DRKeyIntraLevel1 is not implemented")) +} + +func (UnimplementedDRKeyIntraServiceHandler) DRKeyASHost(context.Context, *connect.Request[control_plane.DRKeyASHostRequest]) (*connect.Response[control_plane.DRKeyASHostResponse], error) { + return nil, connect.NewError(connect.CodeUnimplemented, errors.New("proto.control_plane.v1.DRKeyIntraService.DRKeyASHost is not implemented")) +} + +func (UnimplementedDRKeyIntraServiceHandler) DRKeyHostAS(context.Context, *connect.Request[control_plane.DRKeyHostASRequest]) (*connect.Response[control_plane.DRKeyHostASResponse], error) { + return nil, connect.NewError(connect.CodeUnimplemented, errors.New("proto.control_plane.v1.DRKeyIntraService.DRKeyHostAS is not implemented")) +} + +func (UnimplementedDRKeyIntraServiceHandler) DRKeyHostHost(context.Context, *connect.Request[control_plane.DRKeyHostHostRequest]) (*connect.Response[control_plane.DRKeyHostHostResponse], error) { + return nil, connect.NewError(connect.CodeUnimplemented, errors.New("proto.control_plane.v1.DRKeyIntraService.DRKeyHostHost is not implemented")) +} + +func (UnimplementedDRKeyIntraServiceHandler) DRKeySecretValue(context.Context, *connect.Request[control_plane.DRKeySecretValueRequest]) (*connect.Response[control_plane.DRKeySecretValueResponse], error) { + return nil, connect.NewError(connect.CodeUnimplemented, errors.New("proto.control_plane.v1.DRKeyIntraService.DRKeySecretValue is not implemented")) +} diff --git a/pkg/proto/control_plane/v1/control_planeconnect/renewal.connect.go b/pkg/proto/control_plane/v1/control_planeconnect/renewal.connect.go new file mode 100644 index 0000000000..1b19999cd0 --- /dev/null +++ b/pkg/proto/control_plane/v1/control_planeconnect/renewal.connect.go @@ -0,0 +1,114 @@ +// Code generated by protoc-gen-connect-go. DO NOT EDIT. +// +// Source: proto/control_plane/v1/renewal.proto + +package control_planeconnect + +import ( + connect "connectrpc.com/connect" + context "context" + errors "errors" + control_plane "github.com/scionproto/scion/pkg/proto/control_plane" + http "net/http" + strings "strings" +) + +// This is a compile-time assertion to ensure that this generated file and the connect package are +// compatible. If you get a compiler error that this constant is not defined, this code was +// generated with a version of connect newer than the one compiled into your binary. You can fix the +// problem by either regenerating this code with an older version of connect or updating the connect +// version compiled into your binary. +const _ = connect.IsAtLeastVersion1_13_0 + +const ( + // ChainRenewalServiceName is the fully-qualified name of the ChainRenewalService service. + ChainRenewalServiceName = "proto.control_plane.v1.ChainRenewalService" +) + +// These constants are the fully-qualified names of the RPCs defined in this package. They're +// exposed at runtime as Spec.Procedure and as the final two segments of the HTTP route. +// +// Note that these are different from the fully-qualified method names used by +// google.golang.org/protobuf/reflect/protoreflect. To convert from these constants to +// reflection-formatted method names, remove the leading slash and convert the remaining slash to a +// period. +const ( + // ChainRenewalServiceChainRenewalProcedure is the fully-qualified name of the ChainRenewalService's + // ChainRenewal RPC. + ChainRenewalServiceChainRenewalProcedure = "/proto.control_plane.v1.ChainRenewalService/ChainRenewal" +) + +// These variables are the protoreflect.Descriptor objects for the RPCs defined in this package. +var ( + chainRenewalServiceServiceDescriptor = control_plane.File_proto_control_plane_v1_renewal_proto.Services().ByName("ChainRenewalService") + chainRenewalServiceChainRenewalMethodDescriptor = chainRenewalServiceServiceDescriptor.Methods().ByName("ChainRenewal") +) + +// ChainRenewalServiceClient is a client for the proto.control_plane.v1.ChainRenewalService service. +type ChainRenewalServiceClient interface { + ChainRenewal(context.Context, *connect.Request[control_plane.ChainRenewalRequest]) (*connect.Response[control_plane.ChainRenewalResponse], error) +} + +// NewChainRenewalServiceClient constructs a client for the +// proto.control_plane.v1.ChainRenewalService service. By default, it uses the Connect protocol with +// the binary Protobuf Codec, asks for gzipped responses, and sends uncompressed requests. To use +// the gRPC or gRPC-Web protocols, supply the connect.WithGRPC() or connect.WithGRPCWeb() options. +// +// The URL supplied here should be the base URL for the Connect or gRPC server (for example, +// http://api.acme.com or https://acme.com/grpc). +func NewChainRenewalServiceClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) ChainRenewalServiceClient { + baseURL = strings.TrimRight(baseURL, "/") + return &chainRenewalServiceClient{ + chainRenewal: connect.NewClient[control_plane.ChainRenewalRequest, control_plane.ChainRenewalResponse]( + httpClient, + baseURL+ChainRenewalServiceChainRenewalProcedure, + connect.WithSchema(chainRenewalServiceChainRenewalMethodDescriptor), + connect.WithClientOptions(opts...), + ), + } +} + +// chainRenewalServiceClient implements ChainRenewalServiceClient. +type chainRenewalServiceClient struct { + chainRenewal *connect.Client[control_plane.ChainRenewalRequest, control_plane.ChainRenewalResponse] +} + +// ChainRenewal calls proto.control_plane.v1.ChainRenewalService.ChainRenewal. +func (c *chainRenewalServiceClient) ChainRenewal(ctx context.Context, req *connect.Request[control_plane.ChainRenewalRequest]) (*connect.Response[control_plane.ChainRenewalResponse], error) { + return c.chainRenewal.CallUnary(ctx, req) +} + +// ChainRenewalServiceHandler is an implementation of the proto.control_plane.v1.ChainRenewalService +// service. +type ChainRenewalServiceHandler interface { + ChainRenewal(context.Context, *connect.Request[control_plane.ChainRenewalRequest]) (*connect.Response[control_plane.ChainRenewalResponse], error) +} + +// NewChainRenewalServiceHandler builds an HTTP handler from the service implementation. It returns +// the path on which to mount the handler and the handler itself. +// +// By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf +// and JSON codecs. They also support gzip compression. +func NewChainRenewalServiceHandler(svc ChainRenewalServiceHandler, opts ...connect.HandlerOption) (string, http.Handler) { + chainRenewalServiceChainRenewalHandler := connect.NewUnaryHandler( + ChainRenewalServiceChainRenewalProcedure, + svc.ChainRenewal, + connect.WithSchema(chainRenewalServiceChainRenewalMethodDescriptor), + connect.WithHandlerOptions(opts...), + ) + return "/proto.control_plane.v1.ChainRenewalService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + switch r.URL.Path { + case ChainRenewalServiceChainRenewalProcedure: + chainRenewalServiceChainRenewalHandler.ServeHTTP(w, r) + default: + http.NotFound(w, r) + } + }) +} + +// UnimplementedChainRenewalServiceHandler returns CodeUnimplemented from all methods. +type UnimplementedChainRenewalServiceHandler struct{} + +func (UnimplementedChainRenewalServiceHandler) ChainRenewal(context.Context, *connect.Request[control_plane.ChainRenewalRequest]) (*connect.Response[control_plane.ChainRenewalResponse], error) { + return nil, connect.NewError(connect.CodeUnimplemented, errors.New("proto.control_plane.v1.ChainRenewalService.ChainRenewal is not implemented")) +} diff --git a/pkg/proto/control_plane/v1/control_planeconnect/seg.connect.go b/pkg/proto/control_plane/v1/control_planeconnect/seg.connect.go new file mode 100644 index 0000000000..266d5b169a --- /dev/null +++ b/pkg/proto/control_plane/v1/control_planeconnect/seg.connect.go @@ -0,0 +1,274 @@ +// Code generated by protoc-gen-connect-go. DO NOT EDIT. +// +// Source: proto/control_plane/v1/seg.proto + +package control_planeconnect + +import ( + connect "connectrpc.com/connect" + context "context" + errors "errors" + control_plane "github.com/scionproto/scion/pkg/proto/control_plane" + http "net/http" + strings "strings" +) + +// This is a compile-time assertion to ensure that this generated file and the connect package are +// compatible. If you get a compiler error that this constant is not defined, this code was +// generated with a version of connect newer than the one compiled into your binary. You can fix the +// problem by either regenerating this code with an older version of connect or updating the connect +// version compiled into your binary. +const _ = connect.IsAtLeastVersion1_13_0 + +const ( + // SegmentLookupServiceName is the fully-qualified name of the SegmentLookupService service. + SegmentLookupServiceName = "proto.control_plane.v1.SegmentLookupService" + // SegmentRegistrationServiceName is the fully-qualified name of the SegmentRegistrationService + // service. + SegmentRegistrationServiceName = "proto.control_plane.v1.SegmentRegistrationService" + // SegmentCreationServiceName is the fully-qualified name of the SegmentCreationService service. + SegmentCreationServiceName = "proto.control_plane.v1.SegmentCreationService" +) + +// These constants are the fully-qualified names of the RPCs defined in this package. They're +// exposed at runtime as Spec.Procedure and as the final two segments of the HTTP route. +// +// Note that these are different from the fully-qualified method names used by +// google.golang.org/protobuf/reflect/protoreflect. To convert from these constants to +// reflection-formatted method names, remove the leading slash and convert the remaining slash to a +// period. +const ( + // SegmentLookupServiceSegmentsProcedure is the fully-qualified name of the SegmentLookupService's + // Segments RPC. + SegmentLookupServiceSegmentsProcedure = "/proto.control_plane.v1.SegmentLookupService/Segments" + // SegmentRegistrationServiceSegmentsRegistrationProcedure is the fully-qualified name of the + // SegmentRegistrationService's SegmentsRegistration RPC. + SegmentRegistrationServiceSegmentsRegistrationProcedure = "/proto.control_plane.v1.SegmentRegistrationService/SegmentsRegistration" + // SegmentCreationServiceBeaconProcedure is the fully-qualified name of the SegmentCreationService's + // Beacon RPC. + SegmentCreationServiceBeaconProcedure = "/proto.control_plane.v1.SegmentCreationService/Beacon" +) + +// These variables are the protoreflect.Descriptor objects for the RPCs defined in this package. +var ( + segmentLookupServiceServiceDescriptor = control_plane.File_proto_control_plane_v1_seg_proto.Services().ByName("SegmentLookupService") + segmentLookupServiceSegmentsMethodDescriptor = segmentLookupServiceServiceDescriptor.Methods().ByName("Segments") + segmentRegistrationServiceServiceDescriptor = control_plane.File_proto_control_plane_v1_seg_proto.Services().ByName("SegmentRegistrationService") + segmentRegistrationServiceSegmentsRegistrationMethodDescriptor = segmentRegistrationServiceServiceDescriptor.Methods().ByName("SegmentsRegistration") + segmentCreationServiceServiceDescriptor = control_plane.File_proto_control_plane_v1_seg_proto.Services().ByName("SegmentCreationService") + segmentCreationServiceBeaconMethodDescriptor = segmentCreationServiceServiceDescriptor.Methods().ByName("Beacon") +) + +// SegmentLookupServiceClient is a client for the proto.control_plane.v1.SegmentLookupService +// service. +type SegmentLookupServiceClient interface { + Segments(context.Context, *connect.Request[control_plane.SegmentsRequest]) (*connect.Response[control_plane.SegmentsResponse], error) +} + +// NewSegmentLookupServiceClient constructs a client for the +// proto.control_plane.v1.SegmentLookupService service. By default, it uses the Connect protocol +// with the binary Protobuf Codec, asks for gzipped responses, and sends uncompressed requests. To +// use the gRPC or gRPC-Web protocols, supply the connect.WithGRPC() or connect.WithGRPCWeb() +// options. +// +// The URL supplied here should be the base URL for the Connect or gRPC server (for example, +// http://api.acme.com or https://acme.com/grpc). +func NewSegmentLookupServiceClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) SegmentLookupServiceClient { + baseURL = strings.TrimRight(baseURL, "/") + return &segmentLookupServiceClient{ + segments: connect.NewClient[control_plane.SegmentsRequest, control_plane.SegmentsResponse]( + httpClient, + baseURL+SegmentLookupServiceSegmentsProcedure, + connect.WithSchema(segmentLookupServiceSegmentsMethodDescriptor), + connect.WithClientOptions(opts...), + ), + } +} + +// segmentLookupServiceClient implements SegmentLookupServiceClient. +type segmentLookupServiceClient struct { + segments *connect.Client[control_plane.SegmentsRequest, control_plane.SegmentsResponse] +} + +// Segments calls proto.control_plane.v1.SegmentLookupService.Segments. +func (c *segmentLookupServiceClient) Segments(ctx context.Context, req *connect.Request[control_plane.SegmentsRequest]) (*connect.Response[control_plane.SegmentsResponse], error) { + return c.segments.CallUnary(ctx, req) +} + +// SegmentLookupServiceHandler is an implementation of the +// proto.control_plane.v1.SegmentLookupService service. +type SegmentLookupServiceHandler interface { + Segments(context.Context, *connect.Request[control_plane.SegmentsRequest]) (*connect.Response[control_plane.SegmentsResponse], error) +} + +// NewSegmentLookupServiceHandler builds an HTTP handler from the service implementation. It returns +// the path on which to mount the handler and the handler itself. +// +// By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf +// and JSON codecs. They also support gzip compression. +func NewSegmentLookupServiceHandler(svc SegmentLookupServiceHandler, opts ...connect.HandlerOption) (string, http.Handler) { + segmentLookupServiceSegmentsHandler := connect.NewUnaryHandler( + SegmentLookupServiceSegmentsProcedure, + svc.Segments, + connect.WithSchema(segmentLookupServiceSegmentsMethodDescriptor), + connect.WithHandlerOptions(opts...), + ) + return "/proto.control_plane.v1.SegmentLookupService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + switch r.URL.Path { + case SegmentLookupServiceSegmentsProcedure: + segmentLookupServiceSegmentsHandler.ServeHTTP(w, r) + default: + http.NotFound(w, r) + } + }) +} + +// UnimplementedSegmentLookupServiceHandler returns CodeUnimplemented from all methods. +type UnimplementedSegmentLookupServiceHandler struct{} + +func (UnimplementedSegmentLookupServiceHandler) Segments(context.Context, *connect.Request[control_plane.SegmentsRequest]) (*connect.Response[control_plane.SegmentsResponse], error) { + return nil, connect.NewError(connect.CodeUnimplemented, errors.New("proto.control_plane.v1.SegmentLookupService.Segments is not implemented")) +} + +// SegmentRegistrationServiceClient is a client for the +// proto.control_plane.v1.SegmentRegistrationService service. +type SegmentRegistrationServiceClient interface { + SegmentsRegistration(context.Context, *connect.Request[control_plane.SegmentsRegistrationRequest]) (*connect.Response[control_plane.SegmentsRegistrationResponse], error) +} + +// NewSegmentRegistrationServiceClient constructs a client for the +// proto.control_plane.v1.SegmentRegistrationService service. By default, it uses the Connect +// protocol with the binary Protobuf Codec, asks for gzipped responses, and sends uncompressed +// requests. To use the gRPC or gRPC-Web protocols, supply the connect.WithGRPC() or +// connect.WithGRPCWeb() options. +// +// The URL supplied here should be the base URL for the Connect or gRPC server (for example, +// http://api.acme.com or https://acme.com/grpc). +func NewSegmentRegistrationServiceClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) SegmentRegistrationServiceClient { + baseURL = strings.TrimRight(baseURL, "/") + return &segmentRegistrationServiceClient{ + segmentsRegistration: connect.NewClient[control_plane.SegmentsRegistrationRequest, control_plane.SegmentsRegistrationResponse]( + httpClient, + baseURL+SegmentRegistrationServiceSegmentsRegistrationProcedure, + connect.WithSchema(segmentRegistrationServiceSegmentsRegistrationMethodDescriptor), + connect.WithClientOptions(opts...), + ), + } +} + +// segmentRegistrationServiceClient implements SegmentRegistrationServiceClient. +type segmentRegistrationServiceClient struct { + segmentsRegistration *connect.Client[control_plane.SegmentsRegistrationRequest, control_plane.SegmentsRegistrationResponse] +} + +// SegmentsRegistration calls +// proto.control_plane.v1.SegmentRegistrationService.SegmentsRegistration. +func (c *segmentRegistrationServiceClient) SegmentsRegistration(ctx context.Context, req *connect.Request[control_plane.SegmentsRegistrationRequest]) (*connect.Response[control_plane.SegmentsRegistrationResponse], error) { + return c.segmentsRegistration.CallUnary(ctx, req) +} + +// SegmentRegistrationServiceHandler is an implementation of the +// proto.control_plane.v1.SegmentRegistrationService service. +type SegmentRegistrationServiceHandler interface { + SegmentsRegistration(context.Context, *connect.Request[control_plane.SegmentsRegistrationRequest]) (*connect.Response[control_plane.SegmentsRegistrationResponse], error) +} + +// NewSegmentRegistrationServiceHandler builds an HTTP handler from the service implementation. It +// returns the path on which to mount the handler and the handler itself. +// +// By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf +// and JSON codecs. They also support gzip compression. +func NewSegmentRegistrationServiceHandler(svc SegmentRegistrationServiceHandler, opts ...connect.HandlerOption) (string, http.Handler) { + segmentRegistrationServiceSegmentsRegistrationHandler := connect.NewUnaryHandler( + SegmentRegistrationServiceSegmentsRegistrationProcedure, + svc.SegmentsRegistration, + connect.WithSchema(segmentRegistrationServiceSegmentsRegistrationMethodDescriptor), + connect.WithHandlerOptions(opts...), + ) + return "/proto.control_plane.v1.SegmentRegistrationService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + switch r.URL.Path { + case SegmentRegistrationServiceSegmentsRegistrationProcedure: + segmentRegistrationServiceSegmentsRegistrationHandler.ServeHTTP(w, r) + default: + http.NotFound(w, r) + } + }) +} + +// UnimplementedSegmentRegistrationServiceHandler returns CodeUnimplemented from all methods. +type UnimplementedSegmentRegistrationServiceHandler struct{} + +func (UnimplementedSegmentRegistrationServiceHandler) SegmentsRegistration(context.Context, *connect.Request[control_plane.SegmentsRegistrationRequest]) (*connect.Response[control_plane.SegmentsRegistrationResponse], error) { + return nil, connect.NewError(connect.CodeUnimplemented, errors.New("proto.control_plane.v1.SegmentRegistrationService.SegmentsRegistration is not implemented")) +} + +// SegmentCreationServiceClient is a client for the proto.control_plane.v1.SegmentCreationService +// service. +type SegmentCreationServiceClient interface { + Beacon(context.Context, *connect.Request[control_plane.BeaconRequest]) (*connect.Response[control_plane.BeaconResponse], error) +} + +// NewSegmentCreationServiceClient constructs a client for the +// proto.control_plane.v1.SegmentCreationService service. By default, it uses the Connect protocol +// with the binary Protobuf Codec, asks for gzipped responses, and sends uncompressed requests. To +// use the gRPC or gRPC-Web protocols, supply the connect.WithGRPC() or connect.WithGRPCWeb() +// options. +// +// The URL supplied here should be the base URL for the Connect or gRPC server (for example, +// http://api.acme.com or https://acme.com/grpc). +func NewSegmentCreationServiceClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) SegmentCreationServiceClient { + baseURL = strings.TrimRight(baseURL, "/") + return &segmentCreationServiceClient{ + beacon: connect.NewClient[control_plane.BeaconRequest, control_plane.BeaconResponse]( + httpClient, + baseURL+SegmentCreationServiceBeaconProcedure, + connect.WithSchema(segmentCreationServiceBeaconMethodDescriptor), + connect.WithClientOptions(opts...), + ), + } +} + +// segmentCreationServiceClient implements SegmentCreationServiceClient. +type segmentCreationServiceClient struct { + beacon *connect.Client[control_plane.BeaconRequest, control_plane.BeaconResponse] +} + +// Beacon calls proto.control_plane.v1.SegmentCreationService.Beacon. +func (c *segmentCreationServiceClient) Beacon(ctx context.Context, req *connect.Request[control_plane.BeaconRequest]) (*connect.Response[control_plane.BeaconResponse], error) { + return c.beacon.CallUnary(ctx, req) +} + +// SegmentCreationServiceHandler is an implementation of the +// proto.control_plane.v1.SegmentCreationService service. +type SegmentCreationServiceHandler interface { + Beacon(context.Context, *connect.Request[control_plane.BeaconRequest]) (*connect.Response[control_plane.BeaconResponse], error) +} + +// NewSegmentCreationServiceHandler builds an HTTP handler from the service implementation. It +// returns the path on which to mount the handler and the handler itself. +// +// By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf +// and JSON codecs. They also support gzip compression. +func NewSegmentCreationServiceHandler(svc SegmentCreationServiceHandler, opts ...connect.HandlerOption) (string, http.Handler) { + segmentCreationServiceBeaconHandler := connect.NewUnaryHandler( + SegmentCreationServiceBeaconProcedure, + svc.Beacon, + connect.WithSchema(segmentCreationServiceBeaconMethodDescriptor), + connect.WithHandlerOptions(opts...), + ) + return "/proto.control_plane.v1.SegmentCreationService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + switch r.URL.Path { + case SegmentCreationServiceBeaconProcedure: + segmentCreationServiceBeaconHandler.ServeHTTP(w, r) + default: + http.NotFound(w, r) + } + }) +} + +// UnimplementedSegmentCreationServiceHandler returns CodeUnimplemented from all methods. +type UnimplementedSegmentCreationServiceHandler struct{} + +func (UnimplementedSegmentCreationServiceHandler) Beacon(context.Context, *connect.Request[control_plane.BeaconRequest]) (*connect.Response[control_plane.BeaconResponse], error) { + return nil, connect.NewError(connect.CodeUnimplemented, errors.New("proto.control_plane.v1.SegmentCreationService.Beacon is not implemented")) +} diff --git a/pkg/proto/daemon/v1/daemonconnect/BUILD.bazel b/pkg/proto/daemon/v1/daemonconnect/BUILD.bazel new file mode 100644 index 0000000000..873a53ceab --- /dev/null +++ b/pkg/proto/daemon/v1/daemonconnect/BUILD.bazel @@ -0,0 +1,6 @@ +load("//tools/proto:connect.bzl", "go_connect_library") + +go_connect_library( + name = "go_default_library", + proto = "daemon", +) diff --git a/pkg/proto/daemon/v1/daemonconnect/daemon.connect.go b/pkg/proto/daemon/v1/daemonconnect/daemon.connect.go new file mode 100644 index 0000000000..b7e5dbbe3f --- /dev/null +++ b/pkg/proto/daemon/v1/daemonconnect/daemon.connect.go @@ -0,0 +1,350 @@ +// Code generated by protoc-gen-connect-go. DO NOT EDIT. +// +// Source: proto/daemon/v1/daemon.proto + +package daemonconnect + +import ( + connect "connectrpc.com/connect" + context "context" + errors "errors" + daemon "github.com/scionproto/scion/pkg/proto/daemon" + emptypb "google.golang.org/protobuf/types/known/emptypb" + http "net/http" + strings "strings" +) + +// This is a compile-time assertion to ensure that this generated file and the connect package are +// compatible. If you get a compiler error that this constant is not defined, this code was +// generated with a version of connect newer than the one compiled into your binary. You can fix the +// problem by either regenerating this code with an older version of connect or updating the connect +// version compiled into your binary. +const _ = connect.IsAtLeastVersion1_13_0 + +const ( + // DaemonServiceName is the fully-qualified name of the DaemonService service. + DaemonServiceName = "proto.daemon.v1.DaemonService" +) + +// These constants are the fully-qualified names of the RPCs defined in this package. They're +// exposed at runtime as Spec.Procedure and as the final two segments of the HTTP route. +// +// Note that these are different from the fully-qualified method names used by +// google.golang.org/protobuf/reflect/protoreflect. To convert from these constants to +// reflection-formatted method names, remove the leading slash and convert the remaining slash to a +// period. +const ( + // DaemonServicePathsProcedure is the fully-qualified name of the DaemonService's Paths RPC. + DaemonServicePathsProcedure = "/proto.daemon.v1.DaemonService/Paths" + // DaemonServiceASProcedure is the fully-qualified name of the DaemonService's AS RPC. + DaemonServiceASProcedure = "/proto.daemon.v1.DaemonService/AS" + // DaemonServiceInterfacesProcedure is the fully-qualified name of the DaemonService's Interfaces + // RPC. + DaemonServiceInterfacesProcedure = "/proto.daemon.v1.DaemonService/Interfaces" + // DaemonServiceServicesProcedure is the fully-qualified name of the DaemonService's Services RPC. + DaemonServiceServicesProcedure = "/proto.daemon.v1.DaemonService/Services" + // DaemonServiceNotifyInterfaceDownProcedure is the fully-qualified name of the DaemonService's + // NotifyInterfaceDown RPC. + DaemonServiceNotifyInterfaceDownProcedure = "/proto.daemon.v1.DaemonService/NotifyInterfaceDown" + // DaemonServicePortRangeProcedure is the fully-qualified name of the DaemonService's PortRange RPC. + DaemonServicePortRangeProcedure = "/proto.daemon.v1.DaemonService/PortRange" + // DaemonServiceDRKeyASHostProcedure is the fully-qualified name of the DaemonService's DRKeyASHost + // RPC. + DaemonServiceDRKeyASHostProcedure = "/proto.daemon.v1.DaemonService/DRKeyASHost" + // DaemonServiceDRKeyHostASProcedure is the fully-qualified name of the DaemonService's DRKeyHostAS + // RPC. + DaemonServiceDRKeyHostASProcedure = "/proto.daemon.v1.DaemonService/DRKeyHostAS" + // DaemonServiceDRKeyHostHostProcedure is the fully-qualified name of the DaemonService's + // DRKeyHostHost RPC. + DaemonServiceDRKeyHostHostProcedure = "/proto.daemon.v1.DaemonService/DRKeyHostHost" +) + +// These variables are the protoreflect.Descriptor objects for the RPCs defined in this package. +var ( + daemonServiceServiceDescriptor = daemon.File_proto_daemon_v1_daemon_proto.Services().ByName("DaemonService") + daemonServicePathsMethodDescriptor = daemonServiceServiceDescriptor.Methods().ByName("Paths") + daemonServiceASMethodDescriptor = daemonServiceServiceDescriptor.Methods().ByName("AS") + daemonServiceInterfacesMethodDescriptor = daemonServiceServiceDescriptor.Methods().ByName("Interfaces") + daemonServiceServicesMethodDescriptor = daemonServiceServiceDescriptor.Methods().ByName("Services") + daemonServiceNotifyInterfaceDownMethodDescriptor = daemonServiceServiceDescriptor.Methods().ByName("NotifyInterfaceDown") + daemonServicePortRangeMethodDescriptor = daemonServiceServiceDescriptor.Methods().ByName("PortRange") + daemonServiceDRKeyASHostMethodDescriptor = daemonServiceServiceDescriptor.Methods().ByName("DRKeyASHost") + daemonServiceDRKeyHostASMethodDescriptor = daemonServiceServiceDescriptor.Methods().ByName("DRKeyHostAS") + daemonServiceDRKeyHostHostMethodDescriptor = daemonServiceServiceDescriptor.Methods().ByName("DRKeyHostHost") +) + +// DaemonServiceClient is a client for the proto.daemon.v1.DaemonService service. +type DaemonServiceClient interface { + Paths(context.Context, *connect.Request[daemon.PathsRequest]) (*connect.Response[daemon.PathsResponse], error) + AS(context.Context, *connect.Request[daemon.ASRequest]) (*connect.Response[daemon.ASResponse], error) + Interfaces(context.Context, *connect.Request[daemon.InterfacesRequest]) (*connect.Response[daemon.InterfacesResponse], error) + Services(context.Context, *connect.Request[daemon.ServicesRequest]) (*connect.Response[daemon.ServicesResponse], error) + NotifyInterfaceDown(context.Context, *connect.Request[daemon.NotifyInterfaceDownRequest]) (*connect.Response[daemon.NotifyInterfaceDownResponse], error) + PortRange(context.Context, *connect.Request[emptypb.Empty]) (*connect.Response[daemon.PortRangeResponse], error) + DRKeyASHost(context.Context, *connect.Request[daemon.DRKeyASHostRequest]) (*connect.Response[daemon.DRKeyASHostResponse], error) + DRKeyHostAS(context.Context, *connect.Request[daemon.DRKeyHostASRequest]) (*connect.Response[daemon.DRKeyHostASResponse], error) + DRKeyHostHost(context.Context, *connect.Request[daemon.DRKeyHostHostRequest]) (*connect.Response[daemon.DRKeyHostHostResponse], error) +} + +// NewDaemonServiceClient constructs a client for the proto.daemon.v1.DaemonService service. By +// default, it uses the Connect protocol with the binary Protobuf Codec, asks for gzipped responses, +// and sends uncompressed requests. To use the gRPC or gRPC-Web protocols, supply the +// connect.WithGRPC() or connect.WithGRPCWeb() options. +// +// The URL supplied here should be the base URL for the Connect or gRPC server (for example, +// http://api.acme.com or https://acme.com/grpc). +func NewDaemonServiceClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) DaemonServiceClient { + baseURL = strings.TrimRight(baseURL, "/") + return &daemonServiceClient{ + paths: connect.NewClient[daemon.PathsRequest, daemon.PathsResponse]( + httpClient, + baseURL+DaemonServicePathsProcedure, + connect.WithSchema(daemonServicePathsMethodDescriptor), + connect.WithClientOptions(opts...), + ), + aS: connect.NewClient[daemon.ASRequest, daemon.ASResponse]( + httpClient, + baseURL+DaemonServiceASProcedure, + connect.WithSchema(daemonServiceASMethodDescriptor), + connect.WithClientOptions(opts...), + ), + interfaces: connect.NewClient[daemon.InterfacesRequest, daemon.InterfacesResponse]( + httpClient, + baseURL+DaemonServiceInterfacesProcedure, + connect.WithSchema(daemonServiceInterfacesMethodDescriptor), + connect.WithClientOptions(opts...), + ), + services: connect.NewClient[daemon.ServicesRequest, daemon.ServicesResponse]( + httpClient, + baseURL+DaemonServiceServicesProcedure, + connect.WithSchema(daemonServiceServicesMethodDescriptor), + connect.WithClientOptions(opts...), + ), + notifyInterfaceDown: connect.NewClient[daemon.NotifyInterfaceDownRequest, daemon.NotifyInterfaceDownResponse]( + httpClient, + baseURL+DaemonServiceNotifyInterfaceDownProcedure, + connect.WithSchema(daemonServiceNotifyInterfaceDownMethodDescriptor), + connect.WithClientOptions(opts...), + ), + portRange: connect.NewClient[emptypb.Empty, daemon.PortRangeResponse]( + httpClient, + baseURL+DaemonServicePortRangeProcedure, + connect.WithSchema(daemonServicePortRangeMethodDescriptor), + connect.WithClientOptions(opts...), + ), + dRKeyASHost: connect.NewClient[daemon.DRKeyASHostRequest, daemon.DRKeyASHostResponse]( + httpClient, + baseURL+DaemonServiceDRKeyASHostProcedure, + connect.WithSchema(daemonServiceDRKeyASHostMethodDescriptor), + connect.WithClientOptions(opts...), + ), + dRKeyHostAS: connect.NewClient[daemon.DRKeyHostASRequest, daemon.DRKeyHostASResponse]( + httpClient, + baseURL+DaemonServiceDRKeyHostASProcedure, + connect.WithSchema(daemonServiceDRKeyHostASMethodDescriptor), + connect.WithClientOptions(opts...), + ), + dRKeyHostHost: connect.NewClient[daemon.DRKeyHostHostRequest, daemon.DRKeyHostHostResponse]( + httpClient, + baseURL+DaemonServiceDRKeyHostHostProcedure, + connect.WithSchema(daemonServiceDRKeyHostHostMethodDescriptor), + connect.WithClientOptions(opts...), + ), + } +} + +// daemonServiceClient implements DaemonServiceClient. +type daemonServiceClient struct { + paths *connect.Client[daemon.PathsRequest, daemon.PathsResponse] + aS *connect.Client[daemon.ASRequest, daemon.ASResponse] + interfaces *connect.Client[daemon.InterfacesRequest, daemon.InterfacesResponse] + services *connect.Client[daemon.ServicesRequest, daemon.ServicesResponse] + notifyInterfaceDown *connect.Client[daemon.NotifyInterfaceDownRequest, daemon.NotifyInterfaceDownResponse] + portRange *connect.Client[emptypb.Empty, daemon.PortRangeResponse] + dRKeyASHost *connect.Client[daemon.DRKeyASHostRequest, daemon.DRKeyASHostResponse] + dRKeyHostAS *connect.Client[daemon.DRKeyHostASRequest, daemon.DRKeyHostASResponse] + dRKeyHostHost *connect.Client[daemon.DRKeyHostHostRequest, daemon.DRKeyHostHostResponse] +} + +// Paths calls proto.daemon.v1.DaemonService.Paths. +func (c *daemonServiceClient) Paths(ctx context.Context, req *connect.Request[daemon.PathsRequest]) (*connect.Response[daemon.PathsResponse], error) { + return c.paths.CallUnary(ctx, req) +} + +// AS calls proto.daemon.v1.DaemonService.AS. +func (c *daemonServiceClient) AS(ctx context.Context, req *connect.Request[daemon.ASRequest]) (*connect.Response[daemon.ASResponse], error) { + return c.aS.CallUnary(ctx, req) +} + +// Interfaces calls proto.daemon.v1.DaemonService.Interfaces. +func (c *daemonServiceClient) Interfaces(ctx context.Context, req *connect.Request[daemon.InterfacesRequest]) (*connect.Response[daemon.InterfacesResponse], error) { + return c.interfaces.CallUnary(ctx, req) +} + +// Services calls proto.daemon.v1.DaemonService.Services. +func (c *daemonServiceClient) Services(ctx context.Context, req *connect.Request[daemon.ServicesRequest]) (*connect.Response[daemon.ServicesResponse], error) { + return c.services.CallUnary(ctx, req) +} + +// NotifyInterfaceDown calls proto.daemon.v1.DaemonService.NotifyInterfaceDown. +func (c *daemonServiceClient) NotifyInterfaceDown(ctx context.Context, req *connect.Request[daemon.NotifyInterfaceDownRequest]) (*connect.Response[daemon.NotifyInterfaceDownResponse], error) { + return c.notifyInterfaceDown.CallUnary(ctx, req) +} + +// PortRange calls proto.daemon.v1.DaemonService.PortRange. +func (c *daemonServiceClient) PortRange(ctx context.Context, req *connect.Request[emptypb.Empty]) (*connect.Response[daemon.PortRangeResponse], error) { + return c.portRange.CallUnary(ctx, req) +} + +// DRKeyASHost calls proto.daemon.v1.DaemonService.DRKeyASHost. +func (c *daemonServiceClient) DRKeyASHost(ctx context.Context, req *connect.Request[daemon.DRKeyASHostRequest]) (*connect.Response[daemon.DRKeyASHostResponse], error) { + return c.dRKeyASHost.CallUnary(ctx, req) +} + +// DRKeyHostAS calls proto.daemon.v1.DaemonService.DRKeyHostAS. +func (c *daemonServiceClient) DRKeyHostAS(ctx context.Context, req *connect.Request[daemon.DRKeyHostASRequest]) (*connect.Response[daemon.DRKeyHostASResponse], error) { + return c.dRKeyHostAS.CallUnary(ctx, req) +} + +// DRKeyHostHost calls proto.daemon.v1.DaemonService.DRKeyHostHost. +func (c *daemonServiceClient) DRKeyHostHost(ctx context.Context, req *connect.Request[daemon.DRKeyHostHostRequest]) (*connect.Response[daemon.DRKeyHostHostResponse], error) { + return c.dRKeyHostHost.CallUnary(ctx, req) +} + +// DaemonServiceHandler is an implementation of the proto.daemon.v1.DaemonService service. +type DaemonServiceHandler interface { + Paths(context.Context, *connect.Request[daemon.PathsRequest]) (*connect.Response[daemon.PathsResponse], error) + AS(context.Context, *connect.Request[daemon.ASRequest]) (*connect.Response[daemon.ASResponse], error) + Interfaces(context.Context, *connect.Request[daemon.InterfacesRequest]) (*connect.Response[daemon.InterfacesResponse], error) + Services(context.Context, *connect.Request[daemon.ServicesRequest]) (*connect.Response[daemon.ServicesResponse], error) + NotifyInterfaceDown(context.Context, *connect.Request[daemon.NotifyInterfaceDownRequest]) (*connect.Response[daemon.NotifyInterfaceDownResponse], error) + PortRange(context.Context, *connect.Request[emptypb.Empty]) (*connect.Response[daemon.PortRangeResponse], error) + DRKeyASHost(context.Context, *connect.Request[daemon.DRKeyASHostRequest]) (*connect.Response[daemon.DRKeyASHostResponse], error) + DRKeyHostAS(context.Context, *connect.Request[daemon.DRKeyHostASRequest]) (*connect.Response[daemon.DRKeyHostASResponse], error) + DRKeyHostHost(context.Context, *connect.Request[daemon.DRKeyHostHostRequest]) (*connect.Response[daemon.DRKeyHostHostResponse], error) +} + +// NewDaemonServiceHandler builds an HTTP handler from the service implementation. It returns the +// path on which to mount the handler and the handler itself. +// +// By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf +// and JSON codecs. They also support gzip compression. +func NewDaemonServiceHandler(svc DaemonServiceHandler, opts ...connect.HandlerOption) (string, http.Handler) { + daemonServicePathsHandler := connect.NewUnaryHandler( + DaemonServicePathsProcedure, + svc.Paths, + connect.WithSchema(daemonServicePathsMethodDescriptor), + connect.WithHandlerOptions(opts...), + ) + daemonServiceASHandler := connect.NewUnaryHandler( + DaemonServiceASProcedure, + svc.AS, + connect.WithSchema(daemonServiceASMethodDescriptor), + connect.WithHandlerOptions(opts...), + ) + daemonServiceInterfacesHandler := connect.NewUnaryHandler( + DaemonServiceInterfacesProcedure, + svc.Interfaces, + connect.WithSchema(daemonServiceInterfacesMethodDescriptor), + connect.WithHandlerOptions(opts...), + ) + daemonServiceServicesHandler := connect.NewUnaryHandler( + DaemonServiceServicesProcedure, + svc.Services, + connect.WithSchema(daemonServiceServicesMethodDescriptor), + connect.WithHandlerOptions(opts...), + ) + daemonServiceNotifyInterfaceDownHandler := connect.NewUnaryHandler( + DaemonServiceNotifyInterfaceDownProcedure, + svc.NotifyInterfaceDown, + connect.WithSchema(daemonServiceNotifyInterfaceDownMethodDescriptor), + connect.WithHandlerOptions(opts...), + ) + daemonServicePortRangeHandler := connect.NewUnaryHandler( + DaemonServicePortRangeProcedure, + svc.PortRange, + connect.WithSchema(daemonServicePortRangeMethodDescriptor), + connect.WithHandlerOptions(opts...), + ) + daemonServiceDRKeyASHostHandler := connect.NewUnaryHandler( + DaemonServiceDRKeyASHostProcedure, + svc.DRKeyASHost, + connect.WithSchema(daemonServiceDRKeyASHostMethodDescriptor), + connect.WithHandlerOptions(opts...), + ) + daemonServiceDRKeyHostASHandler := connect.NewUnaryHandler( + DaemonServiceDRKeyHostASProcedure, + svc.DRKeyHostAS, + connect.WithSchema(daemonServiceDRKeyHostASMethodDescriptor), + connect.WithHandlerOptions(opts...), + ) + daemonServiceDRKeyHostHostHandler := connect.NewUnaryHandler( + DaemonServiceDRKeyHostHostProcedure, + svc.DRKeyHostHost, + connect.WithSchema(daemonServiceDRKeyHostHostMethodDescriptor), + connect.WithHandlerOptions(opts...), + ) + return "/proto.daemon.v1.DaemonService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + switch r.URL.Path { + case DaemonServicePathsProcedure: + daemonServicePathsHandler.ServeHTTP(w, r) + case DaemonServiceASProcedure: + daemonServiceASHandler.ServeHTTP(w, r) + case DaemonServiceInterfacesProcedure: + daemonServiceInterfacesHandler.ServeHTTP(w, r) + case DaemonServiceServicesProcedure: + daemonServiceServicesHandler.ServeHTTP(w, r) + case DaemonServiceNotifyInterfaceDownProcedure: + daemonServiceNotifyInterfaceDownHandler.ServeHTTP(w, r) + case DaemonServicePortRangeProcedure: + daemonServicePortRangeHandler.ServeHTTP(w, r) + case DaemonServiceDRKeyASHostProcedure: + daemonServiceDRKeyASHostHandler.ServeHTTP(w, r) + case DaemonServiceDRKeyHostASProcedure: + daemonServiceDRKeyHostASHandler.ServeHTTP(w, r) + case DaemonServiceDRKeyHostHostProcedure: + daemonServiceDRKeyHostHostHandler.ServeHTTP(w, r) + default: + http.NotFound(w, r) + } + }) +} + +// UnimplementedDaemonServiceHandler returns CodeUnimplemented from all methods. +type UnimplementedDaemonServiceHandler struct{} + +func (UnimplementedDaemonServiceHandler) Paths(context.Context, *connect.Request[daemon.PathsRequest]) (*connect.Response[daemon.PathsResponse], error) { + return nil, connect.NewError(connect.CodeUnimplemented, errors.New("proto.daemon.v1.DaemonService.Paths is not implemented")) +} + +func (UnimplementedDaemonServiceHandler) AS(context.Context, *connect.Request[daemon.ASRequest]) (*connect.Response[daemon.ASResponse], error) { + return nil, connect.NewError(connect.CodeUnimplemented, errors.New("proto.daemon.v1.DaemonService.AS is not implemented")) +} + +func (UnimplementedDaemonServiceHandler) Interfaces(context.Context, *connect.Request[daemon.InterfacesRequest]) (*connect.Response[daemon.InterfacesResponse], error) { + return nil, connect.NewError(connect.CodeUnimplemented, errors.New("proto.daemon.v1.DaemonService.Interfaces is not implemented")) +} + +func (UnimplementedDaemonServiceHandler) Services(context.Context, *connect.Request[daemon.ServicesRequest]) (*connect.Response[daemon.ServicesResponse], error) { + return nil, connect.NewError(connect.CodeUnimplemented, errors.New("proto.daemon.v1.DaemonService.Services is not implemented")) +} + +func (UnimplementedDaemonServiceHandler) NotifyInterfaceDown(context.Context, *connect.Request[daemon.NotifyInterfaceDownRequest]) (*connect.Response[daemon.NotifyInterfaceDownResponse], error) { + return nil, connect.NewError(connect.CodeUnimplemented, errors.New("proto.daemon.v1.DaemonService.NotifyInterfaceDown is not implemented")) +} + +func (UnimplementedDaemonServiceHandler) PortRange(context.Context, *connect.Request[emptypb.Empty]) (*connect.Response[daemon.PortRangeResponse], error) { + return nil, connect.NewError(connect.CodeUnimplemented, errors.New("proto.daemon.v1.DaemonService.PortRange is not implemented")) +} + +func (UnimplementedDaemonServiceHandler) DRKeyASHost(context.Context, *connect.Request[daemon.DRKeyASHostRequest]) (*connect.Response[daemon.DRKeyASHostResponse], error) { + return nil, connect.NewError(connect.CodeUnimplemented, errors.New("proto.daemon.v1.DaemonService.DRKeyASHost is not implemented")) +} + +func (UnimplementedDaemonServiceHandler) DRKeyHostAS(context.Context, *connect.Request[daemon.DRKeyHostASRequest]) (*connect.Response[daemon.DRKeyHostASResponse], error) { + return nil, connect.NewError(connect.CodeUnimplemented, errors.New("proto.daemon.v1.DaemonService.DRKeyHostAS is not implemented")) +} + +func (UnimplementedDaemonServiceHandler) DRKeyHostHost(context.Context, *connect.Request[daemon.DRKeyHostHostRequest]) (*connect.Response[daemon.DRKeyHostHostResponse], error) { + return nil, connect.NewError(connect.CodeUnimplemented, errors.New("proto.daemon.v1.DaemonService.DRKeyHostHost is not implemented")) +} diff --git a/pkg/proto/discovery/v1/discoveryconnect/BUILD.bazel b/pkg/proto/discovery/v1/discoveryconnect/BUILD.bazel new file mode 100644 index 0000000000..22cc8643b8 --- /dev/null +++ b/pkg/proto/discovery/v1/discoveryconnect/BUILD.bazel @@ -0,0 +1,6 @@ +load("//tools/proto:connect.bzl", "go_connect_library") + +go_connect_library( + name = "go_default_library", + proto = "discovery", +) diff --git a/pkg/proto/discovery/v1/discoveryconnect/discovery.connect.go b/pkg/proto/discovery/v1/discoveryconnect/discovery.connect.go new file mode 100644 index 0000000000..7fbe31c293 --- /dev/null +++ b/pkg/proto/discovery/v1/discoveryconnect/discovery.connect.go @@ -0,0 +1,143 @@ +// Code generated by protoc-gen-connect-go. DO NOT EDIT. +// +// Source: proto/discovery/v1/discovery.proto + +package discoveryconnect + +import ( + connect "connectrpc.com/connect" + context "context" + errors "errors" + discovery "github.com/scionproto/scion/pkg/proto/discovery" + http "net/http" + strings "strings" +) + +// This is a compile-time assertion to ensure that this generated file and the connect package are +// compatible. If you get a compiler error that this constant is not defined, this code was +// generated with a version of connect newer than the one compiled into your binary. You can fix the +// problem by either regenerating this code with an older version of connect or updating the connect +// version compiled into your binary. +const _ = connect.IsAtLeastVersion1_13_0 + +const ( + // DiscoveryServiceName is the fully-qualified name of the DiscoveryService service. + DiscoveryServiceName = "proto.discovery.v1.DiscoveryService" +) + +// These constants are the fully-qualified names of the RPCs defined in this package. They're +// exposed at runtime as Spec.Procedure and as the final two segments of the HTTP route. +// +// Note that these are different from the fully-qualified method names used by +// google.golang.org/protobuf/reflect/protoreflect. To convert from these constants to +// reflection-formatted method names, remove the leading slash and convert the remaining slash to a +// period. +const ( + // DiscoveryServiceGatewaysProcedure is the fully-qualified name of the DiscoveryService's Gateways + // RPC. + DiscoveryServiceGatewaysProcedure = "/proto.discovery.v1.DiscoveryService/Gateways" + // DiscoveryServiceHiddenSegmentServicesProcedure is the fully-qualified name of the + // DiscoveryService's HiddenSegmentServices RPC. + DiscoveryServiceHiddenSegmentServicesProcedure = "/proto.discovery.v1.DiscoveryService/HiddenSegmentServices" +) + +// These variables are the protoreflect.Descriptor objects for the RPCs defined in this package. +var ( + discoveryServiceServiceDescriptor = discovery.File_proto_discovery_v1_discovery_proto.Services().ByName("DiscoveryService") + discoveryServiceGatewaysMethodDescriptor = discoveryServiceServiceDescriptor.Methods().ByName("Gateways") + discoveryServiceHiddenSegmentServicesMethodDescriptor = discoveryServiceServiceDescriptor.Methods().ByName("HiddenSegmentServices") +) + +// DiscoveryServiceClient is a client for the proto.discovery.v1.DiscoveryService service. +type DiscoveryServiceClient interface { + Gateways(context.Context, *connect.Request[discovery.GatewaysRequest]) (*connect.Response[discovery.GatewaysResponse], error) + HiddenSegmentServices(context.Context, *connect.Request[discovery.HiddenSegmentServicesRequest]) (*connect.Response[discovery.HiddenSegmentServicesResponse], error) +} + +// NewDiscoveryServiceClient constructs a client for the proto.discovery.v1.DiscoveryService +// service. By default, it uses the Connect protocol with the binary Protobuf Codec, asks for +// gzipped responses, and sends uncompressed requests. To use the gRPC or gRPC-Web protocols, supply +// the connect.WithGRPC() or connect.WithGRPCWeb() options. +// +// The URL supplied here should be the base URL for the Connect or gRPC server (for example, +// http://api.acme.com or https://acme.com/grpc). +func NewDiscoveryServiceClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) DiscoveryServiceClient { + baseURL = strings.TrimRight(baseURL, "/") + return &discoveryServiceClient{ + gateways: connect.NewClient[discovery.GatewaysRequest, discovery.GatewaysResponse]( + httpClient, + baseURL+DiscoveryServiceGatewaysProcedure, + connect.WithSchema(discoveryServiceGatewaysMethodDescriptor), + connect.WithClientOptions(opts...), + ), + hiddenSegmentServices: connect.NewClient[discovery.HiddenSegmentServicesRequest, discovery.HiddenSegmentServicesResponse]( + httpClient, + baseURL+DiscoveryServiceHiddenSegmentServicesProcedure, + connect.WithSchema(discoveryServiceHiddenSegmentServicesMethodDescriptor), + connect.WithClientOptions(opts...), + ), + } +} + +// discoveryServiceClient implements DiscoveryServiceClient. +type discoveryServiceClient struct { + gateways *connect.Client[discovery.GatewaysRequest, discovery.GatewaysResponse] + hiddenSegmentServices *connect.Client[discovery.HiddenSegmentServicesRequest, discovery.HiddenSegmentServicesResponse] +} + +// Gateways calls proto.discovery.v1.DiscoveryService.Gateways. +func (c *discoveryServiceClient) Gateways(ctx context.Context, req *connect.Request[discovery.GatewaysRequest]) (*connect.Response[discovery.GatewaysResponse], error) { + return c.gateways.CallUnary(ctx, req) +} + +// HiddenSegmentServices calls proto.discovery.v1.DiscoveryService.HiddenSegmentServices. +func (c *discoveryServiceClient) HiddenSegmentServices(ctx context.Context, req *connect.Request[discovery.HiddenSegmentServicesRequest]) (*connect.Response[discovery.HiddenSegmentServicesResponse], error) { + return c.hiddenSegmentServices.CallUnary(ctx, req) +} + +// DiscoveryServiceHandler is an implementation of the proto.discovery.v1.DiscoveryService service. +type DiscoveryServiceHandler interface { + Gateways(context.Context, *connect.Request[discovery.GatewaysRequest]) (*connect.Response[discovery.GatewaysResponse], error) + HiddenSegmentServices(context.Context, *connect.Request[discovery.HiddenSegmentServicesRequest]) (*connect.Response[discovery.HiddenSegmentServicesResponse], error) +} + +// NewDiscoveryServiceHandler builds an HTTP handler from the service implementation. It returns the +// path on which to mount the handler and the handler itself. +// +// By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf +// and JSON codecs. They also support gzip compression. +func NewDiscoveryServiceHandler(svc DiscoveryServiceHandler, opts ...connect.HandlerOption) (string, http.Handler) { + discoveryServiceGatewaysHandler := connect.NewUnaryHandler( + DiscoveryServiceGatewaysProcedure, + svc.Gateways, + connect.WithSchema(discoveryServiceGatewaysMethodDescriptor), + connect.WithHandlerOptions(opts...), + ) + discoveryServiceHiddenSegmentServicesHandler := connect.NewUnaryHandler( + DiscoveryServiceHiddenSegmentServicesProcedure, + svc.HiddenSegmentServices, + connect.WithSchema(discoveryServiceHiddenSegmentServicesMethodDescriptor), + connect.WithHandlerOptions(opts...), + ) + return "/proto.discovery.v1.DiscoveryService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + switch r.URL.Path { + case DiscoveryServiceGatewaysProcedure: + discoveryServiceGatewaysHandler.ServeHTTP(w, r) + case DiscoveryServiceHiddenSegmentServicesProcedure: + discoveryServiceHiddenSegmentServicesHandler.ServeHTTP(w, r) + default: + http.NotFound(w, r) + } + }) +} + +// UnimplementedDiscoveryServiceHandler returns CodeUnimplemented from all methods. +type UnimplementedDiscoveryServiceHandler struct{} + +func (UnimplementedDiscoveryServiceHandler) Gateways(context.Context, *connect.Request[discovery.GatewaysRequest]) (*connect.Response[discovery.GatewaysResponse], error) { + return nil, connect.NewError(connect.CodeUnimplemented, errors.New("proto.discovery.v1.DiscoveryService.Gateways is not implemented")) +} + +func (UnimplementedDiscoveryServiceHandler) HiddenSegmentServices(context.Context, *connect.Request[discovery.HiddenSegmentServicesRequest]) (*connect.Response[discovery.HiddenSegmentServicesResponse], error) { + return nil, connect.NewError(connect.CodeUnimplemented, errors.New("proto.discovery.v1.DiscoveryService.HiddenSegmentServices is not implemented")) +} diff --git a/pkg/proto/gateway/v1/gatewayconnect/BUILD.bazel b/pkg/proto/gateway/v1/gatewayconnect/BUILD.bazel new file mode 100644 index 0000000000..d69e0d7fbf --- /dev/null +++ b/pkg/proto/gateway/v1/gatewayconnect/BUILD.bazel @@ -0,0 +1,9 @@ +load("//tools/proto:connect.bzl", "go_connect_library") + +go_connect_library( + name = "go_default_library", + files = [ + "prefix.connect.go", + ], + proto = "gateway", +) diff --git a/pkg/proto/gateway/v1/gatewayconnect/prefix.connect.go b/pkg/proto/gateway/v1/gatewayconnect/prefix.connect.go new file mode 100644 index 0000000000..485440f1fe --- /dev/null +++ b/pkg/proto/gateway/v1/gatewayconnect/prefix.connect.go @@ -0,0 +1,113 @@ +// Code generated by protoc-gen-connect-go. DO NOT EDIT. +// +// Source: proto/gateway/v1/prefix.proto + +package gatewayconnect + +import ( + connect "connectrpc.com/connect" + context "context" + errors "errors" + gateway "github.com/scionproto/scion/pkg/proto/gateway" + http "net/http" + strings "strings" +) + +// This is a compile-time assertion to ensure that this generated file and the connect package are +// compatible. If you get a compiler error that this constant is not defined, this code was +// generated with a version of connect newer than the one compiled into your binary. You can fix the +// problem by either regenerating this code with an older version of connect or updating the connect +// version compiled into your binary. +const _ = connect.IsAtLeastVersion1_13_0 + +const ( + // IPPrefixesServiceName is the fully-qualified name of the IPPrefixesService service. + IPPrefixesServiceName = "proto.gateway.v1.IPPrefixesService" +) + +// These constants are the fully-qualified names of the RPCs defined in this package. They're +// exposed at runtime as Spec.Procedure and as the final two segments of the HTTP route. +// +// Note that these are different from the fully-qualified method names used by +// google.golang.org/protobuf/reflect/protoreflect. To convert from these constants to +// reflection-formatted method names, remove the leading slash and convert the remaining slash to a +// period. +const ( + // IPPrefixesServicePrefixesProcedure is the fully-qualified name of the IPPrefixesService's + // Prefixes RPC. + IPPrefixesServicePrefixesProcedure = "/proto.gateway.v1.IPPrefixesService/Prefixes" +) + +// These variables are the protoreflect.Descriptor objects for the RPCs defined in this package. +var ( + iPPrefixesServiceServiceDescriptor = gateway.File_proto_gateway_v1_prefix_proto.Services().ByName("IPPrefixesService") + iPPrefixesServicePrefixesMethodDescriptor = iPPrefixesServiceServiceDescriptor.Methods().ByName("Prefixes") +) + +// IPPrefixesServiceClient is a client for the proto.gateway.v1.IPPrefixesService service. +type IPPrefixesServiceClient interface { + Prefixes(context.Context, *connect.Request[gateway.PrefixesRequest]) (*connect.Response[gateway.PrefixesResponse], error) +} + +// NewIPPrefixesServiceClient constructs a client for the proto.gateway.v1.IPPrefixesService +// service. By default, it uses the Connect protocol with the binary Protobuf Codec, asks for +// gzipped responses, and sends uncompressed requests. To use the gRPC or gRPC-Web protocols, supply +// the connect.WithGRPC() or connect.WithGRPCWeb() options. +// +// The URL supplied here should be the base URL for the Connect or gRPC server (for example, +// http://api.acme.com or https://acme.com/grpc). +func NewIPPrefixesServiceClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) IPPrefixesServiceClient { + baseURL = strings.TrimRight(baseURL, "/") + return &iPPrefixesServiceClient{ + prefixes: connect.NewClient[gateway.PrefixesRequest, gateway.PrefixesResponse]( + httpClient, + baseURL+IPPrefixesServicePrefixesProcedure, + connect.WithSchema(iPPrefixesServicePrefixesMethodDescriptor), + connect.WithClientOptions(opts...), + ), + } +} + +// iPPrefixesServiceClient implements IPPrefixesServiceClient. +type iPPrefixesServiceClient struct { + prefixes *connect.Client[gateway.PrefixesRequest, gateway.PrefixesResponse] +} + +// Prefixes calls proto.gateway.v1.IPPrefixesService.Prefixes. +func (c *iPPrefixesServiceClient) Prefixes(ctx context.Context, req *connect.Request[gateway.PrefixesRequest]) (*connect.Response[gateway.PrefixesResponse], error) { + return c.prefixes.CallUnary(ctx, req) +} + +// IPPrefixesServiceHandler is an implementation of the proto.gateway.v1.IPPrefixesService service. +type IPPrefixesServiceHandler interface { + Prefixes(context.Context, *connect.Request[gateway.PrefixesRequest]) (*connect.Response[gateway.PrefixesResponse], error) +} + +// NewIPPrefixesServiceHandler builds an HTTP handler from the service implementation. It returns +// the path on which to mount the handler and the handler itself. +// +// By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf +// and JSON codecs. They also support gzip compression. +func NewIPPrefixesServiceHandler(svc IPPrefixesServiceHandler, opts ...connect.HandlerOption) (string, http.Handler) { + iPPrefixesServicePrefixesHandler := connect.NewUnaryHandler( + IPPrefixesServicePrefixesProcedure, + svc.Prefixes, + connect.WithSchema(iPPrefixesServicePrefixesMethodDescriptor), + connect.WithHandlerOptions(opts...), + ) + return "/proto.gateway.v1.IPPrefixesService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + switch r.URL.Path { + case IPPrefixesServicePrefixesProcedure: + iPPrefixesServicePrefixesHandler.ServeHTTP(w, r) + default: + http.NotFound(w, r) + } + }) +} + +// UnimplementedIPPrefixesServiceHandler returns CodeUnimplemented from all methods. +type UnimplementedIPPrefixesServiceHandler struct{} + +func (UnimplementedIPPrefixesServiceHandler) Prefixes(context.Context, *connect.Request[gateway.PrefixesRequest]) (*connect.Response[gateway.PrefixesResponse], error) { + return nil, connect.NewError(connect.CodeUnimplemented, errors.New("proto.gateway.v1.IPPrefixesService.Prefixes is not implemented")) +} diff --git a/pkg/proto/hidden_segment/v1/hidden_segmentconnect/BUILD.bazel b/pkg/proto/hidden_segment/v1/hidden_segmentconnect/BUILD.bazel new file mode 100644 index 0000000000..a154f0afdb --- /dev/null +++ b/pkg/proto/hidden_segment/v1/hidden_segmentconnect/BUILD.bazel @@ -0,0 +1,6 @@ +load("//tools/proto:connect.bzl", "go_connect_library") + +go_connect_library( + name = "go_default_library", + proto = "hidden_segment", +) diff --git a/pkg/proto/hidden_segment/v1/hidden_segmentconnect/hidden_segment.connect.go b/pkg/proto/hidden_segment/v1/hidden_segmentconnect/hidden_segment.connect.go new file mode 100644 index 0000000000..37480c4368 --- /dev/null +++ b/pkg/proto/hidden_segment/v1/hidden_segmentconnect/hidden_segment.connect.go @@ -0,0 +1,280 @@ +// Code generated by protoc-gen-connect-go. DO NOT EDIT. +// +// Source: proto/hidden_segment/v1/hidden_segment.proto + +package hidden_segmentconnect + +import ( + connect "connectrpc.com/connect" + context "context" + errors "errors" + hidden_segment "github.com/scionproto/scion/pkg/proto/hidden_segment" + http "net/http" + strings "strings" +) + +// This is a compile-time assertion to ensure that this generated file and the connect package are +// compatible. If you get a compiler error that this constant is not defined, this code was +// generated with a version of connect newer than the one compiled into your binary. You can fix the +// problem by either regenerating this code with an older version of connect or updating the connect +// version compiled into your binary. +const _ = connect.IsAtLeastVersion1_13_0 + +const ( + // HiddenSegmentRegistrationServiceName is the fully-qualified name of the + // HiddenSegmentRegistrationService service. + HiddenSegmentRegistrationServiceName = "proto.hidden_segment.v1.HiddenSegmentRegistrationService" + // HiddenSegmentLookupServiceName is the fully-qualified name of the HiddenSegmentLookupService + // service. + HiddenSegmentLookupServiceName = "proto.hidden_segment.v1.HiddenSegmentLookupService" + // AuthoritativeHiddenSegmentLookupServiceName is the fully-qualified name of the + // AuthoritativeHiddenSegmentLookupService service. + AuthoritativeHiddenSegmentLookupServiceName = "proto.hidden_segment.v1.AuthoritativeHiddenSegmentLookupService" +) + +// These constants are the fully-qualified names of the RPCs defined in this package. They're +// exposed at runtime as Spec.Procedure and as the final two segments of the HTTP route. +// +// Note that these are different from the fully-qualified method names used by +// google.golang.org/protobuf/reflect/protoreflect. To convert from these constants to +// reflection-formatted method names, remove the leading slash and convert the remaining slash to a +// period. +const ( + // HiddenSegmentRegistrationServiceHiddenSegmentRegistrationProcedure is the fully-qualified name of + // the HiddenSegmentRegistrationService's HiddenSegmentRegistration RPC. + HiddenSegmentRegistrationServiceHiddenSegmentRegistrationProcedure = "/proto.hidden_segment.v1.HiddenSegmentRegistrationService/HiddenSegmentRegistration" + // HiddenSegmentLookupServiceHiddenSegmentsProcedure is the fully-qualified name of the + // HiddenSegmentLookupService's HiddenSegments RPC. + HiddenSegmentLookupServiceHiddenSegmentsProcedure = "/proto.hidden_segment.v1.HiddenSegmentLookupService/HiddenSegments" + // AuthoritativeHiddenSegmentLookupServiceAuthoritativeHiddenSegmentsProcedure is the + // fully-qualified name of the AuthoritativeHiddenSegmentLookupService's AuthoritativeHiddenSegments + // RPC. + AuthoritativeHiddenSegmentLookupServiceAuthoritativeHiddenSegmentsProcedure = "/proto.hidden_segment.v1.AuthoritativeHiddenSegmentLookupService/AuthoritativeHiddenSegments" +) + +// These variables are the protoreflect.Descriptor objects for the RPCs defined in this package. +var ( + hiddenSegmentRegistrationServiceServiceDescriptor = hidden_segment.File_proto_hidden_segment_v1_hidden_segment_proto.Services().ByName("HiddenSegmentRegistrationService") + hiddenSegmentRegistrationServiceHiddenSegmentRegistrationMethodDescriptor = hiddenSegmentRegistrationServiceServiceDescriptor.Methods().ByName("HiddenSegmentRegistration") + hiddenSegmentLookupServiceServiceDescriptor = hidden_segment.File_proto_hidden_segment_v1_hidden_segment_proto.Services().ByName("HiddenSegmentLookupService") + hiddenSegmentLookupServiceHiddenSegmentsMethodDescriptor = hiddenSegmentLookupServiceServiceDescriptor.Methods().ByName("HiddenSegments") + authoritativeHiddenSegmentLookupServiceServiceDescriptor = hidden_segment.File_proto_hidden_segment_v1_hidden_segment_proto.Services().ByName("AuthoritativeHiddenSegmentLookupService") + authoritativeHiddenSegmentLookupServiceAuthoritativeHiddenSegmentsMethodDescriptor = authoritativeHiddenSegmentLookupServiceServiceDescriptor.Methods().ByName("AuthoritativeHiddenSegments") +) + +// HiddenSegmentRegistrationServiceClient is a client for the +// proto.hidden_segment.v1.HiddenSegmentRegistrationService service. +type HiddenSegmentRegistrationServiceClient interface { + HiddenSegmentRegistration(context.Context, *connect.Request[hidden_segment.HiddenSegmentRegistrationRequest]) (*connect.Response[hidden_segment.HiddenSegmentRegistrationResponse], error) +} + +// NewHiddenSegmentRegistrationServiceClient constructs a client for the +// proto.hidden_segment.v1.HiddenSegmentRegistrationService service. By default, it uses the Connect +// protocol with the binary Protobuf Codec, asks for gzipped responses, and sends uncompressed +// requests. To use the gRPC or gRPC-Web protocols, supply the connect.WithGRPC() or +// connect.WithGRPCWeb() options. +// +// The URL supplied here should be the base URL for the Connect or gRPC server (for example, +// http://api.acme.com or https://acme.com/grpc). +func NewHiddenSegmentRegistrationServiceClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) HiddenSegmentRegistrationServiceClient { + baseURL = strings.TrimRight(baseURL, "/") + return &hiddenSegmentRegistrationServiceClient{ + hiddenSegmentRegistration: connect.NewClient[hidden_segment.HiddenSegmentRegistrationRequest, hidden_segment.HiddenSegmentRegistrationResponse]( + httpClient, + baseURL+HiddenSegmentRegistrationServiceHiddenSegmentRegistrationProcedure, + connect.WithSchema(hiddenSegmentRegistrationServiceHiddenSegmentRegistrationMethodDescriptor), + connect.WithClientOptions(opts...), + ), + } +} + +// hiddenSegmentRegistrationServiceClient implements HiddenSegmentRegistrationServiceClient. +type hiddenSegmentRegistrationServiceClient struct { + hiddenSegmentRegistration *connect.Client[hidden_segment.HiddenSegmentRegistrationRequest, hidden_segment.HiddenSegmentRegistrationResponse] +} + +// HiddenSegmentRegistration calls +// proto.hidden_segment.v1.HiddenSegmentRegistrationService.HiddenSegmentRegistration. +func (c *hiddenSegmentRegistrationServiceClient) HiddenSegmentRegistration(ctx context.Context, req *connect.Request[hidden_segment.HiddenSegmentRegistrationRequest]) (*connect.Response[hidden_segment.HiddenSegmentRegistrationResponse], error) { + return c.hiddenSegmentRegistration.CallUnary(ctx, req) +} + +// HiddenSegmentRegistrationServiceHandler is an implementation of the +// proto.hidden_segment.v1.HiddenSegmentRegistrationService service. +type HiddenSegmentRegistrationServiceHandler interface { + HiddenSegmentRegistration(context.Context, *connect.Request[hidden_segment.HiddenSegmentRegistrationRequest]) (*connect.Response[hidden_segment.HiddenSegmentRegistrationResponse], error) +} + +// NewHiddenSegmentRegistrationServiceHandler builds an HTTP handler from the service +// implementation. It returns the path on which to mount the handler and the handler itself. +// +// By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf +// and JSON codecs. They also support gzip compression. +func NewHiddenSegmentRegistrationServiceHandler(svc HiddenSegmentRegistrationServiceHandler, opts ...connect.HandlerOption) (string, http.Handler) { + hiddenSegmentRegistrationServiceHiddenSegmentRegistrationHandler := connect.NewUnaryHandler( + HiddenSegmentRegistrationServiceHiddenSegmentRegistrationProcedure, + svc.HiddenSegmentRegistration, + connect.WithSchema(hiddenSegmentRegistrationServiceHiddenSegmentRegistrationMethodDescriptor), + connect.WithHandlerOptions(opts...), + ) + return "/proto.hidden_segment.v1.HiddenSegmentRegistrationService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + switch r.URL.Path { + case HiddenSegmentRegistrationServiceHiddenSegmentRegistrationProcedure: + hiddenSegmentRegistrationServiceHiddenSegmentRegistrationHandler.ServeHTTP(w, r) + default: + http.NotFound(w, r) + } + }) +} + +// UnimplementedHiddenSegmentRegistrationServiceHandler returns CodeUnimplemented from all methods. +type UnimplementedHiddenSegmentRegistrationServiceHandler struct{} + +func (UnimplementedHiddenSegmentRegistrationServiceHandler) HiddenSegmentRegistration(context.Context, *connect.Request[hidden_segment.HiddenSegmentRegistrationRequest]) (*connect.Response[hidden_segment.HiddenSegmentRegistrationResponse], error) { + return nil, connect.NewError(connect.CodeUnimplemented, errors.New("proto.hidden_segment.v1.HiddenSegmentRegistrationService.HiddenSegmentRegistration is not implemented")) +} + +// HiddenSegmentLookupServiceClient is a client for the +// proto.hidden_segment.v1.HiddenSegmentLookupService service. +type HiddenSegmentLookupServiceClient interface { + HiddenSegments(context.Context, *connect.Request[hidden_segment.HiddenSegmentsRequest]) (*connect.Response[hidden_segment.HiddenSegmentsResponse], error) +} + +// NewHiddenSegmentLookupServiceClient constructs a client for the +// proto.hidden_segment.v1.HiddenSegmentLookupService service. By default, it uses the Connect +// protocol with the binary Protobuf Codec, asks for gzipped responses, and sends uncompressed +// requests. To use the gRPC or gRPC-Web protocols, supply the connect.WithGRPC() or +// connect.WithGRPCWeb() options. +// +// The URL supplied here should be the base URL for the Connect or gRPC server (for example, +// http://api.acme.com or https://acme.com/grpc). +func NewHiddenSegmentLookupServiceClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) HiddenSegmentLookupServiceClient { + baseURL = strings.TrimRight(baseURL, "/") + return &hiddenSegmentLookupServiceClient{ + hiddenSegments: connect.NewClient[hidden_segment.HiddenSegmentsRequest, hidden_segment.HiddenSegmentsResponse]( + httpClient, + baseURL+HiddenSegmentLookupServiceHiddenSegmentsProcedure, + connect.WithSchema(hiddenSegmentLookupServiceHiddenSegmentsMethodDescriptor), + connect.WithClientOptions(opts...), + ), + } +} + +// hiddenSegmentLookupServiceClient implements HiddenSegmentLookupServiceClient. +type hiddenSegmentLookupServiceClient struct { + hiddenSegments *connect.Client[hidden_segment.HiddenSegmentsRequest, hidden_segment.HiddenSegmentsResponse] +} + +// HiddenSegments calls proto.hidden_segment.v1.HiddenSegmentLookupService.HiddenSegments. +func (c *hiddenSegmentLookupServiceClient) HiddenSegments(ctx context.Context, req *connect.Request[hidden_segment.HiddenSegmentsRequest]) (*connect.Response[hidden_segment.HiddenSegmentsResponse], error) { + return c.hiddenSegments.CallUnary(ctx, req) +} + +// HiddenSegmentLookupServiceHandler is an implementation of the +// proto.hidden_segment.v1.HiddenSegmentLookupService service. +type HiddenSegmentLookupServiceHandler interface { + HiddenSegments(context.Context, *connect.Request[hidden_segment.HiddenSegmentsRequest]) (*connect.Response[hidden_segment.HiddenSegmentsResponse], error) +} + +// NewHiddenSegmentLookupServiceHandler builds an HTTP handler from the service implementation. It +// returns the path on which to mount the handler and the handler itself. +// +// By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf +// and JSON codecs. They also support gzip compression. +func NewHiddenSegmentLookupServiceHandler(svc HiddenSegmentLookupServiceHandler, opts ...connect.HandlerOption) (string, http.Handler) { + hiddenSegmentLookupServiceHiddenSegmentsHandler := connect.NewUnaryHandler( + HiddenSegmentLookupServiceHiddenSegmentsProcedure, + svc.HiddenSegments, + connect.WithSchema(hiddenSegmentLookupServiceHiddenSegmentsMethodDescriptor), + connect.WithHandlerOptions(opts...), + ) + return "/proto.hidden_segment.v1.HiddenSegmentLookupService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + switch r.URL.Path { + case HiddenSegmentLookupServiceHiddenSegmentsProcedure: + hiddenSegmentLookupServiceHiddenSegmentsHandler.ServeHTTP(w, r) + default: + http.NotFound(w, r) + } + }) +} + +// UnimplementedHiddenSegmentLookupServiceHandler returns CodeUnimplemented from all methods. +type UnimplementedHiddenSegmentLookupServiceHandler struct{} + +func (UnimplementedHiddenSegmentLookupServiceHandler) HiddenSegments(context.Context, *connect.Request[hidden_segment.HiddenSegmentsRequest]) (*connect.Response[hidden_segment.HiddenSegmentsResponse], error) { + return nil, connect.NewError(connect.CodeUnimplemented, errors.New("proto.hidden_segment.v1.HiddenSegmentLookupService.HiddenSegments is not implemented")) +} + +// AuthoritativeHiddenSegmentLookupServiceClient is a client for the +// proto.hidden_segment.v1.AuthoritativeHiddenSegmentLookupService service. +type AuthoritativeHiddenSegmentLookupServiceClient interface { + AuthoritativeHiddenSegments(context.Context, *connect.Request[hidden_segment.AuthoritativeHiddenSegmentsRequest]) (*connect.Response[hidden_segment.AuthoritativeHiddenSegmentsResponse], error) +} + +// NewAuthoritativeHiddenSegmentLookupServiceClient constructs a client for the +// proto.hidden_segment.v1.AuthoritativeHiddenSegmentLookupService service. By default, it uses the +// Connect protocol with the binary Protobuf Codec, asks for gzipped responses, and sends +// uncompressed requests. To use the gRPC or gRPC-Web protocols, supply the connect.WithGRPC() or +// connect.WithGRPCWeb() options. +// +// The URL supplied here should be the base URL for the Connect or gRPC server (for example, +// http://api.acme.com or https://acme.com/grpc). +func NewAuthoritativeHiddenSegmentLookupServiceClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) AuthoritativeHiddenSegmentLookupServiceClient { + baseURL = strings.TrimRight(baseURL, "/") + return &authoritativeHiddenSegmentLookupServiceClient{ + authoritativeHiddenSegments: connect.NewClient[hidden_segment.AuthoritativeHiddenSegmentsRequest, hidden_segment.AuthoritativeHiddenSegmentsResponse]( + httpClient, + baseURL+AuthoritativeHiddenSegmentLookupServiceAuthoritativeHiddenSegmentsProcedure, + connect.WithSchema(authoritativeHiddenSegmentLookupServiceAuthoritativeHiddenSegmentsMethodDescriptor), + connect.WithClientOptions(opts...), + ), + } +} + +// authoritativeHiddenSegmentLookupServiceClient implements +// AuthoritativeHiddenSegmentLookupServiceClient. +type authoritativeHiddenSegmentLookupServiceClient struct { + authoritativeHiddenSegments *connect.Client[hidden_segment.AuthoritativeHiddenSegmentsRequest, hidden_segment.AuthoritativeHiddenSegmentsResponse] +} + +// AuthoritativeHiddenSegments calls +// proto.hidden_segment.v1.AuthoritativeHiddenSegmentLookupService.AuthoritativeHiddenSegments. +func (c *authoritativeHiddenSegmentLookupServiceClient) AuthoritativeHiddenSegments(ctx context.Context, req *connect.Request[hidden_segment.AuthoritativeHiddenSegmentsRequest]) (*connect.Response[hidden_segment.AuthoritativeHiddenSegmentsResponse], error) { + return c.authoritativeHiddenSegments.CallUnary(ctx, req) +} + +// AuthoritativeHiddenSegmentLookupServiceHandler is an implementation of the +// proto.hidden_segment.v1.AuthoritativeHiddenSegmentLookupService service. +type AuthoritativeHiddenSegmentLookupServiceHandler interface { + AuthoritativeHiddenSegments(context.Context, *connect.Request[hidden_segment.AuthoritativeHiddenSegmentsRequest]) (*connect.Response[hidden_segment.AuthoritativeHiddenSegmentsResponse], error) +} + +// NewAuthoritativeHiddenSegmentLookupServiceHandler builds an HTTP handler from the service +// implementation. It returns the path on which to mount the handler and the handler itself. +// +// By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf +// and JSON codecs. They also support gzip compression. +func NewAuthoritativeHiddenSegmentLookupServiceHandler(svc AuthoritativeHiddenSegmentLookupServiceHandler, opts ...connect.HandlerOption) (string, http.Handler) { + authoritativeHiddenSegmentLookupServiceAuthoritativeHiddenSegmentsHandler := connect.NewUnaryHandler( + AuthoritativeHiddenSegmentLookupServiceAuthoritativeHiddenSegmentsProcedure, + svc.AuthoritativeHiddenSegments, + connect.WithSchema(authoritativeHiddenSegmentLookupServiceAuthoritativeHiddenSegmentsMethodDescriptor), + connect.WithHandlerOptions(opts...), + ) + return "/proto.hidden_segment.v1.AuthoritativeHiddenSegmentLookupService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + switch r.URL.Path { + case AuthoritativeHiddenSegmentLookupServiceAuthoritativeHiddenSegmentsProcedure: + authoritativeHiddenSegmentLookupServiceAuthoritativeHiddenSegmentsHandler.ServeHTTP(w, r) + default: + http.NotFound(w, r) + } + }) +} + +// UnimplementedAuthoritativeHiddenSegmentLookupServiceHandler returns CodeUnimplemented from all +// methods. +type UnimplementedAuthoritativeHiddenSegmentLookupServiceHandler struct{} + +func (UnimplementedAuthoritativeHiddenSegmentLookupServiceHandler) AuthoritativeHiddenSegments(context.Context, *connect.Request[hidden_segment.AuthoritativeHiddenSegmentsRequest]) (*connect.Response[hidden_segment.AuthoritativeHiddenSegmentsResponse], error) { + return nil, connect.NewError(connect.CodeUnimplemented, errors.New("proto.hidden_segment.v1.AuthoritativeHiddenSegmentLookupService.AuthoritativeHiddenSegments is not implemented")) +} diff --git a/private/must/BUILD.bazel b/private/must/BUILD.bazel new file mode 100644 index 0000000000..a38b98d30c --- /dev/null +++ b/private/must/BUILD.bazel @@ -0,0 +1,8 @@ +load("//tools/lint:go.bzl", "go_library") + +go_library( + name = "go_default_library", + srcs = ["must.go"], + importpath = "github.com/scionproto/scion/private/must", + visibility = ["//visibility:public"], +) diff --git a/private/must/must.go b/private/must/must.go new file mode 100644 index 0000000000..3df16f66f9 --- /dev/null +++ b/private/must/must.go @@ -0,0 +1,30 @@ +// Copyright 2024 Anapaya Systems +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package must + +// Do panics if err is not nil. +func Do(err error) { + if err != nil { + panic("must: expected nil, got " + err.Error()) + } +} + +// Get panics if err is not nil. +func Get[T any](v T, err error) T { + if err != nil { + panic("must: expected nil, got " + err.Error()) + } + return v +} diff --git a/tools/proto/BUILD.bazel b/tools/proto/BUILD.bazel new file mode 100644 index 0000000000..e2b879cd94 --- /dev/null +++ b/tools/proto/BUILD.bazel @@ -0,0 +1,11 @@ +load("@io_bazel_rules_go//proto:compiler.bzl", "go_proto_compiler") + +## bazel query --output label '@com_connectrpc_connect//...' +## @com_connectrpc_connect//cmd/protoc-gen-connect-go:protoc-gen-connect-go +go_proto_compiler( + name = "connect_go_proto_compiler", + plugin = "@com_connectrpc_connect//cmd/protoc-gen-connect-go:protoc-gen-connect-go", + suffix = ".connect.go", + visibility = ["//visibility:public"], + deps = ["@com_connectrpc_connect//:go_default_library"], +) diff --git a/tools/proto/connect.bzl b/tools/proto/connect.bzl new file mode 100644 index 0000000000..5747f92271 --- /dev/null +++ b/tools/proto/connect.bzl @@ -0,0 +1,45 @@ +load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library") +load("//tools/lint:write_source_files.bzl", "write_source_files") +load("@aspect_bazel_lib//lib:copy_to_directory.bzl", "copy_to_directory") +load("@aspect_bazel_lib//lib:directory_path.bzl", "make_directory_path") + +def go_connect_library(name, proto, files = None): + # See: https://github.com/bazelbuild/rules_go/issues/3658#issuecomment-1678046338 + + go_proto_library( + name = "go_default_library", + compilers = [ + "//tools/proto:connect_go_proto_compiler", + ], + importpath = "github.com/scionproto/scion/pkg/proto/" + proto, + overrideimportpath = "github.com/scionproto/scion/pkg/proto/%s/v1/%sconnect" % (proto, proto), + proto = "//proto/%s/v1:%s" % (proto, proto), + visibility = ["//visibility:public"], + deps = ["//pkg/proto/%s:go_default_library" % proto], + ) + + file_target = "go_default_library.filegroup" + dir_target = "go_default_library.directory" + + native.filegroup( + name = file_target, + srcs = [":go_default_library"], + output_group = "go_generated_srcs", + ) + + copy_to_directory( + name = dir_target, + srcs = [file_target], + root_paths = ["**"], + ) + + if not files: + files = ["%s.connect.go" % proto] + + write_source_files( + name = "write_files", + files = { + output_file: make_directory_path("_{}_dirpath".format(output_file), dir_target, output_file) + for output_file in files + }, + )