Explorar o código

feat(api): expose restart vpn functionality over api

Mustafa Arici %!s(int64=8) %!d(string=hai) anos
pai
achega
0b7c7cb222
Modificáronse 9 ficheiros con 182 adicións e 40 borrados
  1. 2 0
      api/pb/user.pb.go
  2. 88 35
      api/pb/vpn.pb.go
  3. 42 0
      api/pb/vpn.pb.gw.go
  4. 8 0
      api/pb/vpn.proto
  5. 15 0
      api/rpc.go
  6. 5 5
      bindata/bindata.go
  7. 2 0
      perms.go
  8. 19 0
      template/vpn.swagger.json
  9. 1 0
      vpn.go

+ 2 - 0
api/pb/user.pb.go

@@ -22,9 +22,11 @@ It has these top-level messages:
 	VPNStatusRequest
 	VPNInitRequest
 	VPNUpdateRequest
+	VPNRestartRequest
 	VPNStatusResponse
 	VPNInitResponse
 	VPNUpdateResponse
+	VPNRestartResponse
 	NetworkCreateRequest
 	NetworkListRequest
 	NetworkDeleteRequest

+ 88 - 35
api/pb/vpn.pb.go

@@ -122,6 +122,14 @@ func (m *VPNUpdateRequest) GetDns() string {
 	return ""
 }
 
+type VPNRestartRequest struct {
+}
+
+func (m *VPNRestartRequest) Reset()                    { *m = VPNRestartRequest{} }
+func (m *VPNRestartRequest) String() string            { return proto.CompactTextString(m) }
+func (*VPNRestartRequest) ProtoMessage()               {}
+func (*VPNRestartRequest) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{3} }
+
 type VPNStatusResponse struct {
 	Name         string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"`
 	SerialNumber string `protobuf:"bytes,2,opt,name=serial_number,json=serialNumber" json:"serial_number,omitempty"`
@@ -139,7 +147,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{4} }
 
 func (m *VPNStatusResponse) GetName() string {
 	if m != nil {
@@ -224,7 +232,7 @@ 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} }
+func (*VPNInitResponse) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{5} }
 
 type VPNUpdateResponse struct {
 }
@@ -232,15 +240,25 @@ type VPNUpdateResponse struct {
 func (m *VPNUpdateResponse) Reset()                    { *m = VPNUpdateResponse{} }
 func (m *VPNUpdateResponse) String() string            { return proto.CompactTextString(m) }
 func (*VPNUpdateResponse) ProtoMessage()               {}
-func (*VPNUpdateResponse) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{5} }
+func (*VPNUpdateResponse) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{6} }
+
+type VPNRestartResponse struct {
+}
+
+func (m *VPNRestartResponse) Reset()                    { *m = VPNRestartResponse{} }
+func (m *VPNRestartResponse) String() string            { return proto.CompactTextString(m) }
+func (*VPNRestartResponse) ProtoMessage()               {}
+func (*VPNRestartResponse) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{7} }
 
 func init() {
 	proto.RegisterType((*VPNStatusRequest)(nil), "pb.VPNStatusRequest")
 	proto.RegisterType((*VPNInitRequest)(nil), "pb.VPNInitRequest")
 	proto.RegisterType((*VPNUpdateRequest)(nil), "pb.VPNUpdateRequest")
+	proto.RegisterType((*VPNRestartRequest)(nil), "pb.VPNRestartRequest")
 	proto.RegisterType((*VPNStatusResponse)(nil), "pb.VPNStatusResponse")
 	proto.RegisterType((*VPNInitResponse)(nil), "pb.VPNInitResponse")
 	proto.RegisterType((*VPNUpdateResponse)(nil), "pb.VPNUpdateResponse")
+	proto.RegisterType((*VPNRestartResponse)(nil), "pb.VPNRestartResponse")
 	proto.RegisterEnum("pb.VPNProto", VPNProto_name, VPNProto_value)
 }
 
@@ -258,6 +276,7 @@ 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)
 	Update(ctx context.Context, in *VPNUpdateRequest, opts ...grpc.CallOption) (*VPNUpdateResponse, error)
+	Restart(ctx context.Context, in *VPNRestartRequest, opts ...grpc.CallOption) (*VPNRestartResponse, error)
 }
 
 type vPNServiceClient struct {
@@ -295,12 +314,22 @@ func (c *vPNServiceClient) Update(ctx context.Context, in *VPNUpdateRequest, opt
 	return out, nil
 }
 
+func (c *vPNServiceClient) Restart(ctx context.Context, in *VPNRestartRequest, opts ...grpc.CallOption) (*VPNRestartResponse, error) {
+	out := new(VPNRestartResponse)
+	err := grpc.Invoke(ctx, "/pb.VPNService/Restart", 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)
 	Update(context.Context, *VPNUpdateRequest) (*VPNUpdateResponse, error)
+	Restart(context.Context, *VPNRestartRequest) (*VPNRestartResponse, error)
 }
 
 func RegisterVPNServiceServer(s *grpc.Server, srv VPNServiceServer) {
@@ -361,6 +390,24 @@ func _VPNService_Update_Handler(srv interface{}, ctx context.Context, dec func(i
 	return interceptor(ctx, in, info, handler)
 }
 
+func _VPNService_Restart_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+	in := new(VPNRestartRequest)
+	if err := dec(in); err != nil {
+		return nil, err
+	}
+	if interceptor == nil {
+		return srv.(VPNServiceServer).Restart(ctx, in)
+	}
+	info := &grpc.UnaryServerInfo{
+		Server:     srv,
+		FullMethod: "/pb.VPNService/Restart",
+	}
+	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+		return srv.(VPNServiceServer).Restart(ctx, req.(*VPNRestartRequest))
+	}
+	return interceptor(ctx, in, info, handler)
+}
+
 var _VPNService_serviceDesc = grpc.ServiceDesc{
 	ServiceName: "pb.VPNService",
 	HandlerType: (*VPNServiceServer)(nil),
@@ -377,6 +424,10 @@ var _VPNService_serviceDesc = grpc.ServiceDesc{
 			MethodName: "Update",
 			Handler:    _VPNService_Update_Handler,
 		},
+		{
+			MethodName: "Restart",
+			Handler:    _VPNService_Restart_Handler,
+		},
 	},
 	Streams:  []grpc.StreamDesc{},
 	Metadata: "vpn.proto",
@@ -385,37 +436,39 @@ var _VPNService_serviceDesc = grpc.ServiceDesc{
 func init() { proto.RegisterFile("vpn.proto", fileDescriptor1) }
 
 var fileDescriptor1 = []byte{
-	// 502 bytes of a gzipped FileDescriptorProto
+	// 537 bytes of a gzipped FileDescriptorProto
 	0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x92, 0xc1, 0x6e, 0xd3, 0x40,
-	0x10, 0x86, 0xb1, 0x93, 0x3a, 0xc9, 0x50, 0x8a, 0x3b, 0x4d, 0x55, 0x13, 0xa8, 0x54, 0x99, 0x4b,
-	0x14, 0xa4, 0x44, 0x94, 0x5b, 0x2f, 0x08, 0x0a, 0x48, 0x48, 0xc8, 0x98, 0xd0, 0xe6, 0x6a, 0xad,
-	0x9d, 0x6d, 0xb1, 0x9a, 0xec, 0x2e, 0xde, 0x4d, 0x1e, 0x00, 0x1e, 0x01, 0x89, 0x03, 0xaf, 0xc5,
-	0x2b, 0xf0, 0x20, 0xc8, 0xb3, 0x4e, 0x6a, 0x23, 0x7a, 0x9b, 0xfd, 0x67, 0xf7, 0xd7, 0x3f, 0xdf,
-	0x0e, 0xf4, 0xd6, 0x4a, 0x8c, 0x55, 0x21, 0x8d, 0x44, 0x57, 0xa5, 0x83, 0x27, 0xd7, 0x52, 0x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0xb6, 0xe5, 0xad,
+	0x66, 0x0f, 0xea, 0xe0, 0xc2, 0x7c, 0x9a, 0x79, 0xb4, 0xdd, 0xe7, 0x7f, 0x03, 0x00, 0x00, 0xff,
+	0xff, 0x04, 0xc8, 0xb8, 0x7c, 0x1a, 0x04, 0x00, 0x00,
 }

+ 42 - 0
api/pb/vpn.pb.gw.go

@@ -63,6 +63,15 @@ func request_VPNService_Update_0(ctx context.Context, marshaler runtime.Marshale
 
 }
 
+func request_VPNService_Restart_0(ctx context.Context, marshaler runtime.Marshaler, client VPNServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
+	var protoReq VPNRestartRequest
+	var metadata runtime.ServerMetadata
+
+	msg, err := client.Restart(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
+	return msg, metadata, err
+
+}
+
 // RegisterVPNServiceHandlerFromEndpoint is same as RegisterVPNServiceHandler but
 // automatically dials to "endpoint" and closes the connection when "ctx" gets done.
 func RegisterVPNServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) {
@@ -188,6 +197,35 @@ func RegisterVPNServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux,
 
 	})
 
+	mux.Handle("POST", pattern_VPNService_Restart_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
+		ctx, cancel := context.WithCancel(ctx)
+		defer cancel()
+		if cn, ok := w.(http.CloseNotifier); ok {
+			go func(done <-chan struct{}, closed <-chan bool) {
+				select {
+				case <-done:
+				case <-closed:
+					cancel()
+				}
+			}(ctx.Done(), cn.CloseNotify())
+		}
+		inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
+		rctx, err := runtime.AnnotateContext(ctx, mux, req)
+		if err != nil {
+			runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
+			return
+		}
+		resp, md, err := request_VPNService_Restart_0(rctx, inboundMarshaler, client, req, pathParams)
+		ctx = runtime.NewServerMetadataContext(ctx, md)
+		if err != nil {
+			runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
+			return
+		}
+
+		forward_VPNService_Restart_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
+
+	})
+
 	return nil
 }
 
@@ -197,6 +235,8 @@ var (
 	pattern_VPNService_Init_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"api", "v1", "vpn", "init"}, ""))
 
 	pattern_VPNService_Update_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"api", "v1", "vpn", "update"}, ""))
+
+	pattern_VPNService_Restart_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"api", "v1", "vpn", "restart"}, ""))
 )
 
 var (
@@ -205,4 +245,6 @@ var (
 	forward_VPNService_Init_0 = runtime.ForwardResponseMessage
 
 	forward_VPNService_Update_0 = runtime.ForwardResponseMessage
+
+	forward_VPNService_Restart_0 = runtime.ForwardResponseMessage
 )

+ 8 - 0
api/pb/vpn.proto

@@ -23,6 +23,7 @@ message VPNUpdateRequest {
   string ip_block = 1;
   string dns = 2;
 }
+message VPNRestartRequest {}
 
 
 service VPNService {
@@ -41,6 +42,12 @@ service VPNService {
       post: "/api/v1/vpn/update"
       body: "*"
     };}
+  rpc Restart (VPNRestartRequest) returns (VPNRestartResponse) {
+    option (google.api.http) = {
+      post: "/api/v1/vpn/restart"
+      //body: "*"
+    };}
+
 
 }
 
@@ -59,3 +66,4 @@ message VPNStatusResponse {
 }
 message VPNInitResponse {}
 message VPNUpdateResponse {}
+message VPNRestartResponse {}

+ 15 - 0
api/rpc.go

@@ -392,6 +392,21 @@ func (s *VPNService) Update(ctx context.Context, req *pb.VPNUpdateRequest) (*pb.
 	return &pb.VPNUpdateResponse{}, nil
 }
 
+func (s *VPNService) Restart(ctx context.Context, req *pb.VPNRestartRequest) (*pb.VPNRestartResponse, error) {
+	logrus.Debugf("rpc call: vpn restart")
+	perms, err := permset.FromContext(ctx)
+	if err != nil {
+		return nil, grpc.Errorf(codes.Unauthenticated, "Can't get permset from context")
+	}
+
+	if !perms.Contains(ovpm.RestartVPNPerm) {
+		return nil, grpc.Errorf(codes.PermissionDenied, "ovpm.UpdateVPNPerm is required for this operation.")
+	}
+
+	ovpm.RestartVPNProc()
+	return &pb.VPNRestartResponse{}, nil
+}
+
 type NetworkService struct{}
 
 func (s *NetworkService) List(ctx context.Context, req *pb.NetworkListRequest) (*pb.NetworkListResponse, error) {

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 5 - 5
bindata/bindata.go


+ 2 - 0
perms.go

@@ -19,6 +19,7 @@ const (
 	GetVPNStatusPerm
 	InitVPNPerm
 	UpdateVPNPerm
+	RestartVPNPerm
 
 	// Network permissions
 	ListNetworksPerm
@@ -45,6 +46,7 @@ func AdminPerms() []permset.Perm {
 		GetVPNStatusPerm,
 		InitVPNPerm,
 		UpdateVPNPerm,
+		RestartVPNPerm,
 		ListNetworksPerm,
 		CreateNetworkPerm,
 		DeleteNetworkPerm,

+ 19 - 0
template/vpn.swagger.json

@@ -41,6 +41,22 @@
         ]
       }
     },
+    "/api/v1/vpn/restart": {
+      "post": {
+        "operationId": "Restart",
+        "responses": {
+          "200": {
+            "description": "",
+            "schema": {
+              "$ref": "#/definitions/pbVPNRestartResponse"
+            }
+          }
+        },
+        "tags": [
+          "VPNService"
+        ]
+      }
+    },
     "/api/v1/vpn/status": {
       "get": {
         "operationId": "Status",
@@ -117,6 +133,9 @@
       ],
       "default": "NOPREF"
     },
+    "pbVPNRestartResponse": {
+      "type": "object"
+    },
     "pbVPNStatusResponse": {
       "type": "object",
       "properties": {

+ 1 - 0
vpn.go

@@ -436,6 +436,7 @@ func RestartVPNProc() {
 	if vpnProc == nil {
 		panic(fmt.Sprintf("vpnProc is not initialized!"))
 	}
+	Emit()
 	vpnProc.Restart()
 	ensureNatEnabled()
 }

Algúns arquivos non se mostraron porque demasiados arquivos cambiaron neste cambio