Browse Source

refactor(rpc): remove vpn apply proto

Mustafa Arici 8 years ago
parent
commit
ea54f2cb32
5 changed files with 21 additions and 111 deletions
  1. 0 11
      api/rpc.go
  2. 0 21
      cmd/ovpm/main.go
  3. 0 2
      pb/user.pb.go
  4. 21 74
      pb/vpn.pb.go
  5. 0 3
      pb/vpn.proto

+ 0 - 11
api/rpc.go

@@ -1,5 +1,3 @@
-//go:generate protoc -I pb/ pb/user.proto pb/vpn.proto --go_out=plugins=grpc:pb
-
 package api
 
 import (
@@ -140,12 +138,3 @@ func (s *VPNService) Init(ctx context.Context, req *pb.VPNInitRequest) (*pb.VPNI
 	}
 	return &pb.VPNInitResponse{}, nil
 }
-
-func (s *VPNService) Apply(ctx context.Context, req *pb.VPNApplyRequest) (*pb.VPNApplyResponse, error) {
-	logrus.Debugf("rpc call: vpn apply")
-	if err := ovpm.Emit(); err != nil {
-		logrus.Errorf("can not apply configuration: %v", err)
-		return nil, err
-	}
-	return &pb.VPNApplyResponse{}, nil
-}

+ 0 - 21
cmd/ovpm/main.go

@@ -1,5 +1,3 @@
-//go:generate go-bindata template/
-
 package main
 
 import (
@@ -322,25 +320,6 @@ func main() {
 						return nil
 					},
 				},
-				// {
-				// 	Name:  "apply",
-				// 	Usage: "Apply pending changes.",
-				// 	Action: func(c *cli.Context) error {
-				// 		action = "apply"
-
-				// 		conn := getConn(c.GlobalString("daemon-port"))
-				// 		defer conn.Close()
-				// 		vpnSvc := pb.NewVPNServiceClient(conn)
-
-				// 		if _, err := vpnSvc.Apply(context.Background(), &pb.VPNApplyRequest{}); err != nil {
-				// 			logrus.Errorf("can not apply configuration: %v", err)
-				// 			os.Exit(1)
-				// 			return err
-				// 		}
-				// 		logrus.Info("changes applied; OpenVPN restarted")
-				// 		return nil
-				// 	},
-				// },
 			},
 		},
 	}

+ 0 - 2
pb/user.pb.go

@@ -18,10 +18,8 @@ It has these top-level messages:
 	UserGenConfigResponse
 	VPNStatusRequest
 	VPNInitRequest
-	VPNApplyRequest
 	VPNStatusResponse
 	VPNInitResponse
-	VPNApplyResponse
 */
 package pb
 

+ 21 - 74
pb/vpn.pb.go

@@ -49,14 +49,6 @@ func (m *VPNInitRequest) GetPort() string {
 	return ""
 }
 
-type VPNApplyRequest struct {
-}
-
-func (m *VPNApplyRequest) Reset()                    { *m = VPNApplyRequest{} }
-func (m *VPNApplyRequest) String() string            { return proto.CompactTextString(m) }
-func (*VPNApplyRequest) ProtoMessage()               {}
-func (*VPNApplyRequest) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{2} }
-
 type VPNStatusResponse struct {
 	Name         string `protobuf:"bytes,1,opt,name=Name" json:"Name,omitempty"`
 	SerialNumber string `protobuf:"bytes,2,opt,name=SerialNumber" json:"SerialNumber,omitempty"`
@@ -72,7 +64,7 @@ type VPNStatusResponse struct {
 func (m *VPNStatusResponse) Reset()                    { *m = VPNStatusResponse{} }
 func (m *VPNStatusResponse) String() string            { return proto.CompactTextString(m) }
 func (*VPNStatusResponse) ProtoMessage()               {}
-func (*VPNStatusResponse) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{3} }
+func (*VPNStatusResponse) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{2} }
 
 func (m *VPNStatusResponse) GetName() string {
 	if m != nil {
@@ -143,23 +135,13 @@ type VPNInitResponse struct {
 func (m *VPNInitResponse) Reset()                    { *m = VPNInitResponse{} }
 func (m *VPNInitResponse) String() string            { return proto.CompactTextString(m) }
 func (*VPNInitResponse) ProtoMessage()               {}
-func (*VPNInitResponse) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{4} }
-
-type VPNApplyResponse struct {
-}
-
-func (m *VPNApplyResponse) Reset()                    { *m = VPNApplyResponse{} }
-func (m *VPNApplyResponse) String() string            { return proto.CompactTextString(m) }
-func (*VPNApplyResponse) ProtoMessage()               {}
-func (*VPNApplyResponse) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{5} }
+func (*VPNInitResponse) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{3} }
 
 func init() {
 	proto.RegisterType((*VPNStatusRequest)(nil), "pb.VPNStatusRequest")
 	proto.RegisterType((*VPNInitRequest)(nil), "pb.VPNInitRequest")
-	proto.RegisterType((*VPNApplyRequest)(nil), "pb.VPNApplyRequest")
 	proto.RegisterType((*VPNStatusResponse)(nil), "pb.VPNStatusResponse")
 	proto.RegisterType((*VPNInitResponse)(nil), "pb.VPNInitResponse")
-	proto.RegisterType((*VPNApplyResponse)(nil), "pb.VPNApplyResponse")
 }
 
 // Reference imports to suppress errors if they are not otherwise used.
@@ -175,7 +157,6 @@ const _ = grpc.SupportPackageIsVersion4
 type VPNServiceClient interface {
 	Status(ctx context.Context, in *VPNStatusRequest, opts ...grpc.CallOption) (*VPNStatusResponse, error)
 	Init(ctx context.Context, in *VPNInitRequest, opts ...grpc.CallOption) (*VPNInitResponse, error)
-	Apply(ctx context.Context, in *VPNApplyRequest, opts ...grpc.CallOption) (*VPNApplyResponse, error)
 }
 
 type vPNServiceClient struct {
@@ -204,21 +185,11 @@ func (c *vPNServiceClient) Init(ctx context.Context, in *VPNInitRequest, opts ..
 	return out, nil
 }
 
-func (c *vPNServiceClient) Apply(ctx context.Context, in *VPNApplyRequest, opts ...grpc.CallOption) (*VPNApplyResponse, error) {
-	out := new(VPNApplyResponse)
-	err := grpc.Invoke(ctx, "/pb.VPNService/Apply", in, out, c.cc, opts...)
-	if err != nil {
-		return nil, err
-	}
-	return out, nil
-}
-
 // Server API for VPNService service
 
 type VPNServiceServer interface {
 	Status(context.Context, *VPNStatusRequest) (*VPNStatusResponse, error)
 	Init(context.Context, *VPNInitRequest) (*VPNInitResponse, error)
-	Apply(context.Context, *VPNApplyRequest) (*VPNApplyResponse, error)
 }
 
 func RegisterVPNServiceServer(s *grpc.Server, srv VPNServiceServer) {
@@ -261,24 +232,6 @@ func _VPNService_Init_Handler(srv interface{}, ctx context.Context, dec func(int
 	return interceptor(ctx, in, info, handler)
 }
 
-func _VPNService_Apply_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
-	in := new(VPNApplyRequest)
-	if err := dec(in); err != nil {
-		return nil, err
-	}
-	if interceptor == nil {
-		return srv.(VPNServiceServer).Apply(ctx, in)
-	}
-	info := &grpc.UnaryServerInfo{
-		Server:     srv,
-		FullMethod: "/pb.VPNService/Apply",
-	}
-	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
-		return srv.(VPNServiceServer).Apply(ctx, req.(*VPNApplyRequest))
-	}
-	return interceptor(ctx, in, info, handler)
-}
-
 var _VPNService_serviceDesc = grpc.ServiceDesc{
 	ServiceName: "pb.VPNService",
 	HandlerType: (*VPNServiceServer)(nil),
@@ -291,10 +244,6 @@ var _VPNService_serviceDesc = grpc.ServiceDesc{
 			MethodName: "Init",
 			Handler:    _VPNService_Init_Handler,
 		},
-		{
-			MethodName: "Apply",
-			Handler:    _VPNService_Apply_Handler,
-		},
 	},
 	Streams:  []grpc.StreamDesc{},
 	Metadata: "vpn.proto",
@@ -303,25 +252,23 @@ var _VPNService_serviceDesc = grpc.ServiceDesc{
 func init() { proto.RegisterFile("vpn.proto", fileDescriptor1) }
 
 var fileDescriptor1 = []byte{
-	// 312 bytes of a gzipped FileDescriptorProto
-	0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x92, 0xcb, 0x4e, 0xf3, 0x30,
-	0x10, 0x85, 0xff, 0xf4, 0x92, 0xbf, 0x19, 0x21, 0x68, 0x87, 0x82, 0xac, 0x88, 0x05, 0xca, 0x8a,
-	0x55, 0x25, 0x2e, 0x12, 0x5b, 0xa2, 0x6c, 0x60, 0x81, 0x15, 0xb5, 0x52, 0xf6, 0x09, 0x78, 0x11,
-	0xd1, 0x26, 0xc6, 0x76, 0x2a, 0xf1, 0x52, 0xbc, 0x18, 0x2f, 0x81, 0x7c, 0x49, 0x93, 0x54, 0x62,
-	0x77, 0xfc, 0x39, 0x67, 0x66, 0x72, 0x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6, 0x83, 0xcb, 0x15, 0x2f,
-	0x56, 0xc7, 0x8b, 0x09, 0x2f, 0x8e, 0xa8, 0xab, 0xfc, 0x0f, 0x6f, 0x61, 0xa2, 0x7b, 0x21, 0xba,
-	0x0f, 0x7a, 0xbb, 0x0b, 0xcf, 0x07, 0xec, 0x60, 0x79, 0x80, 0xa9, 0x99, 0x05, 0xdb, 0xfb, 0xfe,
-	0xb6, 0xc2, 0xe5, 0x10, 0xb6, 0xae, 0xc2, 0x37, 0x2f, 0xe7, 0xfe, 0x37, 0x00, 0x00, 0xff, 0xff,
-	0x10, 0x88, 0xf5, 0x13, 0x46, 0x02, 0x00, 0x00,
+	// 278 bytes of a gzipped FileDescriptorProto
+	0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x91, 0x4f, 0x4f, 0x83, 0x40,
+	0x10, 0xc5, 0xa5, 0x45, 0x2c, 0x13, 0xa3, 0xed, 0xf8, 0x27, 0x1b, 0xe2, 0xc1, 0xec, 0xc9, 0x13,
+	0x89, 0x7a, 0xf0, 0x6a, 0xc3, 0x45, 0x0f, 0x12, 0xd2, 0x26, 0xbd, 0x83, 0xce, 0x81, 0x68, 0x01,
+	0x77, 0x87, 0xc6, 0xef, 0xec, 0x97, 0x30, 0xbb, 0x8b, 0xa5, 0x34, 0xe9, 0xed, 0xed, 0x6f, 0x67,
+	0xde, 0x64, 0xde, 0x40, 0xb8, 0x69, 0xaa, 0xb8, 0x51, 0x35, 0xd7, 0x38, 0x6a, 0x0a, 0x89, 0x30,
+	0x5d, 0x65, 0xe9, 0x92, 0x73, 0x6e, 0xf5, 0x82, 0xbe, 0x5b, 0xd2, 0x2c, 0x9f, 0xe1, 0x6c, 0x95,
+	0xa5, 0xaf, 0x55, 0xc9, 0x1d, 0xc1, 0x08, 0x26, 0x2f, 0xb5, 0xe6, 0x2a, 0x5f, 0x93, 0xf0, 0x6e,
+	0xbd, 0xbb, 0x70, 0xb1, 0x7d, 0x23, 0x82, 0x9f, 0xd5, 0x8a, 0xc5, 0xc8, 0x72, 0xab, 0xe5, 0xaf,
+	0x07, 0xb3, 0x1d, 0x5b, 0xdd, 0xd4, 0x95, 0xb6, 0x95, 0x69, 0xef, 0x60, 0x35, 0x4a, 0x38, 0x5d,
+	0x92, 0x2a, 0xf3, 0xaf, 0xb4, 0x5d, 0x17, 0xa4, 0x3a, 0x97, 0x01, 0x1b, 0x4c, 0x1f, 0x1f, 0x98,
+	0xee, 0xf7, 0xd3, 0x0d, 0x4b, 0x48, 0xb1, 0x38, 0x76, 0xcc, 0x68, 0xbc, 0x86, 0x20, 0x99, 0x5b,
+	0x1a, 0x58, 0xda, 0xbd, 0x70, 0x0a, 0xe3, 0x94, 0x58, 0x9c, 0x58, 0x68, 0xa4, 0xe9, 0x7e, 0xcb,
+	0xf5, 0xa7, 0x98, 0xb8, 0x6e, 0xa3, 0xf1, 0x06, 0xc2, 0x44, 0x51, 0xce, 0xf4, 0x31, 0x67, 0x11,
+	0xda, 0x8f, 0x1e, 0xc8, 0x19, 0x9c, 0x6f, 0xf3, 0x72, 0xab, 0x3e, 0xfc, 0x00, 0x98, 0xfd, 0x49,
+	0x6d, 0xca, 0x77, 0xc2, 0x27, 0x08, 0x5c, 0x14, 0x78, 0x19, 0x37, 0x45, 0xbc, 0x1f, 0x78, 0x74,
+	0xb5, 0x47, 0x9d, 0x89, 0x3c, 0xc2, 0x7b, 0xf0, 0x8d, 0x2d, 0x62, 0x57, 0xb0, 0x73, 0x93, 0xe8,
+	0x62, 0xc0, 0xfe, 0x5b, 0x8a, 0xc0, 0xde, 0xf6, 0xf1, 0x2f, 0x00, 0x00, 0xff, 0xff, 0xc0, 0x1d,
+	0xb6, 0x7e, 0xe8, 0x01, 0x00, 0x00,
 }

+ 0 - 3
pb/vpn.proto

@@ -7,12 +7,10 @@ message VPNInitRequest {
   string Hostname = 1;
   string Port = 2;
 }
-message VPNApplyRequest {}
 
 service VPNService {
   rpc Status (VPNStatusRequest) returns (VPNStatusResponse) {}
   rpc Init (VPNInitRequest) returns (VPNInitResponse) {}
-  rpc Apply (VPNApplyRequest) returns (VPNApplyResponse) {}
 }
 
 message VPNStatusResponse {
@@ -27,4 +25,3 @@ message VPNStatusResponse {
   string CreatedAt = 9;
 }
 message VPNInitResponse {}
-message VPNApplyResponse {}