update ingress.proto
This commit is contained in:
parent
bc86458bf2
commit
fc558b9a31
@ -21,14 +21,14 @@ type server struct {
|
||||
|
||||
func (s *server) Bypass(ctx context.Context, in *proto.BypassRequest) (*proto.BypassReply, error) {
|
||||
reply := &proto.BypassReply{}
|
||||
host := in.GetAddr()
|
||||
host := in.GetHost()
|
||||
if v, _, _ := net.SplitHostPort(host); v != "" {
|
||||
host = v
|
||||
}
|
||||
if host == "example.com" {
|
||||
reply.Ok = true
|
||||
}
|
||||
log.Printf("bypass(%s): %s, %v", in.GetClient(), in.GetAddr(), reply.Ok)
|
||||
log.Printf("bypass(%s): %s/%s, %s, %v", in.GetClient(), in.GetAddr(), in.GetNetwork(), in.GetHost(), reply.Ok)
|
||||
return reply, nil
|
||||
}
|
||||
|
||||
|
@ -21,10 +21,17 @@ type server struct {
|
||||
|
||||
func (s *server) Get(ctx context.Context, in *proto.GetRequest) (*proto.GetReply, error) {
|
||||
reply := &proto.GetReply{}
|
||||
log.Printf("ingress: %s", in.GetHost())
|
||||
log.Printf("ingress get: %s", in.GetHost())
|
||||
return reply, nil
|
||||
}
|
||||
|
||||
func (s *server) Set(ctx context.Context, in *proto.SetRequest) (*proto.SetReply, error) {
|
||||
reply := &proto.SetReply{}
|
||||
log.Printf("ingress set: %s -> %s", in.GetHost(), in.GetEndpoint())
|
||||
return reply, nil
|
||||
|
||||
}
|
||||
|
||||
func main() {
|
||||
flag.Parse()
|
||||
lis, err := net.Listen("tcp", fmt.Sprintf(":%d", *port))
|
||||
|
@ -4,8 +4,8 @@
|
||||
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.25.0-devel
|
||||
// protoc v3.14.0
|
||||
// protoc-gen-go v1.28.1
|
||||
// protoc v3.15.8
|
||||
// source: ingress.proto
|
||||
|
||||
package proto
|
||||
@ -118,6 +118,108 @@ func (x *GetReply) GetEndpoint() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
type SetRequest struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Host string `protobuf:"bytes,1,opt,name=host,proto3" json:"host,omitempty"`
|
||||
Endpoint string `protobuf:"bytes,2,opt,name=endpoint,proto3" json:"endpoint,omitempty"`
|
||||
}
|
||||
|
||||
func (x *SetRequest) Reset() {
|
||||
*x = SetRequest{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_ingress_proto_msgTypes[2]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *SetRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*SetRequest) ProtoMessage() {}
|
||||
|
||||
func (x *SetRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_ingress_proto_msgTypes[2]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use SetRequest.ProtoReflect.Descriptor instead.
|
||||
func (*SetRequest) Descriptor() ([]byte, []int) {
|
||||
return file_ingress_proto_rawDescGZIP(), []int{2}
|
||||
}
|
||||
|
||||
func (x *SetRequest) GetHost() string {
|
||||
if x != nil {
|
||||
return x.Host
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *SetRequest) GetEndpoint() string {
|
||||
if x != nil {
|
||||
return x.Endpoint
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type SetReply struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Ok bool `protobuf:"varint,1,opt,name=ok,proto3" json:"ok,omitempty"`
|
||||
}
|
||||
|
||||
func (x *SetReply) Reset() {
|
||||
*x = SetReply{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_ingress_proto_msgTypes[3]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *SetReply) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*SetReply) ProtoMessage() {}
|
||||
|
||||
func (x *SetReply) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_ingress_proto_msgTypes[3]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use SetReply.ProtoReflect.Descriptor instead.
|
||||
func (*SetReply) Descriptor() ([]byte, []int) {
|
||||
return file_ingress_proto_rawDescGZIP(), []int{3}
|
||||
}
|
||||
|
||||
func (x *SetReply) GetOk() bool {
|
||||
if x != nil {
|
||||
return x.Ok
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
var File_ingress_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_ingress_proto_rawDesc = []byte{
|
||||
@ -127,13 +229,21 @@ var file_ingress_proto_rawDesc = []byte{
|
||||
0x28, 0x09, 0x52, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x22, 0x26, 0x0a, 0x08, 0x47, 0x65, 0x74, 0x52,
|
||||
0x65, 0x70, 0x6c, 0x79, 0x12, 0x1a, 0x0a, 0x08, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74,
|
||||
0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74,
|
||||
0x32, 0x34, 0x0a, 0x07, 0x49, 0x6e, 0x67, 0x72, 0x65, 0x73, 0x73, 0x12, 0x29, 0x0a, 0x03, 0x47,
|
||||
0x65, 0x74, 0x12, 0x11, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x47, 0x65, 0x74, 0x52, 0x65,
|
||||
0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x47, 0x65,
|
||||
0x74, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x42, 0x29, 0x5a, 0x27, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62,
|
||||
0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x6f, 0x2d, 0x67, 0x6f, 0x73, 0x74, 0x2f, 0x70, 0x6c, 0x75,
|
||||
0x67, 0x69, 0x6e, 0x2f, 0x69, 0x6e, 0x67, 0x72, 0x65, 0x73, 0x73, 0x2f, 0x70, 0x72, 0x6f, 0x74,
|
||||
0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
0x22, 0x3c, 0x0a, 0x0a, 0x53, 0x65, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12,
|
||||
0x0a, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x68, 0x6f,
|
||||
0x73, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x18, 0x02,
|
||||
0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x22, 0x1a,
|
||||
0x0a, 0x08, 0x53, 0x65, 0x74, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x0e, 0x0a, 0x02, 0x6f, 0x6b,
|
||||
0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x02, 0x6f, 0x6b, 0x32, 0x5f, 0x0a, 0x07, 0x49, 0x6e,
|
||||
0x67, 0x72, 0x65, 0x73, 0x73, 0x12, 0x29, 0x0a, 0x03, 0x47, 0x65, 0x74, 0x12, 0x11, 0x2e, 0x70,
|
||||
0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x47, 0x65, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a,
|
||||
0x0f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x47, 0x65, 0x74, 0x52, 0x65, 0x70, 0x6c, 0x79,
|
||||
0x12, 0x29, 0x0a, 0x03, 0x53, 0x65, 0x74, 0x12, 0x11, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e,
|
||||
0x53, 0x65, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0f, 0x2e, 0x70, 0x72, 0x6f,
|
||||
0x74, 0x6f, 0x2e, 0x53, 0x65, 0x74, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x42, 0x29, 0x5a, 0x27, 0x67,
|
||||
0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x6f, 0x2d, 0x67, 0x6f, 0x73,
|
||||
0x74, 0x2f, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2f, 0x69, 0x6e, 0x67, 0x72, 0x65, 0x73, 0x73,
|
||||
0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
@ -148,16 +258,20 @@ func file_ingress_proto_rawDescGZIP() []byte {
|
||||
return file_ingress_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_ingress_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
|
||||
var file_ingress_proto_msgTypes = make([]protoimpl.MessageInfo, 4)
|
||||
var file_ingress_proto_goTypes = []interface{}{
|
||||
(*GetRequest)(nil), // 0: proto.GetRequest
|
||||
(*GetReply)(nil), // 1: proto.GetReply
|
||||
(*SetRequest)(nil), // 2: proto.SetRequest
|
||||
(*SetReply)(nil), // 3: proto.SetReply
|
||||
}
|
||||
var file_ingress_proto_depIdxs = []int32{
|
||||
0, // 0: proto.Ingress.Get:input_type -> proto.GetRequest
|
||||
1, // 1: proto.Ingress.Get:output_type -> proto.GetReply
|
||||
1, // [1:2] is the sub-list for method output_type
|
||||
0, // [0:1] is the sub-list for method input_type
|
||||
2, // 1: proto.Ingress.Set:input_type -> proto.SetRequest
|
||||
1, // 2: proto.Ingress.Get:output_type -> proto.GetReply
|
||||
3, // 3: proto.Ingress.Set:output_type -> proto.SetReply
|
||||
2, // [2:4] is the sub-list for method output_type
|
||||
0, // [0:2] is the sub-list for method input_type
|
||||
0, // [0:0] is the sub-list for extension type_name
|
||||
0, // [0:0] is the sub-list for extension extendee
|
||||
0, // [0:0] is the sub-list for field type_name
|
||||
@ -193,6 +307,30 @@ func file_ingress_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_ingress_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*SetRequest); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_ingress_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*SetReply); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
@ -200,7 +338,7 @@ func file_ingress_proto_init() {
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_ingress_proto_rawDesc,
|
||||
NumEnums: 0,
|
||||
NumMessages: 2,
|
||||
NumMessages: 4,
|
||||
NumExtensions: 0,
|
||||
NumServices: 1,
|
||||
},
|
||||
|
@ -14,6 +14,16 @@ message GetReply {
|
||||
string endpoint = 1;
|
||||
}
|
||||
|
||||
message SetRequest {
|
||||
string host = 1;
|
||||
string endpoint = 2;
|
||||
}
|
||||
|
||||
message SetReply {
|
||||
bool ok = 1;
|
||||
}
|
||||
|
||||
service Ingress {
|
||||
rpc Get(GetRequest) returns (GetReply);
|
||||
rpc Set(SetRequest) returns (SetReply);
|
||||
}
|
||||
|
@ -1,4 +1,8 @@
|
||||
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-grpc v1.2.0
|
||||
// - protoc v3.15.8
|
||||
// source: ingress.proto
|
||||
|
||||
package proto
|
||||
|
||||
@ -19,6 +23,7 @@ const _ = grpc.SupportPackageIsVersion7
|
||||
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
|
||||
type IngressClient interface {
|
||||
Get(ctx context.Context, in *GetRequest, opts ...grpc.CallOption) (*GetReply, error)
|
||||
Set(ctx context.Context, in *SetRequest, opts ...grpc.CallOption) (*SetReply, error)
|
||||
}
|
||||
|
||||
type ingressClient struct {
|
||||
@ -38,11 +43,21 @@ func (c *ingressClient) Get(ctx context.Context, in *GetRequest, opts ...grpc.Ca
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *ingressClient) Set(ctx context.Context, in *SetRequest, opts ...grpc.CallOption) (*SetReply, error) {
|
||||
out := new(SetReply)
|
||||
err := c.cc.Invoke(ctx, "/proto.Ingress/Set", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// IngressServer is the server API for Ingress service.
|
||||
// All implementations must embed UnimplementedIngressServer
|
||||
// for forward compatibility
|
||||
type IngressServer interface {
|
||||
Get(context.Context, *GetRequest) (*GetReply, error)
|
||||
Set(context.Context, *SetRequest) (*SetReply, error)
|
||||
mustEmbedUnimplementedIngressServer()
|
||||
}
|
||||
|
||||
@ -53,6 +68,9 @@ type UnimplementedIngressServer struct {
|
||||
func (UnimplementedIngressServer) Get(context.Context, *GetRequest) (*GetReply, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method Get not implemented")
|
||||
}
|
||||
func (UnimplementedIngressServer) Set(context.Context, *SetRequest) (*SetReply, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method Set not implemented")
|
||||
}
|
||||
func (UnimplementedIngressServer) mustEmbedUnimplementedIngressServer() {}
|
||||
|
||||
// UnsafeIngressServer may be embedded to opt out of forward compatibility for this service.
|
||||
@ -84,6 +102,24 @@ func _Ingress_Get_Handler(srv interface{}, ctx context.Context, dec func(interfa
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Ingress_Set_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(SetRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(IngressServer).Set(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/proto.Ingress/Set",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(IngressServer).Set(ctx, req.(*SetRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
// Ingress_ServiceDesc is the grpc.ServiceDesc for Ingress service.
|
||||
// It's only intended for direct use with grpc.RegisterService,
|
||||
// and not to be introspected or modified (even as a copy)
|
||||
@ -95,6 +131,10 @@ var Ingress_ServiceDesc = grpc.ServiceDesc{
|
||||
MethodName: "Get",
|
||||
Handler: _Ingress_Get_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "Set",
|
||||
Handler: _Ingress_Set_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "ingress.proto",
|
||||
|
Loading…
Reference in New Issue
Block a user