From 87a46b8186f0c46e81dbce398731ec750e60d551 Mon Sep 17 00:00:00 2001 From: iiiusi0n Date: Tue, 7 Jan 2025 02:59:23 +0900 Subject: [PATCH 01/12] i missed semicolon --- assets/mysql/initdb.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/mysql/initdb.sql b/assets/mysql/initdb.sql index 24d05e5..ffa3c49 100644 --- a/assets/mysql/initdb.sql +++ b/assets/mysql/initdb.sql @@ -19,7 +19,7 @@ CREATE TABLE IF NOT EXISTS user_license ( license_type_id BINARY(16) NOT NULL REFERENCES user_license_type(id), created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP -) +); INSERT INTO user_license_type (id, name) VALUES (UUID_TO_BIN(UUID()), 'free'); INSERT INTO user_license_type (id, name) VALUES (UUID_TO_BIN(UUID()), 'paid'); From a862e88aa6559c622067704ea01b6f1c8a69c4d0 Mon Sep 17 00:00:00 2001 From: iiiusi0n Date: Tue, 7 Jan 2025 23:21:39 +0900 Subject: [PATCH 02/12] they were too rounded --- web/lib/pages/project.dart | 3 +++ 1 file changed, 3 insertions(+) diff --git a/web/lib/pages/project.dart b/web/lib/pages/project.dart index ed9b3d9..c04918b 100644 --- a/web/lib/pages/project.dart +++ b/web/lib/pages/project.dart @@ -370,6 +370,9 @@ class _ProjectPageState extends State { child: const Text('Delete'), ), ], + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(4), + ), ), ); }, From d03d4829d4467e35da77040d675c8b16172287e7 Mon Sep 17 00:00:00 2001 From: KIbeom Lee Date: Sat, 11 Jan 2025 03:41:40 +0900 Subject: [PATCH 03/12] initImages should be procced only once --- cmd/instance-service/main.go | 3 +++ internal/pkg/instance/init.go | 7 +------ internal/pkg/instance/init_test.go | 2 ++ 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cmd/instance-service/main.go b/cmd/instance-service/main.go index 1c3dc13..473cf3d 100644 --- a/cmd/instance-service/main.go +++ b/cmd/instance-service/main.go @@ -8,6 +8,7 @@ import ( "os" pb "easypwn/internal/api" + "easypwn/internal/pkg/instance" "easypwn/internal/service" "google.golang.org/grpc" @@ -24,6 +25,8 @@ func init() { } func main() { + instance.InitImages() + lis, err := net.Listen("tcp", fmt.Sprintf(":%s", listenPort)) if err != nil { log.Fatalf("failed to listen: %v", err) diff --git a/internal/pkg/instance/init.go b/internal/pkg/instance/init.go index 846549a..580ce78 100644 --- a/internal/pkg/instance/init.go +++ b/internal/pkg/instance/init.go @@ -21,11 +21,6 @@ func init() { host = "unix:///var/run/docker.sock" } - initDockerDaemon(host) - initImages() -} - -func initDockerDaemon(host string) { ctx := context.Background() var err error @@ -40,7 +35,7 @@ func initDockerDaemon(host string) { } } -func initImages() { +func InitImages() { files, err := images.Dockerfiles.ReadDir(".") if err != nil { log.Fatal("Failed to read Dockerfiles: ", err) diff --git a/internal/pkg/instance/init_test.go b/internal/pkg/instance/init_test.go index 3371d7f..e182bb8 100644 --- a/internal/pkg/instance/init_test.go +++ b/internal/pkg/instance/init_test.go @@ -6,6 +6,8 @@ import ( ) func TestInitImages(t *testing.T) { + InitImages() + imageNames, err := getImageNames(context.Background(), cli) if err != nil { t.Fatal("Failed to get image names: ", err) From 41e48477cafbd0dfcacc9d6c992353eaf5b45fdc Mon Sep 17 00:00:00 2001 From: KIbeom Lee Date: Mon, 13 Jan 2025 00:56:30 +0900 Subject: [PATCH 04/12] add instance routers --- api/instance.proto | 33 ++ internal/api/chatbot.pb.go | 68 +-- internal/api/chatbot_grpc.pb.go | 2 +- internal/api/gateway/instance.go | 165 ++++++ internal/api/gateway/router.go | 8 +- internal/api/instance.pb.go | 721 ++++++++++++++++--------- internal/api/instance_grpc.pb.go | 116 +++- internal/api/mailer.pb.go | 124 ++--- internal/api/mailer_grpc.pb.go | 2 +- internal/api/project.pb.go | 436 ++++----------- internal/api/project_grpc.pb.go | 2 +- internal/api/user.pb.go | 314 +++-------- internal/api/user_grpc.pb.go | 2 +- internal/pkg/instance/docker.go | 26 + internal/pkg/instance/instance.go | 40 ++ internal/service/instance.go | 45 ++ web/lib/services/instance_service.dart | 62 +++ 17 files changed, 1204 insertions(+), 962 deletions(-) create mode 100644 internal/api/gateway/instance.go create mode 100644 web/lib/services/instance_service.dart diff --git a/api/instance.proto b/api/instance.proto index a5c9d89..8d9cc96 100644 --- a/api/instance.proto +++ b/api/instance.proto @@ -6,9 +6,16 @@ option go_package = "easypwn/internal/api"; service Instance { rpc CreateInstance(CreateInstanceRequest) returns (CreateInstanceResponse) {} + rpc GetInstance(GetInstanceRequest) returns (GetInstanceResponse) {} + rpc GetInstances(GetInstancesRequest) returns (GetInstancesResponse) {} + rpc DeleteInstance(DeleteInstanceRequest) returns (DeleteInstanceResponse) {} + rpc GetInstanceLogs(GetInstanceLogsRequest) returns (GetInstanceLogsResponse) {} + + rpc StopInstance(StopInstanceRequest) returns (StopInstanceResponse) {} + rpc StartInstance(StartInstanceRequest) returns (StartInstanceResponse) {} } message CreateInstanceRequest { @@ -27,6 +34,16 @@ message GetInstanceResponse { string instance_id = 1; string project_id = 2; string container_id = 3; + string status = 4; + int32 memory = 5; +} + +message GetInstancesRequest { + string project_id = 1; +} + +message GetInstancesResponse { + repeated GetInstanceResponse instances = 1; } message DeleteInstanceRequest { @@ -44,4 +61,20 @@ message GetInstanceLogsRequest { message GetInstanceLogsResponse { string logs = 1; +} + +message StopInstanceRequest { + string instance_id = 1; +} + +message StopInstanceResponse { + string instance_id = 1; +} + +message StartInstanceRequest { + string instance_id = 1; +} + +message StartInstanceResponse { + string instance_id = 1; } \ No newline at end of file diff --git a/internal/api/chatbot.pb.go b/internal/api/chatbot.pb.go index 1755eb6..35b8c45 100644 --- a/internal/api/chatbot.pb.go +++ b/internal/api/chatbot.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.1 -// protoc v5.29.2 +// protoc-gen-go v1.36.2 +// protoc v5.29.3 // source: api/chatbot.proto package api @@ -21,21 +21,18 @@ const ( ) type GetResponseRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + InstanceId string `protobuf:"bytes,1,opt,name=instance_id,json=instanceId,proto3" json:"instance_id,omitempty"` + Message string `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"` unknownFields protoimpl.UnknownFields - - InstanceId string `protobuf:"bytes,1,opt,name=instance_id,json=instanceId,proto3" json:"instance_id,omitempty"` - Message string `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"` + sizeCache protoimpl.SizeCache } func (x *GetResponseRequest) Reset() { *x = GetResponseRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_api_chatbot_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_api_chatbot_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *GetResponseRequest) String() string { @@ -46,7 +43,7 @@ func (*GetResponseRequest) ProtoMessage() {} func (x *GetResponseRequest) ProtoReflect() protoreflect.Message { mi := &file_api_chatbot_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -76,20 +73,17 @@ func (x *GetResponseRequest) GetMessage() string { } type GetResponseResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Response string `protobuf:"bytes,1,opt,name=response,proto3" json:"response,omitempty"` unknownFields protoimpl.UnknownFields - - Response string `protobuf:"bytes,1,opt,name=response,proto3" json:"response,omitempty"` + sizeCache protoimpl.SizeCache } func (x *GetResponseResponse) Reset() { *x = GetResponseResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_api_chatbot_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_api_chatbot_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *GetResponseResponse) String() string { @@ -100,7 +94,7 @@ func (*GetResponseResponse) ProtoMessage() {} func (x *GetResponseResponse) ProtoReflect() protoreflect.Message { mi := &file_api_chatbot_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -158,7 +152,7 @@ func file_api_chatbot_proto_rawDescGZIP() []byte { } var file_api_chatbot_proto_msgTypes = make([]protoimpl.MessageInfo, 2) -var file_api_chatbot_proto_goTypes = []interface{}{ +var file_api_chatbot_proto_goTypes = []any{ (*GetResponseRequest)(nil), // 0: easypwn.GetResponseRequest (*GetResponseResponse)(nil), // 1: easypwn.GetResponseResponse } @@ -177,32 +171,6 @@ func file_api_chatbot_proto_init() { if File_api_chatbot_proto != nil { return } - if !protoimpl.UnsafeEnabled { - file_api_chatbot_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*GetResponseRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_api_chatbot_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*GetResponseResponse); 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{ File: protoimpl.DescBuilder{ diff --git a/internal/api/chatbot_grpc.pb.go b/internal/api/chatbot_grpc.pb.go index 90aa977..eab48fa 100644 --- a/internal/api/chatbot_grpc.pb.go +++ b/internal/api/chatbot_grpc.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: // - protoc-gen-go-grpc v1.5.1 -// - protoc v5.29.2 +// - protoc v5.29.3 // source: api/chatbot.proto package api diff --git a/internal/api/gateway/instance.go b/internal/api/gateway/instance.go new file mode 100644 index 0000000..0f5bec2 --- /dev/null +++ b/internal/api/gateway/instance.go @@ -0,0 +1,165 @@ +package gateway + +import ( + "context" + pb "easypwn/internal/api" + "easypwn/internal/data" + "easypwn/internal/pkg/instance" + "log" + "net/http" + "time" + + "github.com/gin-gonic/gin" +) + +func GetInstancesHandler(instanceClient pb.InstanceClient) gin.HandlerFunc { + ctx := context.Background() + + type InstanceResponse struct { + InstanceId string `json:"instance_id"` + Status string `json:"status"` + Memory int `json:"memory"` + CreatedAt string `json:"created_at"` + UpdatedAt string `json:"updated_at"` + } + + return func(c *gin.Context) { + projectId := c.Query("project_id") + if projectId == "" { + c.JSON(http.StatusBadRequest, gin.H{"error": "Project ID is required"}) + return + } + + instances, err := instanceClient.GetInstances(ctx, &pb.GetInstancesRequest{ + ProjectId: projectId, + }) + if err != nil { + c.JSON(http.StatusInternalServerError, gin.H{"error": "Failed to get project"}) + return + } + + var instanceList []InstanceResponse + for _, insresp := range instances.Instances { + ins, err := instance.GetInstance(ctx, data.GetDB(), insresp.InstanceId) + if err != nil { + log.Printf("Failed to get instance: %v", err) + c.JSON(http.StatusInternalServerError, gin.H{"error": "Failed to get instance"}) + return + } + + status, err := ins.GetStatus(ctx) + if err != nil { + log.Printf("Failed to get instance status: %v", err) + c.JSON(http.StatusInternalServerError, gin.H{"error": "Failed to get instance status"}) + return + } + memory, err := ins.GetMemoryUsage(ctx) + if err != nil { + log.Printf("Failed to get instance memory usage: %v", err) + c.JSON(http.StatusInternalServerError, gin.H{"error": "Failed to get instance memory usage"}) + return + } + instanceList = append(instanceList, InstanceResponse{ + InstanceId: insresp.InstanceId, + Status: status, + Memory: memory, + CreatedAt: ins.CreatedAt.Format(time.RFC3339), + UpdatedAt: ins.UpdatedAt.Format(time.RFC3339), + }) + } + + c.JSON(http.StatusOK, instanceList) + } +} + +func CreateInstanceHandler(instanceClient pb.InstanceClient) gin.HandlerFunc { + ctx := context.Background() + + type CreateInstanceResponse struct { + InstanceId string `json:"instance_id"` + } + + return func(c *gin.Context) { + projectId := c.Query("project_id") + if projectId == "" { + c.JSON(http.StatusBadRequest, gin.H{"error": "Project ID is required"}) + return + } + + response, err := instanceClient.CreateInstance(ctx, &pb.CreateInstanceRequest{ + ProjectId: projectId, + }) + if err != nil { + log.Printf("Failed to create instance: %v", err) + c.JSON(http.StatusInternalServerError, gin.H{"error": "Failed to create instance"}) + return + } + + c.JSON(http.StatusOK, CreateInstanceResponse{ + InstanceId: response.InstanceId, + }) + } +} + +func DeleteInstanceHandler(instanceClient pb.InstanceClient) gin.HandlerFunc { + ctx := context.Background() + + return func(c *gin.Context) { + instanceId := c.Param("id") + if instanceId == "" { + c.JSON(http.StatusBadRequest, gin.H{"error": "Instance ID is required"}) + return + } + + _, err := instanceClient.DeleteInstance(ctx, &pb.DeleteInstanceRequest{ + InstanceId: instanceId, + }) + if err != nil { + log.Printf("Failed to delete instance: %v", err) + c.JSON(http.StatusInternalServerError, gin.H{"error": "Failed to delete instance"}) + return + } + + c.JSON(http.StatusOK, gin.H{"message": "Instance deleted successfully"}) + } +} + +func ActionInstanceHandler(instanceClient pb.InstanceClient) gin.HandlerFunc { + ctx := context.Background() + + return func(c *gin.Context) { + instanceId := c.Param("id") + if instanceId == "" { + c.JSON(http.StatusBadRequest, gin.H{"error": "Instance ID is required"}) + return + } + + action := c.Query("action") + if action == "" { + c.JSON(http.StatusBadRequest, gin.H{"error": "Action is required"}) + return + } + + switch action { + case "start": + _, err := instanceClient.StartInstance(ctx, &pb.StartInstanceRequest{InstanceId: instanceId}) + if err != nil { + log.Printf("Failed to start instance: %v", err) + c.JSON(http.StatusInternalServerError, gin.H{"error": "Failed to start instance"}) + return + } + case "stop": + _, err := instanceClient.StopInstance(ctx, &pb.StopInstanceRequest{InstanceId: instanceId}) + if err != nil { + log.Printf("Failed to stop instance: %v", err) + c.JSON(http.StatusInternalServerError, gin.H{"error": "Failed to stop instance"}) + return + } + default: + c.JSON(http.StatusBadRequest, gin.H{"error": "Invalid action"}) + return + } + + c.JSON(http.StatusOK, gin.H{"message": "Instance action performed successfully"}) + } +} diff --git a/internal/api/gateway/router.go b/internal/api/gateway/router.go index be1d554..ecb1ff2 100644 --- a/internal/api/gateway/router.go +++ b/internal/api/gateway/router.go @@ -48,9 +48,11 @@ func NewRouter(clients RouterClients) *gin.Engine { { instance.Use(jwtauth.AuthMiddleware()) - instance.GET("") - instance.POST("") - instance.DELETE("/:id") + instance.GET("", GetInstancesHandler(clients.InstanceClient)) + instance.POST("", CreateInstanceHandler(clients.InstanceClient)) + + instance.GET("/:id", ActionInstanceHandler(clients.InstanceClient)) + instance.DELETE("/:id", DeleteInstanceHandler(clients.InstanceClient)) } return r diff --git a/internal/api/instance.pb.go b/internal/api/instance.pb.go index b5f76b4..7fce82c 100644 --- a/internal/api/instance.pb.go +++ b/internal/api/instance.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.1 -// protoc v5.29.2 +// protoc-gen-go v1.36.2 +// protoc v5.29.3 // source: api/instance.proto package api @@ -21,20 +21,17 @@ const ( ) type CreateInstanceRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + ProjectId string `protobuf:"bytes,1,opt,name=project_id,json=projectId,proto3" json:"project_id,omitempty"` unknownFields protoimpl.UnknownFields - - ProjectId string `protobuf:"bytes,1,opt,name=project_id,json=projectId,proto3" json:"project_id,omitempty"` + sizeCache protoimpl.SizeCache } func (x *CreateInstanceRequest) Reset() { *x = CreateInstanceRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_api_instance_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_api_instance_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *CreateInstanceRequest) String() string { @@ -45,7 +42,7 @@ func (*CreateInstanceRequest) ProtoMessage() {} func (x *CreateInstanceRequest) ProtoReflect() protoreflect.Message { mi := &file_api_instance_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -68,20 +65,17 @@ func (x *CreateInstanceRequest) GetProjectId() string { } type CreateInstanceResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + InstanceId string `protobuf:"bytes,1,opt,name=instance_id,json=instanceId,proto3" json:"instance_id,omitempty"` unknownFields protoimpl.UnknownFields - - InstanceId string `protobuf:"bytes,1,opt,name=instance_id,json=instanceId,proto3" json:"instance_id,omitempty"` + sizeCache protoimpl.SizeCache } func (x *CreateInstanceResponse) Reset() { *x = CreateInstanceResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_api_instance_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_api_instance_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *CreateInstanceResponse) String() string { @@ -92,7 +86,7 @@ func (*CreateInstanceResponse) ProtoMessage() {} func (x *CreateInstanceResponse) ProtoReflect() protoreflect.Message { mi := &file_api_instance_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -115,20 +109,17 @@ func (x *CreateInstanceResponse) GetInstanceId() string { } type GetInstanceRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + InstanceId string `protobuf:"bytes,1,opt,name=instance_id,json=instanceId,proto3" json:"instance_id,omitempty"` unknownFields protoimpl.UnknownFields - - InstanceId string `protobuf:"bytes,1,opt,name=instance_id,json=instanceId,proto3" json:"instance_id,omitempty"` + sizeCache protoimpl.SizeCache } func (x *GetInstanceRequest) Reset() { *x = GetInstanceRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_api_instance_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_api_instance_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *GetInstanceRequest) String() string { @@ -139,7 +130,7 @@ func (*GetInstanceRequest) ProtoMessage() {} func (x *GetInstanceRequest) ProtoReflect() protoreflect.Message { mi := &file_api_instance_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -162,22 +153,21 @@ func (x *GetInstanceRequest) GetInstanceId() string { } type GetInstanceResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + InstanceId string `protobuf:"bytes,1,opt,name=instance_id,json=instanceId,proto3" json:"instance_id,omitempty"` + ProjectId string `protobuf:"bytes,2,opt,name=project_id,json=projectId,proto3" json:"project_id,omitempty"` + ContainerId string `protobuf:"bytes,3,opt,name=container_id,json=containerId,proto3" json:"container_id,omitempty"` + Status string `protobuf:"bytes,4,opt,name=status,proto3" json:"status,omitempty"` + Memory int32 `protobuf:"varint,5,opt,name=memory,proto3" json:"memory,omitempty"` unknownFields protoimpl.UnknownFields - - InstanceId string `protobuf:"bytes,1,opt,name=instance_id,json=instanceId,proto3" json:"instance_id,omitempty"` - ProjectId string `protobuf:"bytes,2,opt,name=project_id,json=projectId,proto3" json:"project_id,omitempty"` - ContainerId string `protobuf:"bytes,3,opt,name=container_id,json=containerId,proto3" json:"container_id,omitempty"` + sizeCache protoimpl.SizeCache } func (x *GetInstanceResponse) Reset() { *x = GetInstanceResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_api_instance_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_api_instance_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *GetInstanceResponse) String() string { @@ -188,7 +178,7 @@ func (*GetInstanceResponse) ProtoMessage() {} func (x *GetInstanceResponse) ProtoReflect() protoreflect.Message { mi := &file_api_instance_proto_msgTypes[3] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -224,21 +214,120 @@ func (x *GetInstanceResponse) GetContainerId() string { return "" } -type DeleteInstanceRequest struct { - state protoimpl.MessageState +func (x *GetInstanceResponse) GetStatus() string { + if x != nil { + return x.Status + } + return "" +} + +func (x *GetInstanceResponse) GetMemory() int32 { + if x != nil { + return x.Memory + } + return 0 +} + +type GetInstancesRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + ProjectId string `protobuf:"bytes,1,opt,name=project_id,json=projectId,proto3" json:"project_id,omitempty"` + unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache +} + +func (x *GetInstancesRequest) Reset() { + *x = GetInstancesRequest{} + mi := &file_api_instance_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetInstancesRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetInstancesRequest) ProtoMessage() {} + +func (x *GetInstancesRequest) ProtoReflect() protoreflect.Message { + mi := &file_api_instance_proto_msgTypes[4] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetInstancesRequest.ProtoReflect.Descriptor instead. +func (*GetInstancesRequest) Descriptor() ([]byte, []int) { + return file_api_instance_proto_rawDescGZIP(), []int{4} +} + +func (x *GetInstancesRequest) GetProjectId() string { + if x != nil { + return x.ProjectId + } + return "" +} + +type GetInstancesResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Instances []*GetInstanceResponse `protobuf:"bytes,1,rep,name=instances,proto3" json:"instances,omitempty"` unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} - InstanceId string `protobuf:"bytes,1,opt,name=instance_id,json=instanceId,proto3" json:"instance_id,omitempty"` +func (x *GetInstancesResponse) Reset() { + *x = GetInstancesResponse{} + mi := &file_api_instance_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } -func (x *DeleteInstanceRequest) Reset() { - *x = DeleteInstanceRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_api_instance_proto_msgTypes[4] +func (x *GetInstancesResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetInstancesResponse) ProtoMessage() {} + +func (x *GetInstancesResponse) ProtoReflect() protoreflect.Message { + mi := &file_api_instance_proto_msgTypes[5] + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetInstancesResponse.ProtoReflect.Descriptor instead. +func (*GetInstancesResponse) Descriptor() ([]byte, []int) { + return file_api_instance_proto_rawDescGZIP(), []int{5} +} + +func (x *GetInstancesResponse) GetInstances() []*GetInstanceResponse { + if x != nil { + return x.Instances } + return nil +} + +type DeleteInstanceRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + InstanceId string `protobuf:"bytes,1,opt,name=instance_id,json=instanceId,proto3" json:"instance_id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *DeleteInstanceRequest) Reset() { + *x = DeleteInstanceRequest{} + mi := &file_api_instance_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *DeleteInstanceRequest) String() string { @@ -248,8 +337,8 @@ func (x *DeleteInstanceRequest) String() string { func (*DeleteInstanceRequest) ProtoMessage() {} func (x *DeleteInstanceRequest) ProtoReflect() protoreflect.Message { - mi := &file_api_instance_proto_msgTypes[4] - if protoimpl.UnsafeEnabled && x != nil { + mi := &file_api_instance_proto_msgTypes[6] + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -261,7 +350,7 @@ func (x *DeleteInstanceRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use DeleteInstanceRequest.ProtoReflect.Descriptor instead. func (*DeleteInstanceRequest) Descriptor() ([]byte, []int) { - return file_api_instance_proto_rawDescGZIP(), []int{4} + return file_api_instance_proto_rawDescGZIP(), []int{6} } func (x *DeleteInstanceRequest) GetInstanceId() string { @@ -272,20 +361,17 @@ func (x *DeleteInstanceRequest) GetInstanceId() string { } type DeleteInstanceResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + InstanceId string `protobuf:"bytes,1,opt,name=instance_id,json=instanceId,proto3" json:"instance_id,omitempty"` unknownFields protoimpl.UnknownFields - - InstanceId string `protobuf:"bytes,1,opt,name=instance_id,json=instanceId,proto3" json:"instance_id,omitempty"` + sizeCache protoimpl.SizeCache } func (x *DeleteInstanceResponse) Reset() { *x = DeleteInstanceResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_api_instance_proto_msgTypes[5] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_api_instance_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *DeleteInstanceResponse) String() string { @@ -295,8 +381,8 @@ func (x *DeleteInstanceResponse) String() string { func (*DeleteInstanceResponse) ProtoMessage() {} func (x *DeleteInstanceResponse) ProtoReflect() protoreflect.Message { - mi := &file_api_instance_proto_msgTypes[5] - if protoimpl.UnsafeEnabled && x != nil { + mi := &file_api_instance_proto_msgTypes[7] + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -308,7 +394,7 @@ func (x *DeleteInstanceResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use DeleteInstanceResponse.ProtoReflect.Descriptor instead. func (*DeleteInstanceResponse) Descriptor() ([]byte, []int) { - return file_api_instance_proto_rawDescGZIP(), []int{5} + return file_api_instance_proto_rawDescGZIP(), []int{7} } func (x *DeleteInstanceResponse) GetInstanceId() string { @@ -319,21 +405,18 @@ func (x *DeleteInstanceResponse) GetInstanceId() string { } type GetInstanceLogsRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + InstanceId string `protobuf:"bytes,1,opt,name=instance_id,json=instanceId,proto3" json:"instance_id,omitempty"` + Limit int32 `protobuf:"varint,2,opt,name=limit,proto3" json:"limit,omitempty"` unknownFields protoimpl.UnknownFields - - InstanceId string `protobuf:"bytes,1,opt,name=instance_id,json=instanceId,proto3" json:"instance_id,omitempty"` - Limit int32 `protobuf:"varint,2,opt,name=limit,proto3" json:"limit,omitempty"` + sizeCache protoimpl.SizeCache } func (x *GetInstanceLogsRequest) Reset() { *x = GetInstanceLogsRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_api_instance_proto_msgTypes[6] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_api_instance_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *GetInstanceLogsRequest) String() string { @@ -343,8 +426,8 @@ func (x *GetInstanceLogsRequest) String() string { func (*GetInstanceLogsRequest) ProtoMessage() {} func (x *GetInstanceLogsRequest) ProtoReflect() protoreflect.Message { - mi := &file_api_instance_proto_msgTypes[6] - if protoimpl.UnsafeEnabled && x != nil { + mi := &file_api_instance_proto_msgTypes[8] + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -356,7 +439,7 @@ func (x *GetInstanceLogsRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use GetInstanceLogsRequest.ProtoReflect.Descriptor instead. func (*GetInstanceLogsRequest) Descriptor() ([]byte, []int) { - return file_api_instance_proto_rawDescGZIP(), []int{6} + return file_api_instance_proto_rawDescGZIP(), []int{8} } func (x *GetInstanceLogsRequest) GetInstanceId() string { @@ -374,20 +457,17 @@ func (x *GetInstanceLogsRequest) GetLimit() int32 { } type GetInstanceLogsResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Logs string `protobuf:"bytes,1,opt,name=logs,proto3" json:"logs,omitempty"` unknownFields protoimpl.UnknownFields - - Logs string `protobuf:"bytes,1,opt,name=logs,proto3" json:"logs,omitempty"` + sizeCache protoimpl.SizeCache } func (x *GetInstanceLogsResponse) Reset() { *x = GetInstanceLogsResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_api_instance_proto_msgTypes[7] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_api_instance_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *GetInstanceLogsResponse) String() string { @@ -397,8 +477,8 @@ func (x *GetInstanceLogsResponse) String() string { func (*GetInstanceLogsResponse) ProtoMessage() {} func (x *GetInstanceLogsResponse) ProtoReflect() protoreflect.Message { - mi := &file_api_instance_proto_msgTypes[7] - if protoimpl.UnsafeEnabled && x != nil { + mi := &file_api_instance_proto_msgTypes[9] + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -410,7 +490,7 @@ func (x *GetInstanceLogsResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use GetInstanceLogsResponse.ProtoReflect.Descriptor instead. func (*GetInstanceLogsResponse) Descriptor() ([]byte, []int) { - return file_api_instance_proto_rawDescGZIP(), []int{7} + return file_api_instance_proto_rawDescGZIP(), []int{9} } func (x *GetInstanceLogsResponse) GetLogs() string { @@ -420,6 +500,182 @@ func (x *GetInstanceLogsResponse) GetLogs() string { return "" } +type StopInstanceRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + InstanceId string `protobuf:"bytes,1,opt,name=instance_id,json=instanceId,proto3" json:"instance_id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *StopInstanceRequest) Reset() { + *x = StopInstanceRequest{} + mi := &file_api_instance_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *StopInstanceRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*StopInstanceRequest) ProtoMessage() {} + +func (x *StopInstanceRequest) ProtoReflect() protoreflect.Message { + mi := &file_api_instance_proto_msgTypes[10] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use StopInstanceRequest.ProtoReflect.Descriptor instead. +func (*StopInstanceRequest) Descriptor() ([]byte, []int) { + return file_api_instance_proto_rawDescGZIP(), []int{10} +} + +func (x *StopInstanceRequest) GetInstanceId() string { + if x != nil { + return x.InstanceId + } + return "" +} + +type StopInstanceResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + InstanceId string `protobuf:"bytes,1,opt,name=instance_id,json=instanceId,proto3" json:"instance_id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *StopInstanceResponse) Reset() { + *x = StopInstanceResponse{} + mi := &file_api_instance_proto_msgTypes[11] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *StopInstanceResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*StopInstanceResponse) ProtoMessage() {} + +func (x *StopInstanceResponse) ProtoReflect() protoreflect.Message { + mi := &file_api_instance_proto_msgTypes[11] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use StopInstanceResponse.ProtoReflect.Descriptor instead. +func (*StopInstanceResponse) Descriptor() ([]byte, []int) { + return file_api_instance_proto_rawDescGZIP(), []int{11} +} + +func (x *StopInstanceResponse) GetInstanceId() string { + if x != nil { + return x.InstanceId + } + return "" +} + +type StartInstanceRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + InstanceId string `protobuf:"bytes,1,opt,name=instance_id,json=instanceId,proto3" json:"instance_id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *StartInstanceRequest) Reset() { + *x = StartInstanceRequest{} + mi := &file_api_instance_proto_msgTypes[12] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *StartInstanceRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*StartInstanceRequest) ProtoMessage() {} + +func (x *StartInstanceRequest) ProtoReflect() protoreflect.Message { + mi := &file_api_instance_proto_msgTypes[12] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use StartInstanceRequest.ProtoReflect.Descriptor instead. +func (*StartInstanceRequest) Descriptor() ([]byte, []int) { + return file_api_instance_proto_rawDescGZIP(), []int{12} +} + +func (x *StartInstanceRequest) GetInstanceId() string { + if x != nil { + return x.InstanceId + } + return "" +} + +type StartInstanceResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + InstanceId string `protobuf:"bytes,1,opt,name=instance_id,json=instanceId,proto3" json:"instance_id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *StartInstanceResponse) Reset() { + *x = StartInstanceResponse{} + mi := &file_api_instance_proto_msgTypes[13] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *StartInstanceResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*StartInstanceResponse) ProtoMessage() {} + +func (x *StartInstanceResponse) ProtoReflect() protoreflect.Message { + mi := &file_api_instance_proto_msgTypes[13] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use StartInstanceResponse.ProtoReflect.Descriptor instead. +func (*StartInstanceResponse) Descriptor() ([]byte, []int) { + return file_api_instance_proto_rawDescGZIP(), []int{13} +} + +func (x *StartInstanceResponse) GetInstanceId() string { + if x != nil { + return x.InstanceId + } + return "" +} + var File_api_instance_proto protoreflect.FileDescriptor var file_api_instance_proto_rawDesc = []byte{ @@ -435,54 +691,94 @@ var file_api_instance_proto_rawDesc = []byte{ 0x22, 0x35, 0x0a, 0x12, 0x47, 0x65, 0x74, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1f, 0x0a, 0x0b, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x69, 0x6e, 0x73, - 0x74, 0x61, 0x6e, 0x63, 0x65, 0x49, 0x64, 0x22, 0x78, 0x0a, 0x13, 0x47, 0x65, 0x74, 0x49, 0x6e, - 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1f, - 0x0a, 0x0b, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x0a, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x49, 0x64, 0x12, - 0x1d, 0x0a, 0x0a, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x09, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x49, 0x64, 0x12, 0x21, - 0x0a, 0x0c, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x03, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x49, - 0x64, 0x22, 0x38, 0x0a, 0x15, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x49, 0x6e, 0x73, 0x74, 0x61, - 0x6e, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1f, 0x0a, 0x0b, 0x69, 0x6e, - 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x0a, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x49, 0x64, 0x22, 0x39, 0x0a, 0x16, 0x44, - 0x65, 0x6c, 0x65, 0x74, 0x65, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, + 0x74, 0x61, 0x6e, 0x63, 0x65, 0x49, 0x64, 0x22, 0xa8, 0x01, 0x0a, 0x13, 0x47, 0x65, 0x74, 0x49, + 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, + 0x1f, 0x0a, 0x0b, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x49, 0x64, + 0x12, 0x1d, 0x0a, 0x0a, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x49, 0x64, 0x12, + 0x21, 0x0a, 0x0c, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, + 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, + 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x04, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x6d, 0x65, + 0x6d, 0x6f, 0x72, 0x79, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x6d, 0x65, 0x6d, 0x6f, + 0x72, 0x79, 0x22, 0x34, 0x0a, 0x13, 0x47, 0x65, 0x74, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, + 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x70, 0x72, 0x6f, + 0x6a, 0x65, 0x63, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x70, + 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x49, 0x64, 0x22, 0x52, 0x0a, 0x14, 0x47, 0x65, 0x74, 0x49, + 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x12, 0x3a, 0x0a, 0x09, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x73, 0x18, 0x01, 0x20, + 0x03, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x65, 0x61, 0x73, 0x79, 0x70, 0x77, 0x6e, 0x2e, 0x47, 0x65, + 0x74, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x52, 0x09, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x73, 0x22, 0x38, 0x0a, 0x15, + 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1f, 0x0a, 0x0b, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x69, 0x6e, 0x73, 0x74, - 0x61, 0x6e, 0x63, 0x65, 0x49, 0x64, 0x22, 0x4f, 0x0a, 0x16, 0x47, 0x65, 0x74, 0x49, 0x6e, 0x73, - 0x74, 0x61, 0x6e, 0x63, 0x65, 0x4c, 0x6f, 0x67, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x61, 0x6e, 0x63, 0x65, 0x49, 0x64, 0x22, 0x39, 0x0a, 0x16, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, + 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x49, - 0x64, 0x12, 0x14, 0x0a, 0x05, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, - 0x52, 0x05, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x22, 0x2d, 0x0a, 0x17, 0x47, 0x65, 0x74, 0x49, 0x6e, - 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x4c, 0x6f, 0x67, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6c, 0x6f, 0x67, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x04, 0x6c, 0x6f, 0x67, 0x73, 0x32, 0xd8, 0x02, 0x0a, 0x08, 0x49, 0x6e, 0x73, 0x74, 0x61, - 0x6e, 0x63, 0x65, 0x12, 0x53, 0x0a, 0x0e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x49, 0x6e, 0x73, - 0x74, 0x61, 0x6e, 0x63, 0x65, 0x12, 0x1e, 0x2e, 0x65, 0x61, 0x73, 0x79, 0x70, 0x77, 0x6e, 0x2e, - 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1f, 0x2e, 0x65, 0x61, 0x73, 0x79, 0x70, 0x77, 0x6e, 0x2e, - 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x4a, 0x0a, 0x0b, 0x47, 0x65, 0x74, 0x49, - 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x12, 0x1b, 0x2e, 0x65, 0x61, 0x73, 0x79, 0x70, 0x77, - 0x6e, 0x2e, 0x47, 0x65, 0x74, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1c, 0x2e, 0x65, 0x61, 0x73, 0x79, 0x70, 0x77, 0x6e, 0x2e, 0x47, - 0x65, 0x74, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x22, 0x00, 0x12, 0x53, 0x0a, 0x0e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x49, 0x6e, - 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x12, 0x1e, 0x2e, 0x65, 0x61, 0x73, 0x79, 0x70, 0x77, 0x6e, - 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1f, 0x2e, 0x65, 0x61, 0x73, 0x79, 0x70, 0x77, 0x6e, - 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x56, 0x0a, 0x0f, 0x47, 0x65, 0x74, - 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x4c, 0x6f, 0x67, 0x73, 0x12, 0x1f, 0x2e, 0x65, - 0x61, 0x73, 0x79, 0x70, 0x77, 0x6e, 0x2e, 0x47, 0x65, 0x74, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, - 0x63, 0x65, 0x4c, 0x6f, 0x67, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x20, 0x2e, - 0x65, 0x61, 0x73, 0x79, 0x70, 0x77, 0x6e, 0x2e, 0x47, 0x65, 0x74, 0x49, 0x6e, 0x73, 0x74, 0x61, - 0x6e, 0x63, 0x65, 0x4c, 0x6f, 0x67, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, - 0x00, 0x42, 0x16, 0x5a, 0x14, 0x65, 0x61, 0x73, 0x79, 0x70, 0x77, 0x6e, 0x2f, 0x69, 0x6e, 0x74, - 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x61, 0x70, 0x69, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x33, + 0x64, 0x22, 0x4f, 0x0a, 0x16, 0x47, 0x65, 0x74, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, + 0x4c, 0x6f, 0x67, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1f, 0x0a, 0x0b, 0x69, + 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x0a, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x49, 0x64, 0x12, 0x14, 0x0a, 0x05, + 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x6c, 0x69, 0x6d, + 0x69, 0x74, 0x22, 0x2d, 0x0a, 0x17, 0x47, 0x65, 0x74, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, + 0x65, 0x4c, 0x6f, 0x67, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, + 0x04, 0x6c, 0x6f, 0x67, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6c, 0x6f, 0x67, + 0x73, 0x22, 0x36, 0x0a, 0x13, 0x53, 0x74, 0x6f, 0x70, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, + 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1f, 0x0a, 0x0b, 0x69, 0x6e, 0x73, 0x74, + 0x61, 0x6e, 0x63, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x69, + 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x49, 0x64, 0x22, 0x37, 0x0a, 0x14, 0x53, 0x74, 0x6f, + 0x70, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x5f, 0x69, 0x64, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, + 0x49, 0x64, 0x22, 0x37, 0x0a, 0x14, 0x53, 0x74, 0x61, 0x72, 0x74, 0x49, 0x6e, 0x73, 0x74, 0x61, + 0x6e, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1f, 0x0a, 0x0b, 0x69, 0x6e, + 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x0a, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x49, 0x64, 0x22, 0x38, 0x0a, 0x15, 0x53, + 0x74, 0x61, 0x72, 0x74, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, + 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x69, 0x6e, 0x73, 0x74, 0x61, + 0x6e, 0x63, 0x65, 0x49, 0x64, 0x32, 0xc8, 0x04, 0x0a, 0x08, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, + 0x63, 0x65, 0x12, 0x53, 0x0a, 0x0e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x49, 0x6e, 0x73, 0x74, + 0x61, 0x6e, 0x63, 0x65, 0x12, 0x1e, 0x2e, 0x65, 0x61, 0x73, 0x79, 0x70, 0x77, 0x6e, 0x2e, 0x43, + 0x72, 0x65, 0x61, 0x74, 0x65, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1f, 0x2e, 0x65, 0x61, 0x73, 0x79, 0x70, 0x77, 0x6e, 0x2e, 0x43, + 0x72, 0x65, 0x61, 0x74, 0x65, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x4a, 0x0a, 0x0b, 0x47, 0x65, 0x74, 0x49, 0x6e, + 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x12, 0x1b, 0x2e, 0x65, 0x61, 0x73, 0x79, 0x70, 0x77, 0x6e, + 0x2e, 0x47, 0x65, 0x74, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x1a, 0x1c, 0x2e, 0x65, 0x61, 0x73, 0x79, 0x70, 0x77, 0x6e, 0x2e, 0x47, 0x65, + 0x74, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x22, 0x00, 0x12, 0x4d, 0x0a, 0x0c, 0x47, 0x65, 0x74, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, + 0x63, 0x65, 0x73, 0x12, 0x1c, 0x2e, 0x65, 0x61, 0x73, 0x79, 0x70, 0x77, 0x6e, 0x2e, 0x47, 0x65, + 0x74, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x1a, 0x1d, 0x2e, 0x65, 0x61, 0x73, 0x79, 0x70, 0x77, 0x6e, 0x2e, 0x47, 0x65, 0x74, 0x49, + 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x22, 0x00, 0x12, 0x53, 0x0a, 0x0e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x49, 0x6e, 0x73, 0x74, + 0x61, 0x6e, 0x63, 0x65, 0x12, 0x1e, 0x2e, 0x65, 0x61, 0x73, 0x79, 0x70, 0x77, 0x6e, 0x2e, 0x44, + 0x65, 0x6c, 0x65, 0x74, 0x65, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1f, 0x2e, 0x65, 0x61, 0x73, 0x79, 0x70, 0x77, 0x6e, 0x2e, 0x44, + 0x65, 0x6c, 0x65, 0x74, 0x65, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x56, 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x49, 0x6e, + 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x4c, 0x6f, 0x67, 0x73, 0x12, 0x1f, 0x2e, 0x65, 0x61, 0x73, + 0x79, 0x70, 0x77, 0x6e, 0x2e, 0x47, 0x65, 0x74, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, + 0x4c, 0x6f, 0x67, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x20, 0x2e, 0x65, 0x61, + 0x73, 0x79, 0x70, 0x77, 0x6e, 0x2e, 0x47, 0x65, 0x74, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, + 0x65, 0x4c, 0x6f, 0x67, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, + 0x4d, 0x0a, 0x0c, 0x53, 0x74, 0x6f, 0x70, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x12, + 0x1c, 0x2e, 0x65, 0x61, 0x73, 0x79, 0x70, 0x77, 0x6e, 0x2e, 0x53, 0x74, 0x6f, 0x70, 0x49, 0x6e, + 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d, 0x2e, + 0x65, 0x61, 0x73, 0x79, 0x70, 0x77, 0x6e, 0x2e, 0x53, 0x74, 0x6f, 0x70, 0x49, 0x6e, 0x73, 0x74, + 0x61, 0x6e, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x50, + 0x0a, 0x0d, 0x53, 0x74, 0x61, 0x72, 0x74, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x12, + 0x1d, 0x2e, 0x65, 0x61, 0x73, 0x79, 0x70, 0x77, 0x6e, 0x2e, 0x53, 0x74, 0x61, 0x72, 0x74, 0x49, + 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1e, + 0x2e, 0x65, 0x61, 0x73, 0x79, 0x70, 0x77, 0x6e, 0x2e, 0x53, 0x74, 0x61, 0x72, 0x74, 0x49, 0x6e, + 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, + 0x42, 0x16, 0x5a, 0x14, 0x65, 0x61, 0x73, 0x79, 0x70, 0x77, 0x6e, 0x2f, 0x69, 0x6e, 0x74, 0x65, + 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x61, 0x70, 0x69, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -497,31 +793,44 @@ func file_api_instance_proto_rawDescGZIP() []byte { return file_api_instance_proto_rawDescData } -var file_api_instance_proto_msgTypes = make([]protoimpl.MessageInfo, 8) -var file_api_instance_proto_goTypes = []interface{}{ +var file_api_instance_proto_msgTypes = make([]protoimpl.MessageInfo, 14) +var file_api_instance_proto_goTypes = []any{ (*CreateInstanceRequest)(nil), // 0: easypwn.CreateInstanceRequest (*CreateInstanceResponse)(nil), // 1: easypwn.CreateInstanceResponse (*GetInstanceRequest)(nil), // 2: easypwn.GetInstanceRequest (*GetInstanceResponse)(nil), // 3: easypwn.GetInstanceResponse - (*DeleteInstanceRequest)(nil), // 4: easypwn.DeleteInstanceRequest - (*DeleteInstanceResponse)(nil), // 5: easypwn.DeleteInstanceResponse - (*GetInstanceLogsRequest)(nil), // 6: easypwn.GetInstanceLogsRequest - (*GetInstanceLogsResponse)(nil), // 7: easypwn.GetInstanceLogsResponse + (*GetInstancesRequest)(nil), // 4: easypwn.GetInstancesRequest + (*GetInstancesResponse)(nil), // 5: easypwn.GetInstancesResponse + (*DeleteInstanceRequest)(nil), // 6: easypwn.DeleteInstanceRequest + (*DeleteInstanceResponse)(nil), // 7: easypwn.DeleteInstanceResponse + (*GetInstanceLogsRequest)(nil), // 8: easypwn.GetInstanceLogsRequest + (*GetInstanceLogsResponse)(nil), // 9: easypwn.GetInstanceLogsResponse + (*StopInstanceRequest)(nil), // 10: easypwn.StopInstanceRequest + (*StopInstanceResponse)(nil), // 11: easypwn.StopInstanceResponse + (*StartInstanceRequest)(nil), // 12: easypwn.StartInstanceRequest + (*StartInstanceResponse)(nil), // 13: easypwn.StartInstanceResponse } var file_api_instance_proto_depIdxs = []int32{ - 0, // 0: easypwn.Instance.CreateInstance:input_type -> easypwn.CreateInstanceRequest - 2, // 1: easypwn.Instance.GetInstance:input_type -> easypwn.GetInstanceRequest - 4, // 2: easypwn.Instance.DeleteInstance:input_type -> easypwn.DeleteInstanceRequest - 6, // 3: easypwn.Instance.GetInstanceLogs:input_type -> easypwn.GetInstanceLogsRequest - 1, // 4: easypwn.Instance.CreateInstance:output_type -> easypwn.CreateInstanceResponse - 3, // 5: easypwn.Instance.GetInstance:output_type -> easypwn.GetInstanceResponse - 5, // 6: easypwn.Instance.DeleteInstance:output_type -> easypwn.DeleteInstanceResponse - 7, // 7: easypwn.Instance.GetInstanceLogs:output_type -> easypwn.GetInstanceLogsResponse - 4, // [4:8] is the sub-list for method output_type - 0, // [0:4] 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 + 3, // 0: easypwn.GetInstancesResponse.instances:type_name -> easypwn.GetInstanceResponse + 0, // 1: easypwn.Instance.CreateInstance:input_type -> easypwn.CreateInstanceRequest + 2, // 2: easypwn.Instance.GetInstance:input_type -> easypwn.GetInstanceRequest + 4, // 3: easypwn.Instance.GetInstances:input_type -> easypwn.GetInstancesRequest + 6, // 4: easypwn.Instance.DeleteInstance:input_type -> easypwn.DeleteInstanceRequest + 8, // 5: easypwn.Instance.GetInstanceLogs:input_type -> easypwn.GetInstanceLogsRequest + 10, // 6: easypwn.Instance.StopInstance:input_type -> easypwn.StopInstanceRequest + 12, // 7: easypwn.Instance.StartInstance:input_type -> easypwn.StartInstanceRequest + 1, // 8: easypwn.Instance.CreateInstance:output_type -> easypwn.CreateInstanceResponse + 3, // 9: easypwn.Instance.GetInstance:output_type -> easypwn.GetInstanceResponse + 5, // 10: easypwn.Instance.GetInstances:output_type -> easypwn.GetInstancesResponse + 7, // 11: easypwn.Instance.DeleteInstance:output_type -> easypwn.DeleteInstanceResponse + 9, // 12: easypwn.Instance.GetInstanceLogs:output_type -> easypwn.GetInstanceLogsResponse + 11, // 13: easypwn.Instance.StopInstance:output_type -> easypwn.StopInstanceResponse + 13, // 14: easypwn.Instance.StartInstance:output_type -> easypwn.StartInstanceResponse + 8, // [8:15] is the sub-list for method output_type + 1, // [1:8] is the sub-list for method input_type + 1, // [1:1] is the sub-list for extension type_name + 1, // [1:1] is the sub-list for extension extendee + 0, // [0:1] is the sub-list for field type_name } func init() { file_api_instance_proto_init() } @@ -529,111 +838,13 @@ func file_api_instance_proto_init() { if File_api_instance_proto != nil { return } - if !protoimpl.UnsafeEnabled { - file_api_instance_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*CreateInstanceRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_api_instance_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*CreateInstanceResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_api_instance_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*GetInstanceRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_api_instance_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*GetInstanceResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_api_instance_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*DeleteInstanceRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_api_instance_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*DeleteInstanceResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_api_instance_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*GetInstanceLogsRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_api_instance_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*GetInstanceLogsResponse); 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{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_api_instance_proto_rawDesc, NumEnums: 0, - NumMessages: 8, + NumMessages: 14, NumExtensions: 0, NumServices: 1, }, diff --git a/internal/api/instance_grpc.pb.go b/internal/api/instance_grpc.pb.go index 802e0f9..214d451 100644 --- a/internal/api/instance_grpc.pb.go +++ b/internal/api/instance_grpc.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: // - protoc-gen-go-grpc v1.5.1 -// - protoc v5.29.2 +// - protoc v5.29.3 // source: api/instance.proto package api @@ -21,8 +21,11 @@ const _ = grpc.SupportPackageIsVersion9 const ( Instance_CreateInstance_FullMethodName = "/easypwn.Instance/CreateInstance" Instance_GetInstance_FullMethodName = "/easypwn.Instance/GetInstance" + Instance_GetInstances_FullMethodName = "/easypwn.Instance/GetInstances" Instance_DeleteInstance_FullMethodName = "/easypwn.Instance/DeleteInstance" Instance_GetInstanceLogs_FullMethodName = "/easypwn.Instance/GetInstanceLogs" + Instance_StopInstance_FullMethodName = "/easypwn.Instance/StopInstance" + Instance_StartInstance_FullMethodName = "/easypwn.Instance/StartInstance" ) // InstanceClient is the client API for Instance service. @@ -31,8 +34,11 @@ const ( type InstanceClient interface { CreateInstance(ctx context.Context, in *CreateInstanceRequest, opts ...grpc.CallOption) (*CreateInstanceResponse, error) GetInstance(ctx context.Context, in *GetInstanceRequest, opts ...grpc.CallOption) (*GetInstanceResponse, error) + GetInstances(ctx context.Context, in *GetInstancesRequest, opts ...grpc.CallOption) (*GetInstancesResponse, error) DeleteInstance(ctx context.Context, in *DeleteInstanceRequest, opts ...grpc.CallOption) (*DeleteInstanceResponse, error) GetInstanceLogs(ctx context.Context, in *GetInstanceLogsRequest, opts ...grpc.CallOption) (*GetInstanceLogsResponse, error) + StopInstance(ctx context.Context, in *StopInstanceRequest, opts ...grpc.CallOption) (*StopInstanceResponse, error) + StartInstance(ctx context.Context, in *StartInstanceRequest, opts ...grpc.CallOption) (*StartInstanceResponse, error) } type instanceClient struct { @@ -63,6 +69,16 @@ func (c *instanceClient) GetInstance(ctx context.Context, in *GetInstanceRequest return out, nil } +func (c *instanceClient) GetInstances(ctx context.Context, in *GetInstancesRequest, opts ...grpc.CallOption) (*GetInstancesResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(GetInstancesResponse) + err := c.cc.Invoke(ctx, Instance_GetInstances_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *instanceClient) DeleteInstance(ctx context.Context, in *DeleteInstanceRequest, opts ...grpc.CallOption) (*DeleteInstanceResponse, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(DeleteInstanceResponse) @@ -83,14 +99,37 @@ func (c *instanceClient) GetInstanceLogs(ctx context.Context, in *GetInstanceLog return out, nil } +func (c *instanceClient) StopInstance(ctx context.Context, in *StopInstanceRequest, opts ...grpc.CallOption) (*StopInstanceResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(StopInstanceResponse) + err := c.cc.Invoke(ctx, Instance_StopInstance_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *instanceClient) StartInstance(ctx context.Context, in *StartInstanceRequest, opts ...grpc.CallOption) (*StartInstanceResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(StartInstanceResponse) + err := c.cc.Invoke(ctx, Instance_StartInstance_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + // InstanceServer is the server API for Instance service. // All implementations must embed UnimplementedInstanceServer // for forward compatibility. type InstanceServer interface { CreateInstance(context.Context, *CreateInstanceRequest) (*CreateInstanceResponse, error) GetInstance(context.Context, *GetInstanceRequest) (*GetInstanceResponse, error) + GetInstances(context.Context, *GetInstancesRequest) (*GetInstancesResponse, error) DeleteInstance(context.Context, *DeleteInstanceRequest) (*DeleteInstanceResponse, error) GetInstanceLogs(context.Context, *GetInstanceLogsRequest) (*GetInstanceLogsResponse, error) + StopInstance(context.Context, *StopInstanceRequest) (*StopInstanceResponse, error) + StartInstance(context.Context, *StartInstanceRequest) (*StartInstanceResponse, error) mustEmbedUnimplementedInstanceServer() } @@ -107,12 +146,21 @@ func (UnimplementedInstanceServer) CreateInstance(context.Context, *CreateInstan func (UnimplementedInstanceServer) GetInstance(context.Context, *GetInstanceRequest) (*GetInstanceResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method GetInstance not implemented") } +func (UnimplementedInstanceServer) GetInstances(context.Context, *GetInstancesRequest) (*GetInstancesResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetInstances not implemented") +} func (UnimplementedInstanceServer) DeleteInstance(context.Context, *DeleteInstanceRequest) (*DeleteInstanceResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method DeleteInstance not implemented") } func (UnimplementedInstanceServer) GetInstanceLogs(context.Context, *GetInstanceLogsRequest) (*GetInstanceLogsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method GetInstanceLogs not implemented") } +func (UnimplementedInstanceServer) StopInstance(context.Context, *StopInstanceRequest) (*StopInstanceResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method StopInstance not implemented") +} +func (UnimplementedInstanceServer) StartInstance(context.Context, *StartInstanceRequest) (*StartInstanceResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method StartInstance not implemented") +} func (UnimplementedInstanceServer) mustEmbedUnimplementedInstanceServer() {} func (UnimplementedInstanceServer) testEmbeddedByValue() {} @@ -170,6 +218,24 @@ func _Instance_GetInstance_Handler(srv interface{}, ctx context.Context, dec fun return interceptor(ctx, in, info, handler) } +func _Instance_GetInstances_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetInstancesRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(InstanceServer).GetInstances(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Instance_GetInstances_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(InstanceServer).GetInstances(ctx, req.(*GetInstancesRequest)) + } + return interceptor(ctx, in, info, handler) +} + func _Instance_DeleteInstance_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(DeleteInstanceRequest) if err := dec(in); err != nil { @@ -206,6 +272,42 @@ func _Instance_GetInstanceLogs_Handler(srv interface{}, ctx context.Context, dec return interceptor(ctx, in, info, handler) } +func _Instance_StopInstance_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(StopInstanceRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(InstanceServer).StopInstance(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Instance_StopInstance_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(InstanceServer).StopInstance(ctx, req.(*StopInstanceRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Instance_StartInstance_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(StartInstanceRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(InstanceServer).StartInstance(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Instance_StartInstance_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(InstanceServer).StartInstance(ctx, req.(*StartInstanceRequest)) + } + return interceptor(ctx, in, info, handler) +} + // Instance_ServiceDesc is the grpc.ServiceDesc for Instance service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) @@ -221,6 +323,10 @@ var Instance_ServiceDesc = grpc.ServiceDesc{ MethodName: "GetInstance", Handler: _Instance_GetInstance_Handler, }, + { + MethodName: "GetInstances", + Handler: _Instance_GetInstances_Handler, + }, { MethodName: "DeleteInstance", Handler: _Instance_DeleteInstance_Handler, @@ -229,6 +335,14 @@ var Instance_ServiceDesc = grpc.ServiceDesc{ MethodName: "GetInstanceLogs", Handler: _Instance_GetInstanceLogs_Handler, }, + { + MethodName: "StopInstance", + Handler: _Instance_StopInstance_Handler, + }, + { + MethodName: "StartInstance", + Handler: _Instance_StartInstance_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "api/instance.proto", diff --git a/internal/api/mailer.pb.go b/internal/api/mailer.pb.go index 6ef3ed3..be2c006 100644 --- a/internal/api/mailer.pb.go +++ b/internal/api/mailer.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.1 -// protoc v5.29.2 +// protoc-gen-go v1.36.2 +// protoc v5.29.3 // source: api/mailer.proto package api @@ -21,20 +21,17 @@ const ( ) type SendConfirmationEmailRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Email string `protobuf:"bytes,1,opt,name=email,proto3" json:"email,omitempty"` unknownFields protoimpl.UnknownFields - - Email string `protobuf:"bytes,1,opt,name=email,proto3" json:"email,omitempty"` + sizeCache protoimpl.SizeCache } func (x *SendConfirmationEmailRequest) Reset() { *x = SendConfirmationEmailRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_api_mailer_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_api_mailer_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *SendConfirmationEmailRequest) String() string { @@ -45,7 +42,7 @@ func (*SendConfirmationEmailRequest) ProtoMessage() {} func (x *SendConfirmationEmailRequest) ProtoReflect() protoreflect.Message { mi := &file_api_mailer_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -68,20 +65,17 @@ func (x *SendConfirmationEmailRequest) GetEmail() string { } type SendConfirmationEmailResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Code string `protobuf:"bytes,1,opt,name=code,proto3" json:"code,omitempty"` unknownFields protoimpl.UnknownFields - - Code string `protobuf:"bytes,1,opt,name=code,proto3" json:"code,omitempty"` + sizeCache protoimpl.SizeCache } func (x *SendConfirmationEmailResponse) Reset() { *x = SendConfirmationEmailResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_api_mailer_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_api_mailer_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *SendConfirmationEmailResponse) String() string { @@ -92,7 +86,7 @@ func (*SendConfirmationEmailResponse) ProtoMessage() {} func (x *SendConfirmationEmailResponse) ProtoReflect() protoreflect.Message { mi := &file_api_mailer_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -115,20 +109,17 @@ func (x *SendConfirmationEmailResponse) GetCode() string { } type GetConfirmationCodeRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Email string `protobuf:"bytes,1,opt,name=email,proto3" json:"email,omitempty"` unknownFields protoimpl.UnknownFields - - Email string `protobuf:"bytes,1,opt,name=email,proto3" json:"email,omitempty"` + sizeCache protoimpl.SizeCache } func (x *GetConfirmationCodeRequest) Reset() { *x = GetConfirmationCodeRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_api_mailer_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_api_mailer_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *GetConfirmationCodeRequest) String() string { @@ -139,7 +130,7 @@ func (*GetConfirmationCodeRequest) ProtoMessage() {} func (x *GetConfirmationCodeRequest) ProtoReflect() protoreflect.Message { mi := &file_api_mailer_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -162,20 +153,17 @@ func (x *GetConfirmationCodeRequest) GetEmail() string { } type GetConfirmationCodeResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Code string `protobuf:"bytes,1,opt,name=code,proto3" json:"code,omitempty"` unknownFields protoimpl.UnknownFields - - Code string `protobuf:"bytes,1,opt,name=code,proto3" json:"code,omitempty"` + sizeCache protoimpl.SizeCache } func (x *GetConfirmationCodeResponse) Reset() { *x = GetConfirmationCodeResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_api_mailer_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_api_mailer_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *GetConfirmationCodeResponse) String() string { @@ -186,7 +174,7 @@ func (*GetConfirmationCodeResponse) ProtoMessage() {} func (x *GetConfirmationCodeResponse) ProtoReflect() protoreflect.Message { mi := &file_api_mailer_proto_msgTypes[3] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -257,7 +245,7 @@ func file_api_mailer_proto_rawDescGZIP() []byte { } var file_api_mailer_proto_msgTypes = make([]protoimpl.MessageInfo, 4) -var file_api_mailer_proto_goTypes = []interface{}{ +var file_api_mailer_proto_goTypes = []any{ (*SendConfirmationEmailRequest)(nil), // 0: easypwn.SendConfirmationEmailRequest (*SendConfirmationEmailResponse)(nil), // 1: easypwn.SendConfirmationEmailResponse (*GetConfirmationCodeRequest)(nil), // 2: easypwn.GetConfirmationCodeRequest @@ -280,56 +268,6 @@ func file_api_mailer_proto_init() { if File_api_mailer_proto != nil { return } - if !protoimpl.UnsafeEnabled { - file_api_mailer_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*SendConfirmationEmailRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_api_mailer_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*SendConfirmationEmailResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_api_mailer_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*GetConfirmationCodeRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_api_mailer_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*GetConfirmationCodeResponse); 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{ File: protoimpl.DescBuilder{ diff --git a/internal/api/mailer_grpc.pb.go b/internal/api/mailer_grpc.pb.go index 955f461..9370c7f 100644 --- a/internal/api/mailer_grpc.pb.go +++ b/internal/api/mailer_grpc.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: // - protoc-gen-go-grpc v1.5.1 -// - protoc v5.29.2 +// - protoc v5.29.3 // source: api/mailer.proto package api diff --git a/internal/api/project.pb.go b/internal/api/project.pb.go index 6ba773c..bfa90bd 100644 --- a/internal/api/project.pb.go +++ b/internal/api/project.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.1 -// protoc v5.29.2 +// protoc-gen-go v1.36.2 +// protoc v5.29.3 // source: api/project.proto package api @@ -21,25 +21,22 @@ const ( ) type CreateProjectRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + UserId string `protobuf:"bytes,2,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` + FilePath string `protobuf:"bytes,3,opt,name=file_path,json=filePath,proto3" json:"file_path,omitempty"` + FileName string `protobuf:"bytes,4,opt,name=file_name,json=fileName,proto3" json:"file_name,omitempty"` + OsId string `protobuf:"bytes,5,opt,name=os_id,json=osId,proto3" json:"os_id,omitempty"` + PluginId string `protobuf:"bytes,6,opt,name=plugin_id,json=pluginId,proto3" json:"plugin_id,omitempty"` unknownFields protoimpl.UnknownFields - - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` - UserId string `protobuf:"bytes,2,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` - FilePath string `protobuf:"bytes,3,opt,name=file_path,json=filePath,proto3" json:"file_path,omitempty"` - FileName string `protobuf:"bytes,4,opt,name=file_name,json=fileName,proto3" json:"file_name,omitempty"` - OsId string `protobuf:"bytes,5,opt,name=os_id,json=osId,proto3" json:"os_id,omitempty"` - PluginId string `protobuf:"bytes,6,opt,name=plugin_id,json=pluginId,proto3" json:"plugin_id,omitempty"` + sizeCache protoimpl.SizeCache } func (x *CreateProjectRequest) Reset() { *x = CreateProjectRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_api_project_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_api_project_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *CreateProjectRequest) String() string { @@ -50,7 +47,7 @@ func (*CreateProjectRequest) ProtoMessage() {} func (x *CreateProjectRequest) ProtoReflect() protoreflect.Message { mi := &file_api_project_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -108,20 +105,17 @@ func (x *CreateProjectRequest) GetPluginId() string { } type CreateProjectResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + ProjectId string `protobuf:"bytes,1,opt,name=project_id,json=projectId,proto3" json:"project_id,omitempty"` unknownFields protoimpl.UnknownFields - - ProjectId string `protobuf:"bytes,1,opt,name=project_id,json=projectId,proto3" json:"project_id,omitempty"` + sizeCache protoimpl.SizeCache } func (x *CreateProjectResponse) Reset() { *x = CreateProjectResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_api_project_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_api_project_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *CreateProjectResponse) String() string { @@ -132,7 +126,7 @@ func (*CreateProjectResponse) ProtoMessage() {} func (x *CreateProjectResponse) ProtoReflect() protoreflect.Message { mi := &file_api_project_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -155,20 +149,17 @@ func (x *CreateProjectResponse) GetProjectId() string { } type GetProjectRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + ProjectId string `protobuf:"bytes,1,opt,name=project_id,json=projectId,proto3" json:"project_id,omitempty"` unknownFields protoimpl.UnknownFields - - ProjectId string `protobuf:"bytes,1,opt,name=project_id,json=projectId,proto3" json:"project_id,omitempty"` + sizeCache protoimpl.SizeCache } func (x *GetProjectRequest) Reset() { *x = GetProjectRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_api_project_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_api_project_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *GetProjectRequest) String() string { @@ -179,7 +170,7 @@ func (*GetProjectRequest) ProtoMessage() {} func (x *GetProjectRequest) ProtoReflect() protoreflect.Message { mi := &file_api_project_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -202,27 +193,24 @@ func (x *GetProjectRequest) GetProjectId() string { } type GetProjectResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + ProjectId string `protobuf:"bytes,1,opt,name=project_id,json=projectId,proto3" json:"project_id,omitempty"` + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` + UserId string `protobuf:"bytes,3,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` + FilePath string `protobuf:"bytes,4,opt,name=file_path,json=filePath,proto3" json:"file_path,omitempty"` + FileName string `protobuf:"bytes,5,opt,name=file_name,json=fileName,proto3" json:"file_name,omitempty"` + OsId string `protobuf:"bytes,6,opt,name=os_id,json=osId,proto3" json:"os_id,omitempty"` + PluginId string `protobuf:"bytes,7,opt,name=plugin_id,json=pluginId,proto3" json:"plugin_id,omitempty"` + CreatedAt string `protobuf:"bytes,8,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"` unknownFields protoimpl.UnknownFields - - ProjectId string `protobuf:"bytes,1,opt,name=project_id,json=projectId,proto3" json:"project_id,omitempty"` - Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` - UserId string `protobuf:"bytes,3,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` - FilePath string `protobuf:"bytes,4,opt,name=file_path,json=filePath,proto3" json:"file_path,omitempty"` - FileName string `protobuf:"bytes,5,opt,name=file_name,json=fileName,proto3" json:"file_name,omitempty"` - OsId string `protobuf:"bytes,6,opt,name=os_id,json=osId,proto3" json:"os_id,omitempty"` - PluginId string `protobuf:"bytes,7,opt,name=plugin_id,json=pluginId,proto3" json:"plugin_id,omitempty"` - CreatedAt string `protobuf:"bytes,8,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"` + sizeCache protoimpl.SizeCache } func (x *GetProjectResponse) Reset() { *x = GetProjectResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_api_project_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_api_project_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *GetProjectResponse) String() string { @@ -233,7 +221,7 @@ func (*GetProjectResponse) ProtoMessage() {} func (x *GetProjectResponse) ProtoReflect() protoreflect.Message { mi := &file_api_project_proto_msgTypes[3] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -305,20 +293,17 @@ func (x *GetProjectResponse) GetCreatedAt() string { } type GetProjectsRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + UserId string `protobuf:"bytes,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` unknownFields protoimpl.UnknownFields - - UserId string `protobuf:"bytes,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` + sizeCache protoimpl.SizeCache } func (x *GetProjectsRequest) Reset() { *x = GetProjectsRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_api_project_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_api_project_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *GetProjectsRequest) String() string { @@ -329,7 +314,7 @@ func (*GetProjectsRequest) ProtoMessage() {} func (x *GetProjectsRequest) ProtoReflect() protoreflect.Message { mi := &file_api_project_proto_msgTypes[4] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -352,20 +337,17 @@ func (x *GetProjectsRequest) GetUserId() string { } type GetProjectsResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Projects []*GetProjectResponse `protobuf:"bytes,1,rep,name=projects,proto3" json:"projects,omitempty"` unknownFields protoimpl.UnknownFields - - Projects []*GetProjectResponse `protobuf:"bytes,1,rep,name=projects,proto3" json:"projects,omitempty"` + sizeCache protoimpl.SizeCache } func (x *GetProjectsResponse) Reset() { *x = GetProjectsResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_api_project_proto_msgTypes[5] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_api_project_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *GetProjectsResponse) String() string { @@ -376,7 +358,7 @@ func (*GetProjectsResponse) ProtoMessage() {} func (x *GetProjectsResponse) ProtoReflect() protoreflect.Message { mi := &file_api_project_proto_msgTypes[5] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -399,20 +381,17 @@ func (x *GetProjectsResponse) GetProjects() []*GetProjectResponse { } type DeleteProjectRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + ProjectId string `protobuf:"bytes,1,opt,name=project_id,json=projectId,proto3" json:"project_id,omitempty"` unknownFields protoimpl.UnknownFields - - ProjectId string `protobuf:"bytes,1,opt,name=project_id,json=projectId,proto3" json:"project_id,omitempty"` + sizeCache protoimpl.SizeCache } func (x *DeleteProjectRequest) Reset() { *x = DeleteProjectRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_api_project_proto_msgTypes[6] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_api_project_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *DeleteProjectRequest) String() string { @@ -423,7 +402,7 @@ func (*DeleteProjectRequest) ProtoMessage() {} func (x *DeleteProjectRequest) ProtoReflect() protoreflect.Message { mi := &file_api_project_proto_msgTypes[6] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -446,20 +425,17 @@ func (x *DeleteProjectRequest) GetProjectId() string { } type DeleteProjectResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + ProjectId string `protobuf:"bytes,1,opt,name=project_id,json=projectId,proto3" json:"project_id,omitempty"` unknownFields protoimpl.UnknownFields - - ProjectId string `protobuf:"bytes,1,opt,name=project_id,json=projectId,proto3" json:"project_id,omitempty"` + sizeCache protoimpl.SizeCache } func (x *DeleteProjectResponse) Reset() { *x = DeleteProjectResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_api_project_proto_msgTypes[7] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_api_project_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *DeleteProjectResponse) String() string { @@ -470,7 +446,7 @@ func (*DeleteProjectResponse) ProtoMessage() {} func (x *DeleteProjectResponse) ProtoReflect() protoreflect.Message { mi := &file_api_project_proto_msgTypes[7] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -493,18 +469,16 @@ func (x *DeleteProjectResponse) GetProjectId() string { } type GetOsListRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *GetOsListRequest) Reset() { *x = GetOsListRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_api_project_proto_msgTypes[8] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_api_project_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *GetOsListRequest) String() string { @@ -515,7 +489,7 @@ func (*GetOsListRequest) ProtoMessage() {} func (x *GetOsListRequest) ProtoReflect() protoreflect.Message { mi := &file_api_project_proto_msgTypes[8] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -531,21 +505,18 @@ func (*GetOsListRequest) Descriptor() ([]byte, []int) { } type GetOsResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` unknownFields protoimpl.UnknownFields - - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` + sizeCache protoimpl.SizeCache } func (x *GetOsResponse) Reset() { *x = GetOsResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_api_project_proto_msgTypes[9] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_api_project_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *GetOsResponse) String() string { @@ -556,7 +527,7 @@ func (*GetOsResponse) ProtoMessage() {} func (x *GetOsResponse) ProtoReflect() protoreflect.Message { mi := &file_api_project_proto_msgTypes[9] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -586,20 +557,17 @@ func (x *GetOsResponse) GetName() string { } type GetOsListResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + OsList []*GetOsResponse `protobuf:"bytes,1,rep,name=os_list,json=osList,proto3" json:"os_list,omitempty"` unknownFields protoimpl.UnknownFields - - OsList []*GetOsResponse `protobuf:"bytes,1,rep,name=os_list,json=osList,proto3" json:"os_list,omitempty"` + sizeCache protoimpl.SizeCache } func (x *GetOsListResponse) Reset() { *x = GetOsListResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_api_project_proto_msgTypes[10] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_api_project_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *GetOsListResponse) String() string { @@ -610,7 +578,7 @@ func (*GetOsListResponse) ProtoMessage() {} func (x *GetOsListResponse) ProtoReflect() protoreflect.Message { mi := &file_api_project_proto_msgTypes[10] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -633,18 +601,16 @@ func (x *GetOsListResponse) GetOsList() []*GetOsResponse { } type GetPluginListRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *GetPluginListRequest) Reset() { *x = GetPluginListRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_api_project_proto_msgTypes[11] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_api_project_proto_msgTypes[11] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *GetPluginListRequest) String() string { @@ -655,7 +621,7 @@ func (*GetPluginListRequest) ProtoMessage() {} func (x *GetPluginListRequest) ProtoReflect() protoreflect.Message { mi := &file_api_project_proto_msgTypes[11] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -671,21 +637,18 @@ func (*GetPluginListRequest) Descriptor() ([]byte, []int) { } type GetPluginResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` unknownFields protoimpl.UnknownFields - - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` + sizeCache protoimpl.SizeCache } func (x *GetPluginResponse) Reset() { *x = GetPluginResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_api_project_proto_msgTypes[12] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_api_project_proto_msgTypes[12] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *GetPluginResponse) String() string { @@ -696,7 +659,7 @@ func (*GetPluginResponse) ProtoMessage() {} func (x *GetPluginResponse) ProtoReflect() protoreflect.Message { mi := &file_api_project_proto_msgTypes[12] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -726,20 +689,17 @@ func (x *GetPluginResponse) GetName() string { } type GetPluginListResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + PluginList []*GetPluginResponse `protobuf:"bytes,1,rep,name=plugin_list,json=pluginList,proto3" json:"plugin_list,omitempty"` unknownFields protoimpl.UnknownFields - - PluginList []*GetPluginResponse `protobuf:"bytes,1,rep,name=plugin_list,json=pluginList,proto3" json:"plugin_list,omitempty"` + sizeCache protoimpl.SizeCache } func (x *GetPluginListResponse) Reset() { *x = GetPluginListResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_api_project_proto_msgTypes[13] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_api_project_proto_msgTypes[13] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *GetPluginListResponse) String() string { @@ -750,7 +710,7 @@ func (*GetPluginListResponse) ProtoMessage() {} func (x *GetPluginListResponse) ProtoReflect() protoreflect.Message { mi := &file_api_project_proto_msgTypes[13] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -891,7 +851,7 @@ func file_api_project_proto_rawDescGZIP() []byte { } var file_api_project_proto_msgTypes = make([]protoimpl.MessageInfo, 14) -var file_api_project_proto_goTypes = []interface{}{ +var file_api_project_proto_goTypes = []any{ (*CreateProjectRequest)(nil), // 0: easypwn.CreateProjectRequest (*CreateProjectResponse)(nil), // 1: easypwn.CreateProjectResponse (*GetProjectRequest)(nil), // 2: easypwn.GetProjectRequest @@ -935,176 +895,6 @@ func file_api_project_proto_init() { if File_api_project_proto != nil { return } - if !protoimpl.UnsafeEnabled { - file_api_project_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*CreateProjectRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_api_project_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*CreateProjectResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_api_project_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*GetProjectRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_api_project_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*GetProjectResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_api_project_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*GetProjectsRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_api_project_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*GetProjectsResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_api_project_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*DeleteProjectRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_api_project_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*DeleteProjectResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_api_project_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*GetOsListRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_api_project_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*GetOsResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_api_project_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*GetOsListResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_api_project_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*GetPluginListRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_api_project_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*GetPluginResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_api_project_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*GetPluginListResponse); 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{ File: protoimpl.DescBuilder{ diff --git a/internal/api/project_grpc.pb.go b/internal/api/project_grpc.pb.go index de984aa..4939512 100644 --- a/internal/api/project_grpc.pb.go +++ b/internal/api/project_grpc.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: // - protoc-gen-go-grpc v1.5.1 -// - protoc v5.29.2 +// - protoc v5.29.3 // source: api/project.proto package api diff --git a/internal/api/user.pb.go b/internal/api/user.pb.go index 51f6a03..70143f0 100644 --- a/internal/api/user.pb.go +++ b/internal/api/user.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.1 -// protoc v5.29.2 +// protoc-gen-go v1.36.2 +// protoc v5.29.3 // source: api/user.proto package api @@ -21,21 +21,18 @@ const ( ) type AuthLoginRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Email string `protobuf:"bytes,1,opt,name=email,proto3" json:"email,omitempty"` + Password string `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"` unknownFields protoimpl.UnknownFields - - Email string `protobuf:"bytes,1,opt,name=email,proto3" json:"email,omitempty"` - Password string `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"` + sizeCache protoimpl.SizeCache } func (x *AuthLoginRequest) Reset() { *x = AuthLoginRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_api_user_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_api_user_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *AuthLoginRequest) String() string { @@ -46,7 +43,7 @@ func (*AuthLoginRequest) ProtoMessage() {} func (x *AuthLoginRequest) ProtoReflect() protoreflect.Message { mi := &file_api_user_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -76,20 +73,17 @@ func (x *AuthLoginRequest) GetPassword() string { } type AuthLoginResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + UserId string `protobuf:"bytes,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` unknownFields protoimpl.UnknownFields - - UserId string `protobuf:"bytes,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` + sizeCache protoimpl.SizeCache } func (x *AuthLoginResponse) Reset() { *x = AuthLoginResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_api_user_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_api_user_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *AuthLoginResponse) String() string { @@ -100,7 +94,7 @@ func (*AuthLoginResponse) ProtoMessage() {} func (x *AuthLoginResponse) ProtoReflect() protoreflect.Message { mi := &file_api_user_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -123,21 +117,18 @@ func (x *AuthLoginResponse) GetUserId() string { } type CreateUserRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Email string `protobuf:"bytes,1,opt,name=email,proto3" json:"email,omitempty"` + Password string `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"` unknownFields protoimpl.UnknownFields - - Email string `protobuf:"bytes,1,opt,name=email,proto3" json:"email,omitempty"` - Password string `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"` + sizeCache protoimpl.SizeCache } func (x *CreateUserRequest) Reset() { *x = CreateUserRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_api_user_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_api_user_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *CreateUserRequest) String() string { @@ -148,7 +139,7 @@ func (*CreateUserRequest) ProtoMessage() {} func (x *CreateUserRequest) ProtoReflect() protoreflect.Message { mi := &file_api_user_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -178,20 +169,17 @@ func (x *CreateUserRequest) GetPassword() string { } type CreateUserResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + UserId string `protobuf:"bytes,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` unknownFields protoimpl.UnknownFields - - UserId string `protobuf:"bytes,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` + sizeCache protoimpl.SizeCache } func (x *CreateUserResponse) Reset() { *x = CreateUserResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_api_user_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_api_user_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *CreateUserResponse) String() string { @@ -202,7 +190,7 @@ func (*CreateUserResponse) ProtoMessage() {} func (x *CreateUserResponse) ProtoReflect() protoreflect.Message { mi := &file_api_user_proto_msgTypes[3] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -225,20 +213,17 @@ func (x *CreateUserResponse) GetUserId() string { } type GetUserRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + UserId string `protobuf:"bytes,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` unknownFields protoimpl.UnknownFields - - UserId string `protobuf:"bytes,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` + sizeCache protoimpl.SizeCache } func (x *GetUserRequest) Reset() { *x = GetUserRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_api_user_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_api_user_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *GetUserRequest) String() string { @@ -249,7 +234,7 @@ func (*GetUserRequest) ProtoMessage() {} func (x *GetUserRequest) ProtoReflect() protoreflect.Message { mi := &file_api_user_proto_msgTypes[4] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -272,23 +257,20 @@ func (x *GetUserRequest) GetUserId() string { } type GetUserResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + UserId string `protobuf:"bytes,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` + Email string `protobuf:"bytes,2,opt,name=email,proto3" json:"email,omitempty"` + Password string `protobuf:"bytes,3,opt,name=password,proto3" json:"password,omitempty"` + LicenseType string `protobuf:"bytes,4,opt,name=license_type,json=licenseType,proto3" json:"license_type,omitempty"` unknownFields protoimpl.UnknownFields - - UserId string `protobuf:"bytes,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` - Email string `protobuf:"bytes,2,opt,name=email,proto3" json:"email,omitempty"` - Password string `protobuf:"bytes,3,opt,name=password,proto3" json:"password,omitempty"` - LicenseType string `protobuf:"bytes,4,opt,name=license_type,json=licenseType,proto3" json:"license_type,omitempty"` + sizeCache protoimpl.SizeCache } func (x *GetUserResponse) Reset() { *x = GetUserResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_api_user_proto_msgTypes[5] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_api_user_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *GetUserResponse) String() string { @@ -299,7 +281,7 @@ func (*GetUserResponse) ProtoMessage() {} func (x *GetUserResponse) ProtoReflect() protoreflect.Message { mi := &file_api_user_proto_msgTypes[5] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -343,23 +325,20 @@ func (x *GetUserResponse) GetLicenseType() string { } type UpdateUserRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + UserId string `protobuf:"bytes,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` + Email string `protobuf:"bytes,2,opt,name=email,proto3" json:"email,omitempty"` + Password string `protobuf:"bytes,3,opt,name=password,proto3" json:"password,omitempty"` + LicenseType string `protobuf:"bytes,4,opt,name=license_type,json=licenseType,proto3" json:"license_type,omitempty"` unknownFields protoimpl.UnknownFields - - UserId string `protobuf:"bytes,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` - Email string `protobuf:"bytes,2,opt,name=email,proto3" json:"email,omitempty"` - Password string `protobuf:"bytes,3,opt,name=password,proto3" json:"password,omitempty"` - LicenseType string `protobuf:"bytes,4,opt,name=license_type,json=licenseType,proto3" json:"license_type,omitempty"` + sizeCache protoimpl.SizeCache } func (x *UpdateUserRequest) Reset() { *x = UpdateUserRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_api_user_proto_msgTypes[6] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_api_user_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *UpdateUserRequest) String() string { @@ -370,7 +349,7 @@ func (*UpdateUserRequest) ProtoMessage() {} func (x *UpdateUserRequest) ProtoReflect() protoreflect.Message { mi := &file_api_user_proto_msgTypes[6] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -414,20 +393,17 @@ func (x *UpdateUserRequest) GetLicenseType() string { } type UpdateUserResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + UserId string `protobuf:"bytes,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` unknownFields protoimpl.UnknownFields - - UserId string `protobuf:"bytes,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` + sizeCache protoimpl.SizeCache } func (x *UpdateUserResponse) Reset() { *x = UpdateUserResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_api_user_proto_msgTypes[7] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_api_user_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *UpdateUserResponse) String() string { @@ -438,7 +414,7 @@ func (*UpdateUserResponse) ProtoMessage() {} func (x *UpdateUserResponse) ProtoReflect() protoreflect.Message { mi := &file_api_user_proto_msgTypes[7] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -461,20 +437,17 @@ func (x *UpdateUserResponse) GetUserId() string { } type DeleteUserRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + UserId string `protobuf:"bytes,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` unknownFields protoimpl.UnknownFields - - UserId string `protobuf:"bytes,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` + sizeCache protoimpl.SizeCache } func (x *DeleteUserRequest) Reset() { *x = DeleteUserRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_api_user_proto_msgTypes[8] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_api_user_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *DeleteUserRequest) String() string { @@ -485,7 +458,7 @@ func (*DeleteUserRequest) ProtoMessage() {} func (x *DeleteUserRequest) ProtoReflect() protoreflect.Message { mi := &file_api_user_proto_msgTypes[8] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -508,20 +481,17 @@ func (x *DeleteUserRequest) GetUserId() string { } type DeleteUserResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + UserId string `protobuf:"bytes,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` unknownFields protoimpl.UnknownFields - - UserId string `protobuf:"bytes,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` + sizeCache protoimpl.SizeCache } func (x *DeleteUserResponse) Reset() { *x = DeleteUserResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_api_user_proto_msgTypes[9] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_api_user_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *DeleteUserResponse) String() string { @@ -532,7 +502,7 @@ func (*DeleteUserResponse) ProtoMessage() {} func (x *DeleteUserResponse) ProtoReflect() protoreflect.Message { mi := &file_api_user_proto_msgTypes[9] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -641,7 +611,7 @@ func file_api_user_proto_rawDescGZIP() []byte { } var file_api_user_proto_msgTypes = make([]protoimpl.MessageInfo, 10) -var file_api_user_proto_goTypes = []interface{}{ +var file_api_user_proto_goTypes = []any{ (*AuthLoginRequest)(nil), // 0: easypwn.AuthLoginRequest (*AuthLoginResponse)(nil), // 1: easypwn.AuthLoginResponse (*CreateUserRequest)(nil), // 2: easypwn.CreateUserRequest @@ -676,128 +646,6 @@ func file_api_user_proto_init() { if File_api_user_proto != nil { return } - if !protoimpl.UnsafeEnabled { - file_api_user_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*AuthLoginRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_api_user_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*AuthLoginResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_api_user_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*CreateUserRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_api_user_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*CreateUserResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_api_user_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*GetUserRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_api_user_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*GetUserResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_api_user_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*UpdateUserRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_api_user_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*UpdateUserResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_api_user_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*DeleteUserRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_api_user_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*DeleteUserResponse); 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{ File: protoimpl.DescBuilder{ diff --git a/internal/api/user_grpc.pb.go b/internal/api/user_grpc.pb.go index d342049..d17cd2f 100644 --- a/internal/api/user_grpc.pb.go +++ b/internal/api/user_grpc.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: // - protoc-gen-go-grpc v1.5.1 -// - protoc v5.29.2 +// - protoc v5.29.3 // source: api/user.proto package api diff --git a/internal/pkg/instance/docker.go b/internal/pkg/instance/docker.go index 5355d5d..0c96a44 100644 --- a/internal/pkg/instance/docker.go +++ b/internal/pkg/instance/docker.go @@ -149,3 +149,29 @@ func resizeExecTTY(ctx context.Context, cli *client.Client, execID string, size Width: size[1], }) } + +func getContainerStatus(ctx context.Context, cli *client.Client, containerID string) (string, error) { + container, err := cli.ContainerInspect(ctx, containerID) + if err != nil { + return "", err + } + if container.State.Running { + return "running", nil + } + return "stopped", nil +} + +func getContainerMemory(ctx context.Context, cli *client.Client, containerID string) (int, error) { + stats, err := cli.ContainerStats(ctx, containerID, false) + if err != nil { + return 0, err + } + defer stats.Body.Close() + + var memoryStats container.StatsResponse + if err := json.NewDecoder(stats.Body).Decode(&memoryStats); err != nil { + return 0, err + } + + return int(memoryStats.MemoryStats.Usage / 1024 / 1024), nil +} diff --git a/internal/pkg/instance/instance.go b/internal/pkg/instance/instance.go index 38c75cd..deaa991 100644 --- a/internal/pkg/instance/instance.go +++ b/internal/pkg/instance/instance.go @@ -100,6 +100,34 @@ func GetInstance(ctx context.Context, db *sql.DB, id string) (*Instance, error) return instance, nil } +func GetInstances(ctx context.Context, db *sql.DB, projectID string) ([]*Instance, error) { + var createdAt, updatedAt string + instances := []*Instance{} + rows, err := db.Query("SELECT BIN_TO_UUID(id), BIN_TO_UUID(project_id), container_id, DATE_FORMAT(created_at, '%Y-%m-%dT%H:%i:%sZ'), DATE_FORMAT(updated_at, '%Y-%m-%dT%H:%i:%sZ') FROM instance WHERE project_id = UUID_TO_BIN(?)", projectID) + if err != nil { + return nil, err + } + defer rows.Close() + + for rows.Next() { + instance := &Instance{} + err := rows.Scan(&instance.ID, &instance.ProjectID, &instance.ContainerID, &createdAt, &updatedAt) + if err != nil { + return nil, err + } + instance.CreatedAt, err = time.Parse(time.RFC3339, createdAt) + if err != nil { + return nil, err + } + instance.UpdatedAt, err = time.Parse(time.RFC3339, updatedAt) + if err != nil { + return nil, err + } + instances = append(instances, instance) + } + return instances, nil +} + func (i *Instance) Stop() error { return stopContainer(context.Background(), cli, i.ContainerID) } @@ -145,3 +173,15 @@ func (i *Instance) Execute(ctx context.Context, command ...string) (ExecInOut, e func (i *Instance) ResizeTTY(ctx context.Context, execID string, height, width uint) error { return resizeExecTTY(ctx, cli, execID, [2]uint{height, width}) } + +func (i *Instance) GetMemoryUsage(ctx context.Context) (int, error) { + return getContainerMemory(ctx, cli, i.ContainerID) +} + +func (i *Instance) GetStatus(ctx context.Context) (string, error) { + return getContainerStatus(ctx, cli, i.ContainerID) +} + +func (i *Instance) Start(ctx context.Context) error { + return startContainer(ctx, cli, i.ContainerID) +} diff --git a/internal/service/instance.go b/internal/service/instance.go index b936a00..b6729a2 100644 --- a/internal/service/instance.go +++ b/internal/service/instance.go @@ -38,6 +38,23 @@ func (s *InstanceService) GetInstance(ctx context.Context, req *pb.GetInstanceRe }, nil } +func (s *InstanceService) GetInstances(ctx context.Context, req *pb.GetInstancesRequest) (*pb.GetInstancesResponse, error) { + instances, err := instance.GetInstances(ctx, data.GetDB(), req.ProjectId) + if err != nil { + return nil, err + } + + responseInstances := []*pb.GetInstanceResponse{} + for _, instance := range instances { + responseInstances = append(responseInstances, &pb.GetInstanceResponse{ + InstanceId: instance.ID, + ProjectId: instance.ProjectID, + ContainerId: instance.ContainerID, + }) + } + return &pb.GetInstancesResponse{Instances: responseInstances}, nil +} + func (s *InstanceService) DeleteInstance(ctx context.Context, req *pb.DeleteInstanceRequest) (*pb.DeleteInstanceResponse, error) { instance, err := instance.GetInstance(ctx, data.GetDB(), req.InstanceId) if err != nil { @@ -67,3 +84,31 @@ func (s *InstanceService) GetInstanceLogs(ctx context.Context, req *pb.GetInstan return &pb.GetInstanceLogsResponse{Logs: logs}, nil } + +func (s *InstanceService) StopInstance(ctx context.Context, req *pb.StopInstanceRequest) (*pb.StopInstanceResponse, error) { + instance, err := instance.GetInstance(ctx, data.GetDB(), req.InstanceId) + if err != nil { + return nil, err + } + + err = instance.Stop() + if err != nil { + return nil, err + } + + return &pb.StopInstanceResponse{InstanceId: req.InstanceId}, nil +} + +func (s *InstanceService) StartInstance(ctx context.Context, req *pb.StartInstanceRequest) (*pb.StartInstanceResponse, error) { + instance, err := instance.GetInstance(ctx, data.GetDB(), req.InstanceId) + if err != nil { + return nil, err + } + + err = instance.Start(ctx) + if err != nil { + return nil, err + } + + return &pb.StartInstanceResponse{InstanceId: req.InstanceId}, nil +} diff --git a/web/lib/services/instance_service.dart b/web/lib/services/instance_service.dart new file mode 100644 index 0000000..c889536 --- /dev/null +++ b/web/lib/services/instance_service.dart @@ -0,0 +1,62 @@ +import 'package:http/http.dart' as http; + +class Instance { + final String id; + final String status; + final int memory; + final String createdAt; + final String updatedAt; + + Instance({required this.id, required this.status, required this.memory, required this.createdAt, required this.updatedAt}); +} + +class InstanceService { + final String token; + + InstanceService({required this.token}); + + Future> getInstances(String projectId) async { + final response = await http.get( + Uri.parse('/api/instance?project_id=$projectId'), + headers: { + 'Authorization': 'Bearer $token', + }, + ); + if (response.statusCode == 200) { + final data = jsonDecode(response.body); + if (data == null) return []; + return (data as List).map((instance) => Instance.fromJson(instance)).toList(); + } else { + throw Exception('Failed to get instances'); + } + } + + Future createInstance(String projectId) async { + final response = await http.post( + Uri.parse('/api/instance?project_id=$projectId'), + headers: { + 'Authorization': 'Bearer $token', + }, + ); + if (response.statusCode == 200) { + final data = jsonDecode(response.body); + return Instance.fromJson(data); + } else { + throw Exception('Failed to create instance'); + } + } + + Future deleteInstance(String instanceId) async { + final response = await http.delete( + Uri.parse('/api/instance/$instanceId'), + headers: { + 'Authorization': 'Bearer $token', + }, + ); + if (response.statusCode == 200) { + return; + } else { + throw Exception('Failed to delete instance'); + } + } +} \ No newline at end of file From 84813805901a3035e0554032d5e114e32f35a1f2 Mon Sep 17 00:00:00 2001 From: KIbeom Lee Date: Mon, 13 Jan 2025 01:08:45 +0900 Subject: [PATCH 05/12] implant api calls for instances --- web/lib/pages/instance.dart | 157 ++++++++++++++++--------- web/lib/pages/project.dart | 18 ++- web/lib/services/instance_service.dart | 28 +++++ 3 files changed, 146 insertions(+), 57 deletions(-) diff --git a/web/lib/pages/instance.dart b/web/lib/pages/instance.dart index 1758004..ce9bc4f 100644 --- a/web/lib/pages/instance.dart +++ b/web/lib/pages/instance.dart @@ -1,6 +1,8 @@ import 'package:flutter/material.dart'; import 'package:go_router/go_router.dart'; import '../constants/colors.dart'; +import '../services/instance_service.dart'; +import 'package:flutter_secure_storage/flutter_secure_storage.dart'; class InstancePage extends StatefulWidget { const InstancePage({super.key}); @@ -14,49 +16,60 @@ class _InstancePageState extends State { bool _sortAscending = true; int _sortColumnIndex = 0; - List> instances = [ - { - 'id': 'inst-1', - 'projectId': 'proj-1', - 'createdAt': DateTime.now().subtract(const Duration(hours: 2)), - 'status': 'Running', - 'memoryUsage': '124MB', - 'os': 'ubuntu-2410', - 'plugin': 'gef', - }, - { - 'id': 'inst-2', - 'projectId': 'proj-1', - 'createdAt': DateTime.now().subtract(const Duration(days: 1)), - 'status': 'Stopped', - 'memoryUsage': '256MB', - 'os': 'debian-12', - 'plugin': 'radare2', - }, - { - 'id': 'inst-3', - 'projectId': 'proj-2', - 'createdAt': DateTime.now().subtract(const Duration(minutes: 30)), - 'status': 'Pending', - 'memoryUsage': '512MB', - 'os': 'kali-2024', - 'plugin': 'ghidra', - }, - { - 'id': 'inst-4', - 'projectId': 'proj-1', - 'createdAt': DateTime.now().subtract(const Duration(days: 5)), - 'status': 'Running', - 'memoryUsage': '1GB', - 'os': 'ubuntu-2404', - 'plugin': 'binary ninja', - }, - ]; + List> instances = []; + + final _storage = const FlutterSecureStorage(); + late InstanceService _instanceService; + bool _isLoading = true; @override void initState() { super.initState(); - // TODO: Fetch projects and instances from backend + _initializeData(); + } + + Future _initializeData() async { + final token = await _storage.read(key: 'token'); + if (token == null) { + if (mounted) context.go('/login'); + return; + } + + _projectService = ProjectService(token: token); + + _instanceService = InstanceService(token: token); + + try { + final futures = await Future.wait([ + _projectService.getProjects(), + ]); + + if (mounted) { + setState(() { + projects = futures[0] as List; + _isLoading = false; + }); + } + } catch (e) { + if (mounted) context.go('/login'); + } + } + + Future _refreshInstances() async { + if (selectedProjectId == null) return; + + try { + final updatedInstances = await _instanceService.getInstances(selectedProjectId!); + setState(() { + instances = updatedInstances; + }); + } catch (e) { + if (mounted) { + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar(content: Text('Failed to fetch instances')), + ); + } + } } @override @@ -77,17 +90,15 @@ class _InstancePageState extends State { labelText: 'Select Project', border: OutlineInputBorder(), ), - items: const [ - DropdownMenuItem( - value: 'proj-1', - child: Text('Project 1'), - ), - // Add more projects - ], + items: projects.map((project) => DropdownMenuItem( + value: project.id, + child: Text(project.name), + )).toList(), onChanged: (value) { setState(() { selectedProjectId = value; }); + _refreshInstances(); }, ), ), @@ -234,9 +245,6 @@ class _InstancePageState extends State { case 'stopped': statusColor = Colors.red; break; - case 'pending': - statusColor = Colors.orange; - break; default: statusColor = Colors.grey; } @@ -290,8 +298,21 @@ class _InstancePageState extends State { borderRadius: BorderRadius.circular(4), ), ), - onPressed: () { - // TODO: Start/Restart instance + onPressed: () async { + try { + await _instanceService.startInstance(instance['id']); + // Refresh instances after starting + final updatedInstances = await _instanceService.getInstances(selectedProjectId!); + setState(() { + instances = updatedInstances; + }); + } catch (e) { + if (mounted) { + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar(content: Text('Failed to start instance')), + ); + } + } }, child: Text(isRunning ? 'Restart' : 'Start'), ), @@ -306,8 +327,21 @@ class _InstancePageState extends State { borderRadius: BorderRadius.circular(4), ), ), - onPressed: () { - // TODO: Stop instance + onPressed: () async { + try { + await _instanceService.stopInstance(instance['id']); + // Refresh instances after stopping + final updatedInstances = await _instanceService.getInstances(selectedProjectId!); + setState(() { + instances = updatedInstances; + }); + } catch (e) { + if (mounted) { + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar(content: Text('Failed to stop instance')), + ); + } + } }, child: const Text('Stop'), ), @@ -334,9 +368,22 @@ class _InstancePageState extends State { child: const Text('Cancel'), ), TextButton( - onPressed: () { - // TODO: Delete instance + onPressed: () async { Navigator.pop(context); + try { + await _instanceService.deleteInstance(instance['id']); + // Refresh instances after deletion + final updatedInstances = await _instanceService.getInstances(selectedProjectId!); + setState(() { + instances = updatedInstances; + }); + } catch (e) { + if (mounted) { + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar(content: Text('Failed to delete instance')), + ); + } + } }, style: TextButton.styleFrom(foregroundColor: Colors.red), child: const Text('Delete'), diff --git a/web/lib/pages/project.dart b/web/lib/pages/project.dart index c04918b..ad53cd8 100644 --- a/web/lib/pages/project.dart +++ b/web/lib/pages/project.dart @@ -8,6 +8,7 @@ import 'package:file_picker/file_picker.dart'; import '../services/project_service.dart'; import 'package:flutter_secure_storage/flutter_secure_storage.dart'; import 'package:go_router/go_router.dart'; +import '../services/instance_service.dart'; class ProjectPage extends StatefulWidget { const ProjectPage({super.key}); @@ -25,6 +26,7 @@ class _ProjectPageState extends State { final _storage = const FlutterSecureStorage(); late ProjectService _projectService; + late InstanceService _instanceService; List projects = []; List osList = []; List pluginList = []; @@ -44,6 +46,7 @@ class _ProjectPageState extends State { } _projectService = ProjectService(token: token); + _instanceService = InstanceService(token: token); try { final futures = await Future.wait([ @@ -335,8 +338,19 @@ class _ProjectPageState extends State { borderRadius: BorderRadius.circular(4), ), ), - onPressed: () { - // TODO: Create new session + onPressed: () async { + try { + final instance = await _instanceService.createInstance(project.id); + if (mounted) { + context.go('/instances'); + } + } catch (e) { + if (mounted) { + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar(content: Text('Failed to create instance')), + ); + } + } }, child: const Text('New Instance'), ), diff --git a/web/lib/services/instance_service.dart b/web/lib/services/instance_service.dart index c889536..ac3f047 100644 --- a/web/lib/services/instance_service.dart +++ b/web/lib/services/instance_service.dart @@ -59,4 +59,32 @@ class InstanceService { throw Exception('Failed to delete instance'); } } + + Future startInstance(String instanceId) async { + final response = await http.get( + Uri.parse('/api/instance/$instanceId?action=start'), + headers: { + 'Authorization': 'Bearer $token', + }, + ); + if (response.statusCode == 200) { + return; + } else { + throw Exception('Failed to start instance'); + } + } + + Future stopInstance(String instanceId) async { + final response = await http.get( + Uri.parse('/api/instance/$instanceId?action=stop'), + headers: { + 'Authorization': 'Bearer $token', + }, + ); + if (response.statusCode == 200) { + return; + } else { + throw Exception('Failed to stop instance'); + } + } } \ No newline at end of file From 8fc5c3ed8c34678f89d2a402a71bc278c08d99b8 Mon Sep 17 00:00:00 2001 From: KIbeom Lee Date: Mon, 13 Jan 2025 02:29:58 +0900 Subject: [PATCH 06/12] fix flutter build --- web/lib/pages/instance.dart | 53 +++++++++----------------- web/lib/services/instance_service.dart | 11 ++++++ web/pubspec.lock | 30 +++++++-------- 3 files changed, 44 insertions(+), 50 deletions(-) diff --git a/web/lib/pages/instance.dart b/web/lib/pages/instance.dart index ce9bc4f..0bd1414 100644 --- a/web/lib/pages/instance.dart +++ b/web/lib/pages/instance.dart @@ -2,6 +2,7 @@ import 'package:flutter/material.dart'; import 'package:go_router/go_router.dart'; import '../constants/colors.dart'; import '../services/instance_service.dart'; +import '../services/project_service.dart'; import 'package:flutter_secure_storage/flutter_secure_storage.dart'; class InstancePage extends StatefulWidget { @@ -16,10 +17,12 @@ class _InstancePageState extends State { bool _sortAscending = true; int _sortColumnIndex = 0; - List> instances = []; + List instances = []; + List projects = []; final _storage = const FlutterSecureStorage(); late InstanceService _instanceService; + late ProjectService _projectService; bool _isLoading = true; @override @@ -36,7 +39,6 @@ class _InstancePageState extends State { } _projectService = ProjectService(token: token); - _instanceService = InstanceService(token: token); try { @@ -138,8 +140,8 @@ class _InstancePageState extends State { _sortColumnIndex = columnIndex; _sortAscending = ascending; instances.sort((a, b) { - final DateTime aDate = a['createdAt'] as DateTime; - final DateTime bDate = b['createdAt'] as DateTime; + final DateTime aDate = DateTime.parse(a.createdAt); + final DateTime bDate = DateTime.parse(b.createdAt); return ascending ? aDate.compareTo(bDate) : bDate.compareTo(aDate); @@ -160,8 +162,8 @@ class _InstancePageState extends State { _sortColumnIndex = columnIndex; _sortAscending = ascending; instances.sort((a, b) { - final String aStatus = a['status'] as String; - final String bStatus = b['status'] as String; + final String aStatus = a.status; + final String bStatus = b.status; return ascending ? aStatus.compareTo(bStatus) : bStatus.compareTo(aStatus); @@ -175,18 +177,6 @@ class _InstancePageState extends State { style: TextStyle(fontWeight: FontWeight.bold), ), ), - const DataColumn( - label: Text( - 'OS', - style: TextStyle(fontWeight: FontWeight.bold), - ), - ), - const DataColumn( - label: Text( - 'Plugin', - style: TextStyle(fontWeight: FontWeight.bold), - ), - ), const DataColumn( label: Text( 'Actions', @@ -194,19 +184,12 @@ class _InstancePageState extends State { ), ), ], - rows: instances - .where((instance) => - selectedProjectId == null || - instance['projectId'] == selectedProjectId) - .map((instance) { + rows: instances.map((instance) { return DataRow( cells: [ - DataCell(Text(_formatDateTime( - instance['createdAt'] as DateTime))), - DataCell(_buildStatusCell(instance['status'])), - DataCell(Text(instance['memoryUsage'])), - DataCell(Text(instance['os'])), - DataCell(Text(instance['plugin'])), + DataCell(Text(_formatDateTime(DateTime.parse(instance.createdAt)))), + DataCell(_buildStatusCell(instance.status)), + DataCell(Text('${instance.memory} MB')), DataCell(_buildActionButtons(instance)), ], ); @@ -266,8 +249,8 @@ class _InstancePageState extends State { ); } - Widget _buildActionButtons(Map instance) { - final bool isRunning = instance['status'].toString().toLowerCase() == 'running'; + Widget _buildActionButtons(Instance instance) { + final bool isRunning = instance.status.toString().toLowerCase() == 'running'; return Row( mainAxisSize: MainAxisSize.min, @@ -283,7 +266,7 @@ class _InstancePageState extends State { ), ), onPressed: () { - context.go('/session/${instance['id']}'); + context.go('/session/${instance.id}'); }, child: const Text('Open'), ), @@ -300,7 +283,7 @@ class _InstancePageState extends State { ), onPressed: () async { try { - await _instanceService.startInstance(instance['id']); + await _instanceService.startInstance(instance.id); // Refresh instances after starting final updatedInstances = await _instanceService.getInstances(selectedProjectId!); setState(() { @@ -329,7 +312,7 @@ class _InstancePageState extends State { ), onPressed: () async { try { - await _instanceService.stopInstance(instance['id']); + await _instanceService.stopInstance(instance.id); // Refresh instances after stopping final updatedInstances = await _instanceService.getInstances(selectedProjectId!); setState(() { @@ -371,7 +354,7 @@ class _InstancePageState extends State { onPressed: () async { Navigator.pop(context); try { - await _instanceService.deleteInstance(instance['id']); + await _instanceService.deleteInstance(instance.id); // Refresh instances after deletion final updatedInstances = await _instanceService.getInstances(selectedProjectId!); setState(() { diff --git a/web/lib/services/instance_service.dart b/web/lib/services/instance_service.dart index ac3f047..0315d66 100644 --- a/web/lib/services/instance_service.dart +++ b/web/lib/services/instance_service.dart @@ -1,4 +1,5 @@ import 'package:http/http.dart' as http; +import 'dart:convert'; class Instance { final String id; @@ -8,6 +9,16 @@ class Instance { final String updatedAt; Instance({required this.id, required this.status, required this.memory, required this.createdAt, required this.updatedAt}); + + factory Instance.fromJson(Map json) { + return Instance( + id: json['id'], + status: json['status'], + memory: json['memory'], + createdAt: json['created_at'], + updatedAt: json['updated_at'], + ); + } } class InstanceService { diff --git a/web/pubspec.lock b/web/pubspec.lock index b4392cf..fe0e2d0 100644 --- a/web/pubspec.lock +++ b/web/pubspec.lock @@ -37,10 +37,10 @@ packages: dependency: transitive description: name: collection - sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a + sha256: a1ace0a119f20aabc852d165077c036cd864315bd99b7eaa10a60100341941bf url: "https://pub.dev" source: hosted - version: "1.18.0" + version: "1.19.0" convert: dependency: transitive description: @@ -228,18 +228,18 @@ packages: dependency: transitive description: name: leak_tracker - sha256: "3f87a60e8c63aecc975dda1ceedbc8f24de75f09e4856ea27daf8958f2f0ce05" + sha256: "7bb2830ebd849694d1ec25bf1f44582d6ac531a57a365a803a6034ff751d2d06" url: "https://pub.dev" source: hosted - version: "10.0.5" + version: "10.0.7" leak_tracker_flutter_testing: dependency: transitive description: name: leak_tracker_flutter_testing - sha256: "932549fb305594d82d7183ecd9fa93463e9914e1b67cacc34bc40906594a1806" + sha256: "9491a714cca3667b60b5c420da8217e6de0d1ba7a5ec322fab01758f6998f379" url: "https://pub.dev" source: hosted - version: "3.0.5" + version: "3.0.8" leak_tracker_testing: dependency: transitive description: @@ -372,7 +372,7 @@ packages: dependency: transitive description: flutter source: sdk - version: "0.0.99" + version: "0.0.0" source_span: dependency: transitive description: @@ -385,10 +385,10 @@ packages: dependency: transitive description: name: stack_trace - sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b" + sha256: "9f47fd3630d76be3ab26f0ee06d213679aa425996925ff3feffdec504931c377" url: "https://pub.dev" source: hosted - version: "1.11.1" + version: "1.12.0" stream_channel: dependency: transitive description: @@ -401,10 +401,10 @@ packages: dependency: transitive description: name: string_scanner - sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" + sha256: "688af5ed3402a4bde5b3a6c15fd768dbf2621a614950b17f04626c431ab3c4c3" url: "https://pub.dev" source: hosted - version: "1.2.0" + version: "1.3.0" term_glyph: dependency: transitive description: @@ -417,10 +417,10 @@ packages: dependency: transitive description: name: test_api - sha256: "5b8a98dafc4d5c4c9c72d8b31ab2b23fc13422348d2997120294d3bac86b4ddb" + sha256: "664d3a9a64782fcdeb83ce9c6b39e78fd2971d4e37827b9b06c3aa1edc5e760c" url: "https://pub.dev" source: hosted - version: "0.7.2" + version: "0.7.3" typed_data: dependency: transitive description: @@ -441,10 +441,10 @@ packages: dependency: transitive description: name: vm_service - sha256: "5c5f338a667b4c644744b661f309fb8080bb94b18a7e91ef1dbd343bed00ed6d" + sha256: f6be3ed8bd01289b34d679c2b62226f63c0e69f9fd2e50a6b3c1c729a961041b url: "https://pub.dev" source: hosted - version: "14.2.5" + version: "14.3.0" web: dependency: transitive description: From 441830fec5b2e781707fc8a51ab9188a26f99e04 Mon Sep 17 00:00:00 2001 From: iiiusi0n Date: Mon, 13 Jan 2025 03:50:16 +0900 Subject: [PATCH 07/12] fix jwt auth in session --- docker-compose.yml | 1 + internal/api/stream/auth.go | 18 +++++++++++++++++- internal/api/stream/router.go | 2 -- internal/pkg/instance/instance.go | 25 +++++++++++++++++++++++-- web/lib/pages/instance.dart | 9 +++++---- web/lib/pages/project.dart | 4 ++-- web/lib/router.dart | 4 +++- web/lib/services/instance_service.dart | 2 +- web/lib/services/terminal_service.dart | 10 +++++++++- 9 files changed, 61 insertions(+), 14 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index b80980b..6dfb4b3 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -26,6 +26,7 @@ services: - DATABASE_URL=${DATABASE_URL} volumes: - easypwn_data:/var/lib/easypwn + - /var/run/docker.sock:/var/run/docker.sock depends_on: - chatbot - mailer diff --git a/internal/api/stream/auth.go b/internal/api/stream/auth.go index 37b415c..0e15f9e 100644 --- a/internal/api/stream/auth.go +++ b/internal/api/stream/auth.go @@ -6,6 +6,8 @@ import ( "fmt" "net/http" + authjwt "easypwn/internal/pkg/auth" + "github.com/gin-gonic/gin" ) @@ -37,7 +39,21 @@ func InstanceAuthMiddleware(projectClient pb.ProjectClient, instanceClient pb.In return } - if projectInfo.UserId != c.MustGet("user_id").(string) { + token := c.Query("token") + if token != "" { + c.JSON(http.StatusUnauthorized, gin.H{"error": "Unauthorized"}) + c.Abort() + return + } + + user, err := authjwt.Decode(token) + if err != nil { + c.JSON(http.StatusUnauthorized, gin.H{"error": "Unauthorized"}) + c.Abort() + return + } + + if user.UserID != projectInfo.UserId { c.JSON(http.StatusUnauthorized, gin.H{"error": "Unauthorized"}) c.Abort() return diff --git a/internal/api/stream/router.go b/internal/api/stream/router.go index 5e1f6b6..b43e8e0 100644 --- a/internal/api/stream/router.go +++ b/internal/api/stream/router.go @@ -4,7 +4,6 @@ import ( "github.com/gin-gonic/gin" pb "easypwn/internal/api" - authjwt "easypwn/internal/pkg/auth" ) type RouterClients struct { @@ -14,7 +13,6 @@ type RouterClients struct { func NewRouter(clients RouterClients) *gin.Engine { r := gin.Default() - r.Use(authjwt.AuthMiddleware()) r.Use(InstanceAuthMiddleware(clients.ProjectClient, clients.InstanceClient)) stream := r.Group("/stream") diff --git a/internal/pkg/instance/instance.go b/internal/pkg/instance/instance.go index deaa991..5c70c2b 100644 --- a/internal/pkg/instance/instance.go +++ b/internal/pkg/instance/instance.go @@ -15,6 +15,11 @@ type Instance struct { ContainerID string CreatedAt time.Time UpdatedAt time.Time + + Status string + MemoryUsage int + LastStatusUpdatedAt time.Time + LastMemoryUpdatedAt time.Time } func NewInstance(ctx context.Context, db *sql.DB, projectID string) (*Instance, error) { @@ -175,11 +180,27 @@ func (i *Instance) ResizeTTY(ctx context.Context, execID string, height, width u } func (i *Instance) GetMemoryUsage(ctx context.Context) (int, error) { - return getContainerMemory(ctx, cli, i.ContainerID) + if i.LastMemoryUpdatedAt.Add(1 * time.Minute).Before(time.Now()) { + memory, err := getContainerMemory(ctx, cli, i.ContainerID) + if err != nil { + return 0, err + } + i.MemoryUsage = memory + i.LastMemoryUpdatedAt = time.Now() + } + return i.MemoryUsage, nil } func (i *Instance) GetStatus(ctx context.Context) (string, error) { - return getContainerStatus(ctx, cli, i.ContainerID) + if i.LastStatusUpdatedAt.Add(1 * time.Minute).Before(time.Now()) { + status, err := getContainerStatus(ctx, cli, i.ContainerID) + if err != nil { + return "", err + } + i.Status = status + i.LastStatusUpdatedAt = time.Now() + } + return i.Status, nil } func (i *Instance) Start(ctx context.Context) error { diff --git a/web/lib/pages/instance.dart b/web/lib/pages/instance.dart index 0bd1414..1470d69 100644 --- a/web/lib/pages/instance.dart +++ b/web/lib/pages/instance.dart @@ -6,7 +6,8 @@ import '../services/project_service.dart'; import 'package:flutter_secure_storage/flutter_secure_storage.dart'; class InstancePage extends StatefulWidget { - const InstancePage({super.key}); + final String? initialProjectId; + const InstancePage({super.key, this.initialProjectId}); @override State createState() => _InstancePageState(); @@ -23,11 +24,11 @@ class _InstancePageState extends State { final _storage = const FlutterSecureStorage(); late InstanceService _instanceService; late ProjectService _projectService; - bool _isLoading = true; @override void initState() { super.initState(); + selectedProjectId = widget.initialProjectId; _initializeData(); } @@ -48,9 +49,9 @@ class _InstancePageState extends State { if (mounted) { setState(() { - projects = futures[0] as List; - _isLoading = false; + projects = futures[0]; }); + _refreshInstances(); } } catch (e) { if (mounted) context.go('/login'); diff --git a/web/lib/pages/project.dart b/web/lib/pages/project.dart index ad53cd8..7c078fe 100644 --- a/web/lib/pages/project.dart +++ b/web/lib/pages/project.dart @@ -340,9 +340,9 @@ class _ProjectPageState extends State { ), onPressed: () async { try { - final instance = await _instanceService.createInstance(project.id); + final _ = await _instanceService.createInstance(project.id); if (mounted) { - context.go('/instances'); + context.go('/instances', extra: project.id); } } catch (e) { if (mounted) { diff --git a/web/lib/router.dart b/web/lib/router.dart index 5ae5e4d..261c6fe 100644 --- a/web/lib/router.dart +++ b/web/lib/router.dart @@ -56,7 +56,9 @@ final router = GoRouter( ), GoRoute( path: '/instances', - builder: (context, state) => const InstancePage(), + builder: (context, state) => InstancePage( + initialProjectId: state.extra as String?, + ), ), GoRoute( path: '/session/:id', diff --git a/web/lib/services/instance_service.dart b/web/lib/services/instance_service.dart index 0315d66..557c5f1 100644 --- a/web/lib/services/instance_service.dart +++ b/web/lib/services/instance_service.dart @@ -12,7 +12,7 @@ class Instance { factory Instance.fromJson(Map json) { return Instance( - id: json['id'], + id: json['instance_id'], status: json['status'], memory: json['memory'], createdAt: json['created_at'], diff --git a/web/lib/services/terminal_service.dart b/web/lib/services/terminal_service.dart index d1ac8c0..92bb48c 100644 --- a/web/lib/services/terminal_service.dart +++ b/web/lib/services/terminal_service.dart @@ -6,6 +6,7 @@ class TerminalService { Function(dynamic)? onData; bool isConnected = false; String? lastUrl; + String? token; final StreamController _connectionStatusController = StreamController.broadcast(); Stream get connectionStatus => _connectionStatusController.stream; @@ -13,7 +14,14 @@ class TerminalService { void connect(String url) { lastUrl = url; try { - channel = WebSocketChannel.connect(Uri.parse(url)); + final Uri uri = Uri.parse(url); + final Map queryParams = Map.from(uri.queryParameters); + if (token != null) { + queryParams['token'] = token!; + } + final authenticatedUri = uri.replace(queryParameters: queryParams); + + channel = WebSocketChannel.connect(authenticatedUri); isConnected = true; _connectionStatusController.add(true); From 5a9e5ca625fccfcb65d8beb5561f4896e6d5495e Mon Sep 17 00:00:00 2001 From: iiiusi0n Date: Mon, 13 Jan 2025 16:30:36 +0900 Subject: [PATCH 08/12] fix tons of small mistakes --- internal/api/stream/auth.go | 2 +- internal/pkg/instance/instance.go | 7 +- web/lib/pages/session.dart | 215 +++++++++++++++++++++---- web/lib/services/terminal_service.dart | 9 +- 4 files changed, 199 insertions(+), 34 deletions(-) diff --git a/internal/api/stream/auth.go b/internal/api/stream/auth.go index 0e15f9e..2901a63 100644 --- a/internal/api/stream/auth.go +++ b/internal/api/stream/auth.go @@ -40,7 +40,7 @@ func InstanceAuthMiddleware(projectClient pb.ProjectClient, instanceClient pb.In } token := c.Query("token") - if token != "" { + if token == "" { c.JSON(http.StatusUnauthorized, gin.H{"error": "Unauthorized"}) c.Abort() return diff --git a/internal/pkg/instance/instance.go b/internal/pkg/instance/instance.go index 5c70c2b..80bcf74 100644 --- a/internal/pkg/instance/instance.go +++ b/internal/pkg/instance/instance.go @@ -41,7 +41,7 @@ func NewInstance(ctx context.Context, db *sql.DB, projectID string) (*Instance, imageName := fmt.Sprintf("easypwn/%s:%s", osName, pluginName) containerName := util.CreateInstanceName() - containerID, err := createContainer(ctx, cli, containerName, imageName, proj.FilePath, true) + containerID, err := createContainer(ctx, cli, containerName, imageName, proj.FilePath, false) if err != nil { return nil, err } @@ -143,6 +143,11 @@ func (i *Instance) Delete(ctx context.Context, db *sql.DB) error { return err } + err = removeContainer(ctx, cli, i.ContainerID) + if err != nil { + return err + } + tx, err := db.Begin() if err != nil { return err diff --git a/web/lib/pages/session.dart b/web/lib/pages/session.dart index 4c544e7..c053403 100644 --- a/web/lib/pages/session.dart +++ b/web/lib/pages/session.dart @@ -11,6 +11,7 @@ import 'dart:convert'; import 'package:google_fonts/google_fonts.dart'; import 'package:go_router/go_router.dart'; import 'dart:async'; +import 'package:flutter_secure_storage/flutter_secure_storage.dart'; class SessionPage extends StatefulWidget { final String id; @@ -21,8 +22,10 @@ class SessionPage extends StatefulWidget { } class _SessionPageState extends State with SingleTickerProviderStateMixin { + final FlutterSecureStorage _storage = FlutterSecureStorage(); bool isChatExpanded = true; - bool isConnected = true; + bool isDebugConnected = true; + bool isShellConnected = true; final TextEditingController _terminalController = TextEditingController(); final TextEditingController _chatController = TextEditingController(); final ScrollController _terminalScrollController = ScrollController(); @@ -32,15 +35,19 @@ class _SessionPageState extends State with SingleTickerProviderStat final List chatMessages = []; final FocusNode _chatFocusNode = FocusNode(); - late Terminal terminal; - late TerminalController terminalController; - final TerminalService terminalService = TerminalService(); + late Terminal debugTerminal; + late TerminalController debugTerminalController; + late Terminal shellTerminal; + late TerminalController shellTerminalController; + final TerminalService debugTerminalService = TerminalService(); + final TerminalService shellTerminalService = TerminalService(); final double minChatWidth = 300; final double maxChatWidth = 750; double chatWidth = 450; - late StreamSubscription _connectionSubscription; + late StreamSubscription _debugConnectionSubscription; + late StreamSubscription _shellConnectionSubscription; @override void initState() { @@ -57,56 +64,92 @@ class _SessionPageState extends State with SingleTickerProviderStat ); _initializeTerminal(); - _connectionSubscription = terminalService.connectionStatus.listen((status) { + _debugConnectionSubscription = debugTerminalService.connectionStatus.listen((status) { if (mounted) { setState(() { - isConnected = status; + isDebugConnected = status; + }); + } + }); + + _shellConnectionSubscription = shellTerminalService.connectionStatus.listen((status) { + if (mounted) { + setState(() { + isShellConnected = status; }); } }); } - void _initializeTerminal() { - terminal = Terminal( + Future _initializeTerminal() async { + final token = await _storage.read(key: 'token'); + debugTerminal = Terminal( + maxLines: 10000, + ); + shellTerminal = Terminal( maxLines: 10000, ); - terminalController = TerminalController(); + debugTerminalController = TerminalController(); + shellTerminalController = TerminalController(); - terminalService.connect('${Uri.base.scheme == 'https' ? 'wss' : 'ws'}://${Uri.base.host}:${Uri.base.port}/ws'); + debugTerminalService.connect('${Uri.base.scheme == 'https' ? 'wss' : 'ws'}://${Uri.base.host}:${Uri.base.port}/api/stream/session/debugger/${widget.id}', token!); + shellTerminalService.connect('${Uri.base.scheme == 'https' ? 'wss' : 'ws'}://${Uri.base.host}:${Uri.base.port}/api/stream/session/shell/${widget.id}', token); - terminalService.onData = (data) { + debugTerminalService.onData = (data) { if (data is List) { - terminal.write(const Utf8Decoder().convert(data)); + debugTerminal.write(const Utf8Decoder().convert(data)); } }; - terminal.onOutput = (data) { + shellTerminalService.onData = (data) { + if (data is List) { + shellTerminal.write(const Utf8Decoder().convert(data)); + } + }; + + debugTerminal.onOutput = (data) { + final encodedData = const Utf8Encoder().convert(data); + debugTerminalService.sendCommand(encodedData); + }; + + shellTerminal.onOutput = (data) { final encodedData = const Utf8Encoder().convert(data); - terminalService.sendCommand(encodedData); + shellTerminalService.sendCommand(encodedData); }; // Handle terminal resize - terminal.onResize = (w, h, pw, ph) { + debugTerminal.onResize = (w, h, pw, ph) { final resizeCommand = jsonEncode({ 'type': 'resize', 'cols': w, 'rows': h }); - terminalService.sendCommand(resizeCommand); + debugTerminalService.sendCommand(resizeCommand); + }; + + shellTerminal.onResize = (w, h, pw, ph) { + final resizeCommand = jsonEncode({ + 'type': 'resize', + 'cols': w, + 'rows': h + }); + shellTerminalService.sendCommand(resizeCommand); }; } @override void dispose() { - _connectionSubscription.cancel(); + _debugConnectionSubscription.cancel(); + _shellConnectionSubscription.cancel(); _terminalController.dispose(); _chatController.dispose(); _terminalScrollController.dispose(); _chatScrollController.dispose(); _tabController.dispose(); _chatFocusNode.dispose(); - terminalService.dispose(); + debugTerminalService.dispose(); + shellTerminalService.dispose(); super.dispose(); } @@ -296,8 +339,126 @@ class _SessionPageState extends State with SingleTickerProviderStat Container( color: AppColors.surfaceDark, child: TerminalView( - terminal, - controller: terminalController, + debugTerminal, + controller: debugTerminalController, + autofocus: true, + backgroundOpacity: 0.7, + textStyle: TerminalStyle( + fontSize: 14, + fontFamily: GoogleFonts.robotoMono().fontFamily!, + ), + onSecondaryTapDown: (details, offset) async { + final selection = debugTerminalController.selection; + if (selection != null) { + final text = debugTerminal.buffer.getText(selection); + debugTerminalController.clearSelection(); + await Clipboard.setData(ClipboardData(text: text)); + } else { + final data = await Clipboard.getData('text/plain'); + final text = data?.text; + if (text != null) { + debugTerminal.paste(text); + } + } + }, + ), + ), + + if (!isDebugConnected) + Container( + color: const Color(0xFF2C1F1F).withOpacity(0.7), + child: Center( + child: Container( + padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 16), + decoration: BoxDecoration( + color: const Color(0xFF1E1E1E).withOpacity(0.95), + borderRadius: BorderRadius.circular(8), + border: Border.all( + color: const Color(0xFF433333), + width: 1, + ), + boxShadow: [ + BoxShadow( + color: Colors.black.withOpacity(0.2), + blurRadius: 12, + offset: const Offset(0, 4), + ), + ], + ), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Row( + mainAxisSize: MainAxisSize.min, + children: [ + Container( + width: 8, + height: 8, + decoration: BoxDecoration( + color: Colors.red.shade400, + borderRadius: BorderRadius.circular(4), + ), + ), + const SizedBox(width: 8), + const Text( + 'Connection lost', + style: TextStyle( + color: Colors.white70, + fontSize: 14, + fontWeight: FontWeight.w500, + ), + ), + ], + ), + const SizedBox(height: 12), + CustomButton( + text: 'Reconnect', + width: 100, + height: 30, + onPressed: () { + debugTerminalService.reconnect(); + }, + backgroundColor: const Color.fromARGB(255, 196, 73, 73), + borderColor: const Color.fromARGB(255, 196, 73, 73), + textColor: Colors.white70, + ), + ], + ), + ), + ), + ), + + Positioned( + right: 16, + bottom: 16, + child: Container( + decoration: BoxDecoration( + shape: BoxShape.circle, + color: AppColors.surface, + border: Border.all(color: AppColors.border), + ), + child: IconButton( + icon: const Icon(Icons.logout), + iconSize: 20, + color: AppColors.textSecondary, + onPressed: () { + context.go('/instances'); + }, + ), + ), + ), + ], + ); + } + + Widget _buildShellTab() { + return Stack( + children: [ + Container( + color: AppColors.surfaceDark, + child: TerminalView( + shellTerminal, + controller: shellTerminalController, autofocus: true, backgroundOpacity: 0.7, textStyle: TerminalStyle( @@ -305,23 +466,23 @@ class _SessionPageState extends State with SingleTickerProviderStat fontFamily: GoogleFonts.robotoMono().fontFamily!, ), onSecondaryTapDown: (details, offset) async { - final selection = terminalController.selection; + final selection = shellTerminalController.selection; if (selection != null) { - final text = terminal.buffer.getText(selection); - terminalController.clearSelection(); + final text = shellTerminal.buffer.getText(selection); + shellTerminalController.clearSelection(); await Clipboard.setData(ClipboardData(text: text)); } else { final data = await Clipboard.getData('text/plain'); final text = data?.text; if (text != null) { - terminal.paste(text); + shellTerminal.paste(text); } } }, ), ), - if (!isConnected) + if (!isShellConnected) Container( color: const Color(0xFF2C1F1F).withOpacity(0.7), child: Center( @@ -373,7 +534,7 @@ class _SessionPageState extends State with SingleTickerProviderStat width: 100, height: 30, onPressed: () { - terminalService.reconnect(); + shellTerminalService.reconnect(); }, backgroundColor: const Color.fromARGB(255, 196, 73, 73), borderColor: const Color.fromARGB(255, 196, 73, 73), diff --git a/web/lib/services/terminal_service.dart b/web/lib/services/terminal_service.dart index 92bb48c..860e77e 100644 --- a/web/lib/services/terminal_service.dart +++ b/web/lib/services/terminal_service.dart @@ -11,14 +11,13 @@ class TerminalService { Stream get connectionStatus => _connectionStatusController.stream; - void connect(String url) { + void connect(String url, String token) { lastUrl = url; + this.token = token; try { final Uri uri = Uri.parse(url); final Map queryParams = Map.from(uri.queryParameters); - if (token != null) { - queryParams['token'] = token!; - } + queryParams['token'] = token; final authenticatedUri = uri.replace(queryParameters: queryParams); channel = WebSocketChannel.connect(authenticatedUri); @@ -48,7 +47,7 @@ class TerminalService { void reconnect() { if (lastUrl != null) { - connect(lastUrl!); + connect(lastUrl!, token!); } } From 73529c88a89cdca57743de425970b60f2b4d46cb Mon Sep 17 00:00:00 2001 From: iiiusi0n Date: Mon, 13 Jan 2025 17:05:30 +0900 Subject: [PATCH 09/12] implant api calls to session --- internal/api/stream/handler.go | 3 ++- internal/service/project.go | 2 ++ web/lib/pages/session.dart | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/internal/api/stream/handler.go b/internal/api/stream/handler.go index 1ebbade..679a81e 100644 --- a/internal/api/stream/handler.go +++ b/internal/api/stream/handler.go @@ -117,7 +117,8 @@ func GetDebuggerSessionHandler() gin.HandlerFunc { c.JSON(http.StatusInternalServerError, gin.H{"error": "Failed to get instance"}) return } - handleWebSocketSession(c, ins, true, "gdb", c.MustGet("full_path").(string)) + fullPath := c.MustGet("full_path").(string) + handleWebSocketSession(c, ins, true, "gdb", fullPath) } } diff --git a/internal/service/project.go b/internal/service/project.go index e1ae9e8..0d0f56b 100644 --- a/internal/service/project.go +++ b/internal/service/project.go @@ -41,8 +41,10 @@ func (s *ProjectService) GetProject(ctx context.Context, req *pb.GetProjectReque Name: project.Name, UserId: project.UserID, FilePath: project.FilePath, + FileName: project.FileName, OsId: project.OsID, PluginId: project.PluginID, + CreatedAt: project.CreatedAt.Format(time.RFC3339), }, nil } diff --git a/web/lib/pages/session.dart b/web/lib/pages/session.dart index c053403..5dc38dd 100644 --- a/web/lib/pages/session.dart +++ b/web/lib/pages/session.dart @@ -213,7 +213,7 @@ class _SessionPageState extends State with SingleTickerProviderStat controller: _tabController, children: [ _buildDebuggerTab(), - _buildDebuggerTab(), + _buildShellTab(), ], ), ), From 2a0ece8b1fd02254b483af25037ecb81ba3e66b3 Mon Sep 17 00:00:00 2001 From: iiiusi0n Date: Mon, 13 Jan 2025 18:42:15 +0900 Subject: [PATCH 10/12] fix session api calls --- assets/mysql/initdb.sql | 4 +-- internal/api/gateway/instance.go | 35 +++++++++++++++++++++++++- internal/pkg/instance/docker.go | 2 +- internal/pkg/instance/instance.go | 1 + web/lib/components/bottom_bar.dart | 6 ++--- web/lib/pages/session.dart | 29 +++++++++++++++------ web/lib/services/instance_service.dart | 15 +++++++++++ 7 files changed, 78 insertions(+), 14 deletions(-) diff --git a/assets/mysql/initdb.sql b/assets/mysql/initdb.sql index ffa3c49..1dc3fe0 100644 --- a/assets/mysql/initdb.sql +++ b/assets/mysql/initdb.sql @@ -57,7 +57,7 @@ CREATE TABLE IF NOT EXISTS project ( CREATE TABLE IF NOT EXISTS instance ( id BINARY(16) PRIMARY KEY NOT NULL UNIQUE, - project_id BINARY(16) NOT NULL REFERENCES project(id), + project_id BINARY(16) NOT NULL REFERENCES project(id) ON DELETE CASCADE, container_id VARCHAR(64) NOT NULL, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP @@ -65,7 +65,7 @@ CREATE TABLE IF NOT EXISTS instance ( CREATE TABLE IF NOT EXISTS instance_log ( id BINARY(16) PRIMARY KEY NOT NULL UNIQUE, - instance_id BINARY(16) NOT NULL REFERENCES instance(id), + instance_id BINARY(16) NOT NULL REFERENCES instance(id) ON DELETE CASCADE, log TEXT NOT NULL, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP diff --git a/internal/api/gateway/instance.go b/internal/api/gateway/instance.go index 0f5bec2..1570879 100644 --- a/internal/api/gateway/instance.go +++ b/internal/api/gateway/instance.go @@ -127,6 +127,14 @@ func DeleteInstanceHandler(instanceClient pb.InstanceClient) gin.HandlerFunc { func ActionInstanceHandler(instanceClient pb.InstanceClient) gin.HandlerFunc { ctx := context.Background() + type InstanceResponse struct { + InstanceId string `json:"instance_id"` + Status string `json:"status"` + Memory int `json:"memory"` + CreatedAt string `json:"created_at"` + UpdatedAt string `json:"updated_at"` + } + return func(c *gin.Context) { instanceId := c.Param("id") if instanceId == "" { @@ -136,7 +144,32 @@ func ActionInstanceHandler(instanceClient pb.InstanceClient) gin.HandlerFunc { action := c.Query("action") if action == "" { - c.JSON(http.StatusBadRequest, gin.H{"error": "Action is required"}) + ins, err := instance.GetInstance(ctx, data.GetDB(), instanceId) + if err != nil { + log.Printf("Failed to get instance: %v", err) + c.JSON(http.StatusInternalServerError, gin.H{"error": "Failed to get instance"}) + return + } + + status, err := ins.GetStatus(ctx) + if err != nil { + log.Printf("Failed to get instance status: %v", err) + c.JSON(http.StatusInternalServerError, gin.H{"error": "Failed to get instance status"}) + return + } + memory, err := ins.GetMemoryUsage(ctx) + if err != nil { + log.Printf("Failed to get instance memory usage: %v", err) + c.JSON(http.StatusInternalServerError, gin.H{"error": "Failed to get instance memory usage"}) + return + } + c.JSON(http.StatusOK, InstanceResponse{ + InstanceId: ins.ID, + Status: status, + Memory: memory, + CreatedAt: ins.CreatedAt.Format(time.RFC3339), + UpdatedAt: ins.UpdatedAt.Format(time.RFC3339), + }) return } diff --git a/internal/pkg/instance/docker.go b/internal/pkg/instance/docker.go index 0c96a44..06db4dd 100644 --- a/internal/pkg/instance/docker.go +++ b/internal/pkg/instance/docker.go @@ -90,7 +90,7 @@ func createContainer(ctx context.Context, cli *client.Client, containerName, ima Tty: true, }, &container.HostConfig{ Binds: []string{ - fmt.Sprintf("%s:/work", workPath), + fmt.Sprintf("%s:/work:rw", workPath), }, AutoRemove: autoRemove, }, nil, nil, containerName) diff --git a/internal/pkg/instance/instance.go b/internal/pkg/instance/instance.go index 80bcf74..ef57824 100644 --- a/internal/pkg/instance/instance.go +++ b/internal/pkg/instance/instance.go @@ -41,6 +41,7 @@ func NewInstance(ctx context.Context, db *sql.DB, projectID string) (*Instance, imageName := fmt.Sprintf("easypwn/%s:%s", osName, pluginName) containerName := util.CreateInstanceName() + containerID, err := createContainer(ctx, cli, containerName, imageName, proj.FilePath, false) if err != nil { return nil, err diff --git a/web/lib/components/bottom_bar.dart b/web/lib/components/bottom_bar.dart index a9ef2d4..253b876 100644 --- a/web/lib/components/bottom_bar.dart +++ b/web/lib/components/bottom_bar.dart @@ -2,12 +2,12 @@ import 'package:flutter/material.dart'; import '../constants/colors.dart'; class BottomBar extends StatelessWidget { - final String instanceAddress; + final String instanceId; final String memoryUsage; const BottomBar({ super.key, - required this.instanceAddress, + required this.instanceId, required this.memoryUsage, }); @@ -25,7 +25,7 @@ class BottomBar extends StatelessWidget { child: Row( children: [ Text( - 'Connected to: $instanceAddress', + 'Connected to instance: $instanceId', style: TextStyle( color: AppColors.greyShade(600), fontSize: 12, diff --git a/web/lib/pages/session.dart b/web/lib/pages/session.dart index 5dc38dd..2d97d88 100644 --- a/web/lib/pages/session.dart +++ b/web/lib/pages/session.dart @@ -12,7 +12,7 @@ import 'package:google_fonts/google_fonts.dart'; import 'package:go_router/go_router.dart'; import 'dart:async'; import 'package:flutter_secure_storage/flutter_secure_storage.dart'; - +import '../services/instance_service.dart'; class SessionPage extends StatefulWidget { final String id; const SessionPage({super.key, required this.id}); @@ -22,7 +22,7 @@ class SessionPage extends StatefulWidget { } class _SessionPageState extends State with SingleTickerProviderStateMixin { - final FlutterSecureStorage _storage = FlutterSecureStorage(); + final FlutterSecureStorage _storage = const FlutterSecureStorage(); bool isChatExpanded = true; bool isDebugConnected = true; bool isShellConnected = true; @@ -41,7 +41,7 @@ class _SessionPageState extends State with SingleTickerProviderStat late TerminalController shellTerminalController; final TerminalService debugTerminalService = TerminalService(); final TerminalService shellTerminalService = TerminalService(); - + late InstanceService _instanceService; final double minChatWidth = 300; final double maxChatWidth = 750; double chatWidth = 450; @@ -49,6 +49,17 @@ class _SessionPageState extends State with SingleTickerProviderStat late StreamSubscription _debugConnectionSubscription; late StreamSubscription _shellConnectionSubscription; + String memoryUsage = '...'; + + Future _updateMemoryUsage() async { + final instance = await _instanceService.getInstance(widget.id); + if (mounted) { + setState(() { + memoryUsage = instance.memory.toString(); + }); + } + } + @override void initState() { super.initState(); @@ -79,6 +90,8 @@ class _SessionPageState extends State with SingleTickerProviderStat }); } }); + + _updateMemoryUsage(); } Future _initializeTerminal() async { @@ -93,7 +106,9 @@ class _SessionPageState extends State with SingleTickerProviderStat debugTerminalController = TerminalController(); shellTerminalController = TerminalController(); - debugTerminalService.connect('${Uri.base.scheme == 'https' ? 'wss' : 'ws'}://${Uri.base.host}:${Uri.base.port}/api/stream/session/debugger/${widget.id}', token!); + _instanceService = InstanceService(token: token!); + + debugTerminalService.connect('${Uri.base.scheme == 'https' ? 'wss' : 'ws'}://${Uri.base.host}:${Uri.base.port}/api/stream/session/debugger/${widget.id}', token); shellTerminalService.connect('${Uri.base.scheme == 'https' ? 'wss' : 'ws'}://${Uri.base.host}:${Uri.base.port}/api/stream/session/shell/${widget.id}', token); debugTerminalService.onData = (data) { @@ -324,9 +339,9 @@ class _SessionPageState extends State with SingleTickerProviderStat ), // Bottom bar - const BottomBar( - instanceAddress: 'localhost:8080', - memoryUsage: '124MB', + BottomBar( + instanceId: widget.id, + memoryUsage: "$memoryUsage MB", ), ], ), diff --git a/web/lib/services/instance_service.dart b/web/lib/services/instance_service.dart index 557c5f1..1c473d1 100644 --- a/web/lib/services/instance_service.dart +++ b/web/lib/services/instance_service.dart @@ -42,6 +42,21 @@ class InstanceService { } } + Future getInstance(String instanceId) async { + final response = await http.get( + Uri.parse('/api/instance/$instanceId'), + headers: { + 'Authorization': 'Bearer $token', + }, + ); + if (response.statusCode == 200) { + final data = jsonDecode(response.body); + return Instance.fromJson(data); + } else { + throw Exception('Failed to get instance'); + } + } + Future createInstance(String projectId) async { final response = await http.post( Uri.parse('/api/instance?project_id=$projectId'), From bda1c7fdbdbaa3f884aed22c6589e3f91afcb68b Mon Sep 17 00:00:00 2001 From: iiiusi0n Date: Mon, 13 Jan 2025 18:57:52 +0900 Subject: [PATCH 11/12] fix mount path --- .env | 1 + cmd/api-gateway/main.go | 6 ++++++ docker-compose.yml | 13 ++++++++----- internal/api/gateway/project.go | 3 +++ internal/api/gateway/router.go | 11 +++++++++++ 5 files changed, 29 insertions(+), 5 deletions(-) diff --git a/.env b/.env index c8e7705..3637c34 100644 --- a/.env +++ b/.env @@ -10,6 +10,7 @@ CHATBOT_LISTEN_HOST= CHATBOT_LISTEN_PORT= DOCKER_HOST= +DOCKER_HOST_MOUNT_PATH= INSTANCE_LISTEN_HOST= INSTANCE_LISTEN_PORT= INSTANCE_STREAMING_SERVICE_LISTEN_HOST= diff --git a/cmd/api-gateway/main.go b/cmd/api-gateway/main.go index 836438a..cfb26e8 100644 --- a/cmd/api-gateway/main.go +++ b/cmd/api-gateway/main.go @@ -28,6 +28,8 @@ var ( chatbotListenHost = os.Getenv("CHATBOT_LISTEN_HOST") chatbotListenPort = os.Getenv("CHATBOT_LISTEN_PORT") + + dockerHostMountPath = os.Getenv("DOCKER_HOST_MOUNT_PATH") ) func init() { @@ -54,6 +56,10 @@ func init() { if chatbotListenHost == "" || chatbotListenPort == "" { log.Fatalf("CHATBOT_LISTEN_HOST and CHATBOT_LISTEN_PORT must be set") } + + if dockerHostMountPath == "" { + log.Fatalf("DOCKER_HOST_MOUNT_PATH must be set") + } } func main() { diff --git a/docker-compose.yml b/docker-compose.yml index 6dfb4b3..f0c94b5 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -24,8 +24,9 @@ services: - CHATBOT_LISTEN_PORT=${CHATBOT_LISTEN_PORT} - AUTH_JWT_SECRET=${AUTH_JWT_SECRET} - DATABASE_URL=${DATABASE_URL} + - DOCKER_HOST_MOUNT_PATH=${DOCKER_HOST_MOUNT_PATH} volumes: - - easypwn_data:/var/lib/easypwn + - /tmp/easypwn-data:/var/lib/easypwn - /var/run/docker.sock:/var/run/docker.sock depends_on: - chatbot @@ -94,9 +95,10 @@ services: - PROJECT_LISTEN_PORT=${PROJECT_LISTEN_PORT} - DATABASE_URL=${DATABASE_URL} - DOCKER_HOST=${DOCKER_HOST} + - DOCKER_HOST_MOUNT_PATH=${DOCKER_HOST_MOUNT_PATH} volumes: - /var/run/docker.sock:/var/run/docker.sock - - easypwn_data:/var/lib/easypwn + - /tmp/easypwn-data:/var/lib/easypwn depends_on: mysqldb: condition: service_healthy @@ -110,9 +112,10 @@ services: - INSTANCE_LISTEN_PORT=${INSTANCE_LISTEN_PORT} - DATABASE_URL=${DATABASE_URL} - DOCKER_HOST=${DOCKER_HOST} + - DOCKER_HOST_MOUNT_PATH=${DOCKER_HOST_MOUNT_PATH} volumes: - /var/run/docker.sock:/var/run/docker.sock - - easypwn_data:/var/lib/easypwn + - /tmp/easypwn-data:/var/lib/easypwn depends_on: mysqldb: condition: service_healthy @@ -131,9 +134,10 @@ services: - AUTH_JWT_SECRET=${AUTH_JWT_SECRET} - DATABASE_URL=${DATABASE_URL} - DOCKER_HOST=${DOCKER_HOST} + - DOCKER_HOST_MOUNT_PATH=${DOCKER_HOST_MOUNT_PATH} volumes: - /var/run/docker.sock:/var/run/docker.sock - - easypwn_data:/var/lib/easypwn + - /tmp/easypwn-data:/var/lib/easypwn depends_on: - project-service - instance-service @@ -172,4 +176,3 @@ services: volumes: mysql_data: - easypwn_data: diff --git a/internal/api/gateway/project.go b/internal/api/gateway/project.go index b87f705..1d3f33e 100644 --- a/internal/api/gateway/project.go +++ b/internal/api/gateway/project.go @@ -8,6 +8,7 @@ import ( "net/http" "os" "path/filepath" + "strings" "github.com/gin-gonic/gin" ) @@ -148,6 +149,8 @@ func CreateProjectHandler(projectClient pb.ProjectClient) gin.HandlerFunc { return } + projectDir = strings.Replace(projectDir, "/var/lib/easypwn", dockerHostMountPath, 1) + res, err := projectClient.CreateProject(context.Background(), &pb.CreateProjectRequest{ Name: req.ProjectName, UserId: c.GetString("user_id"), diff --git a/internal/api/gateway/router.go b/internal/api/gateway/router.go index ecb1ff2..da030cd 100644 --- a/internal/api/gateway/router.go +++ b/internal/api/gateway/router.go @@ -3,10 +3,21 @@ package gateway import ( pb "easypwn/internal/api" jwtauth "easypwn/internal/pkg/auth" + "log" + "os" "github.com/gin-gonic/gin" ) +var dockerHostMountPath string + +func init() { + dockerHostMountPath = os.Getenv("DOCKER_HOST_MOUNT_PATH") + if dockerHostMountPath == "" { + log.Fatalf("DOCKER_HOST_MOUNT_PATH must be set") + } +} + type RouterClients struct { Mailer pb.MailerClient ChatbotClient pb.ChatbotClient From 84ceda19b6bd7206d33c00b87c55752689bad26f Mon Sep 17 00:00:00 2001 From: iiiusi0n Date: Mon, 13 Jan 2025 19:14:53 +0900 Subject: [PATCH 12/12] done --- internal/api/gateway/instance.go | 39 ++++++++ internal/api/gateway/router.go | 2 + internal/service/chatbot.go | 2 +- internal/service/instance.go | 2 + web/lib/components/chat/chat_message.dart | 4 + web/lib/pages/session.dart | 105 +++++++++++++++------- web/lib/services/chatbot_service.dart | 37 ++++++++ web/lib/services/instance_service.dart | 13 ++- 8 files changed, 169 insertions(+), 35 deletions(-) create mode 100644 web/lib/services/chatbot_service.dart diff --git a/internal/api/gateway/instance.go b/internal/api/gateway/instance.go index 1570879..182d4d1 100644 --- a/internal/api/gateway/instance.go +++ b/internal/api/gateway/instance.go @@ -196,3 +196,42 @@ func ActionInstanceHandler(instanceClient pb.InstanceClient) gin.HandlerFunc { c.JSON(http.StatusOK, gin.H{"message": "Instance action performed successfully"}) } } + +func ChatInstanceHandler(chatbotClient pb.ChatbotClient) gin.HandlerFunc { + ctx := context.Background() + + type ChatInstanceRequest struct { + Message string `json:"message"` + } + + type ChatInstanceResponse struct { + Response string `json:"response"` + } + + return func(c *gin.Context) { + var req ChatInstanceRequest + if err := c.ShouldBindJSON(&req); err != nil { + c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()}) + return + } + + instanceId := c.Param("id") + if instanceId == "" { + c.JSON(http.StatusBadRequest, gin.H{"error": "Instance ID is required"}) + return + } + + response, err := chatbotClient.GetResponse(ctx, &pb.GetResponseRequest{ + InstanceId: instanceId, + Message: req.Message, + }) + if err != nil { + c.JSON(http.StatusInternalServerError, gin.H{"error": "Failed to get response"}) + return + } + + c.JSON(http.StatusOK, ChatInstanceResponse{ + Response: response.Response, + }) + } +} diff --git a/internal/api/gateway/router.go b/internal/api/gateway/router.go index da030cd..102dbb3 100644 --- a/internal/api/gateway/router.go +++ b/internal/api/gateway/router.go @@ -64,6 +64,8 @@ func NewRouter(clients RouterClients) *gin.Engine { instance.GET("/:id", ActionInstanceHandler(clients.InstanceClient)) instance.DELETE("/:id", DeleteInstanceHandler(clients.InstanceClient)) + + instance.POST("/:id/chat", ChatInstanceHandler(clients.ChatbotClient)) } return r diff --git a/internal/service/chatbot.go b/internal/service/chatbot.go index c8a49da..2d1e306 100644 --- a/internal/service/chatbot.go +++ b/internal/service/chatbot.go @@ -24,7 +24,7 @@ func NewChatbotService(ctx context.Context, openAiApiKey string, instanceClient func (s *ChatbotService) getLogs(ctx context.Context, instanceId string) (string, error) { logs, err := s.instanceClient.GetInstanceLogs(ctx, &pb.GetInstanceLogsRequest{ InstanceId: instanceId, - Limit: 30, + Limit: 50, }) if err != nil { return "", err diff --git a/internal/service/instance.go b/internal/service/instance.go index b6729a2..eb6e06e 100644 --- a/internal/service/instance.go +++ b/internal/service/instance.go @@ -2,6 +2,7 @@ package service import ( "context" + "strings" pb "easypwn/internal/api" "easypwn/internal/data" @@ -81,6 +82,7 @@ func (s *InstanceService) GetInstanceLogs(ctx context.Context, req *pb.GetInstan if err != nil { return nil, err } + logs = strings.Join(strings.Fields(logs), " ") return &pb.GetInstanceLogsResponse{Logs: logs}, nil } diff --git a/web/lib/components/chat/chat_message.dart b/web/lib/components/chat/chat_message.dart index 94375ea..9edbc91 100644 --- a/web/lib/components/chat/chat_message.dart +++ b/web/lib/components/chat/chat_message.dart @@ -3,11 +3,15 @@ class ChatMessage { final String message; final DateTime timestamp; final bool isSystem; + final bool isLoading; + final bool isError; ChatMessage({ required this.sender, required this.message, required this.timestamp, this.isSystem = false, + this.isLoading = false, + this.isError = false, }); } \ No newline at end of file diff --git a/web/lib/pages/session.dart b/web/lib/pages/session.dart index 2d97d88..4c6776e 100644 --- a/web/lib/pages/session.dart +++ b/web/lib/pages/session.dart @@ -13,6 +13,8 @@ import 'package:go_router/go_router.dart'; import 'dart:async'; import 'package:flutter_secure_storage/flutter_secure_storage.dart'; import '../services/instance_service.dart'; +import '../services/chatbot_service.dart'; + class SessionPage extends StatefulWidget { final String id; const SessionPage({super.key, required this.id}); @@ -21,7 +23,8 @@ class SessionPage extends StatefulWidget { State createState() => _SessionPageState(); } -class _SessionPageState extends State with SingleTickerProviderStateMixin { +class _SessionPageState extends State + with SingleTickerProviderStateMixin { final FlutterSecureStorage _storage = const FlutterSecureStorage(); bool isChatExpanded = true; bool isDebugConnected = true; @@ -42,6 +45,7 @@ class _SessionPageState extends State with SingleTickerProviderStat final TerminalService debugTerminalService = TerminalService(); final TerminalService shellTerminalService = TerminalService(); late InstanceService _instanceService; + late ChatbotService _chatbotService; final double minChatWidth = 300; final double maxChatWidth = 750; double chatWidth = 450; @@ -68,14 +72,15 @@ class _SessionPageState extends State with SingleTickerProviderStat chatMessages.add( ChatMessage( sender: 'System', - message: 'Connected to debug session. Type your messages here.', + message: 'Connected to AI pwnable assistant. Type your messages here.', timestamp: DateTime.now(), isSystem: true, ), ); _initializeTerminal(); - _debugConnectionSubscription = debugTerminalService.connectionStatus.listen((status) { + _debugConnectionSubscription = + debugTerminalService.connectionStatus.listen((status) { if (mounted) { setState(() { isDebugConnected = status; @@ -83,7 +88,8 @@ class _SessionPageState extends State with SingleTickerProviderStat } }); - _shellConnectionSubscription = shellTerminalService.connectionStatus.listen((status) { + _shellConnectionSubscription = + shellTerminalService.connectionStatus.listen((status) { if (mounted) { setState(() { isShellConnected = status; @@ -102,14 +108,18 @@ class _SessionPageState extends State with SingleTickerProviderStat shellTerminal = Terminal( maxLines: 10000, ); - + debugTerminalController = TerminalController(); shellTerminalController = TerminalController(); _instanceService = InstanceService(token: token!); - - debugTerminalService.connect('${Uri.base.scheme == 'https' ? 'wss' : 'ws'}://${Uri.base.host}:${Uri.base.port}/api/stream/session/debugger/${widget.id}', token); - shellTerminalService.connect('${Uri.base.scheme == 'https' ? 'wss' : 'ws'}://${Uri.base.host}:${Uri.base.port}/api/stream/session/shell/${widget.id}', token); + _chatbotService = ChatbotService(token: token); + debugTerminalService.connect( + '${Uri.base.scheme == 'https' ? 'wss' : 'ws'}://${Uri.base.host}:${Uri.base.port}/api/stream/session/debugger/${widget.id}', + token); + shellTerminalService.connect( + '${Uri.base.scheme == 'https' ? 'wss' : 'ws'}://${Uri.base.host}:${Uri.base.port}/api/stream/session/shell/${widget.id}', + token); debugTerminalService.onData = (data) { if (data is List) { @@ -135,20 +145,14 @@ class _SessionPageState extends State with SingleTickerProviderStat // Handle terminal resize debugTerminal.onResize = (w, h, pw, ph) { - final resizeCommand = jsonEncode({ - 'type': 'resize', - 'cols': w, - 'rows': h - }); + final resizeCommand = + jsonEncode({'type': 'resize', 'cols': w, 'rows': h}); debugTerminalService.sendCommand(resizeCommand); }; shellTerminal.onResize = (w, h, pw, ph) { - final resizeCommand = jsonEncode({ - 'type': 'resize', - 'cols': w, - 'rows': h - }); + final resizeCommand = + jsonEncode({'type': 'resize', 'cols': w, 'rows': h}); shellTerminalService.sendCommand(resizeCommand); }; } @@ -168,9 +172,10 @@ class _SessionPageState extends State with SingleTickerProviderStat super.dispose(); } - void _handleChatSubmit(String value) { + void _handleChatSubmit(String value) async { if (value.isEmpty) return; + // Add user message setState(() { chatMessages.add(ChatMessage( sender: 'You', @@ -180,6 +185,45 @@ class _SessionPageState extends State with SingleTickerProviderStat }); _chatController.clear(); _scrollToBottom(_chatScrollController); + + try { + // Add loading message + setState(() { + chatMessages.add(ChatMessage( + sender: 'Assistant', + message: '...', + timestamp: DateTime.now(), + isLoading: true, + )); + }); + _scrollToBottom(_chatScrollController); + + // Get response from API + final response = await _chatbotService.getResponse(widget.id, value); + + // Replace loading message with actual response + setState(() { + chatMessages.removeLast(); + chatMessages.add(ChatMessage( + sender: 'Assistant', + message: response, + timestamp: DateTime.now(), + )); + }); + } catch (e) { + // Replace loading message with error + setState(() { + chatMessages.removeLast(); + chatMessages.add(ChatMessage( + sender: 'System', + message: 'Failed to get response: $e', + timestamp: DateTime.now(), + isSystem: true, + isError: true, + )); + }); + } + _scrollToBottom(_chatScrollController); } void _scrollToBottom(ScrollController controller) { @@ -258,7 +302,7 @@ class _SessionPageState extends State with SingleTickerProviderStat ), ], ), - + // Chat toggle button AnimatedPositioned( duration: const Duration(milliseconds: 100), @@ -266,11 +310,11 @@ class _SessionPageState extends State with SingleTickerProviderStat right: isChatExpanded ? chatWidth : 0, top: MediaQuery.of(context).size.height / 2 - 60, child: GestureDetector( - onHorizontalDragUpdate: (details) { if (!isChatExpanded) return; setState(() { - chatWidth = (chatWidth - details.delta.dx).clamp(minChatWidth, maxChatWidth); + chatWidth = (chatWidth - details.delta.dx) + .clamp(minChatWidth, maxChatWidth); }); }, child: MouseRegion( @@ -302,7 +346,8 @@ class _SessionPageState extends State with SingleTickerProviderStat decoration: const ShapeDecoration( color: AppColors.surface, shape: ContinuousRectangleBorder( - side: BorderSide(color: AppColors.border, width: 1.5), + side: BorderSide( + color: AppColors.border, width: 1.5), borderRadius: BorderRadius.horizontal( left: Radius.elliptical(24, 48), ), @@ -316,7 +361,7 @@ class _SessionPageState extends State with SingleTickerProviderStat mainAxisSize: MainAxisSize.min, children: [ Icon( - isChatExpanded + isChatExpanded ? Icons.chevron_right : Icons.chevron_left, size: 16, @@ -378,13 +423,13 @@ class _SessionPageState extends State with SingleTickerProviderStat }, ), ), - if (!isDebugConnected) Container( color: const Color(0xFF2C1F1F).withOpacity(0.7), child: Center( child: Container( - padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 16), + padding: + const EdgeInsets.symmetric(horizontal: 20, vertical: 16), decoration: BoxDecoration( color: const Color(0xFF1E1E1E).withOpacity(0.95), borderRadius: BorderRadius.circular(8), @@ -442,7 +487,6 @@ class _SessionPageState extends State with SingleTickerProviderStat ), ), ), - Positioned( right: 16, bottom: 16, @@ -465,7 +509,7 @@ class _SessionPageState extends State with SingleTickerProviderStat ], ); } - + Widget _buildShellTab() { return Stack( children: [ @@ -496,13 +540,13 @@ class _SessionPageState extends State with SingleTickerProviderStat }, ), ), - if (!isShellConnected) Container( color: const Color(0xFF2C1F1F).withOpacity(0.7), child: Center( child: Container( - padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 16), + padding: + const EdgeInsets.symmetric(horizontal: 20, vertical: 16), decoration: BoxDecoration( color: const Color(0xFF1E1E1E).withOpacity(0.95), borderRadius: BorderRadius.circular(8), @@ -560,7 +604,6 @@ class _SessionPageState extends State with SingleTickerProviderStat ), ), ), - Positioned( right: 16, bottom: 16, diff --git a/web/lib/services/chatbot_service.dart b/web/lib/services/chatbot_service.dart new file mode 100644 index 0000000..4e78512 --- /dev/null +++ b/web/lib/services/chatbot_service.dart @@ -0,0 +1,37 @@ +import 'dart:convert'; + +import 'package:http/http.dart' as http; + +class ChatbotResponse { + final String response; + + ChatbotResponse({required this.response}); + + factory ChatbotResponse.fromJson(Map json) { + return ChatbotResponse(response: json['response'].replaceAll('\\n', '\n')); + } +} + +class ChatbotService { + final String token; + + ChatbotService({required this.token}); + + Future getResponse(String instanceId, String message) async { + final response = await http.post( + Uri.parse('/api/instance/$instanceId/chat'), + headers: { + 'Authorization': 'Bearer $token', + 'Content-Type': 'application/json', + }, + body: jsonEncode({ + 'message': message, + }), + ); + if (response.statusCode == 200) { + return ChatbotResponse.fromJson(jsonDecode(response.body)).response; + } else { + throw Exception('Failed to get response'); + } + } +} diff --git a/web/lib/services/instance_service.dart b/web/lib/services/instance_service.dart index 1c473d1..903035f 100644 --- a/web/lib/services/instance_service.dart +++ b/web/lib/services/instance_service.dart @@ -8,7 +8,12 @@ class Instance { final String createdAt; final String updatedAt; - Instance({required this.id, required this.status, required this.memory, required this.createdAt, required this.updatedAt}); + Instance( + {required this.id, + required this.status, + required this.memory, + required this.createdAt, + required this.updatedAt}); factory Instance.fromJson(Map json) { return Instance( @@ -36,7 +41,9 @@ class InstanceService { if (response.statusCode == 200) { final data = jsonDecode(response.body); if (data == null) return []; - return (data as List).map((instance) => Instance.fromJson(instance)).toList(); + return (data as List) + .map((instance) => Instance.fromJson(instance)) + .toList(); } else { throw Exception('Failed to get instances'); } @@ -113,4 +120,4 @@ class InstanceService { throw Exception('Failed to stop instance'); } } -} \ No newline at end of file +}