From a9ee1e9627e59ebb6762f8c17506a6e9e9bad9f0 Mon Sep 17 00:00:00 2001 From: wubijie Date: Wed, 27 Nov 2024 20:04:45 +0800 Subject: [PATCH] Add copyright information --- cmd/agent/app/config/config.go | 22 +- cmd/agent/app/filemonitor/filemonitor.go | 215 +++++----- cmd/agent/app/global/global.go | 7 + cmd/agent/app/localstorage/localstorage.go | 22 +- cmd/agent/app/network/client.go | 21 +- cmd/agent/app/register/handler/command.go | 7 + cmd/agent/app/register/handler/cron.go | 7 + cmd/agent/app/register/handler/disk.go | 7 + cmd/agent/app/register/handler/file.go | 7 + cmd/agent/app/register/handler/firewall.go | 7 + cmd/agent/app/register/handler/machine.go | 7 + cmd/agent/app/register/handler/network.go | 7 + cmd/agent/app/register/handler/rpm.go | 7 + cmd/agent/app/register/handler/service.go | 7 + cmd/agent/app/register/handler/sysctl.go | 7 + cmd/agent/app/register/handler/user.go | 7 + cmd/agent/app/register/registerhandler.go | 21 +- cmd/agent/main.go | 21 +- cmd/server/app/agentmanager/agent.go | 21 +- cmd/server/app/agentmanager/agentmanager.go | 21 +- cmd/server/app/agentmanager/cmd.go | 7 + cmd/server/app/agentmanager/file.go | 7 + cmd/server/app/agentmanager/firewall.go | 7 + cmd/server/app/agentmanager/host.go | 7 + cmd/server/app/agentmanager/network.go | 7 + cmd/server/app/agentmanager/rpm.go | 7 + cmd/server/app/agentmanager/service.go | 7 + cmd/server/app/agentmanager/user.go | 7 + cmd/server/app/cmd/commands/configtemplete.go | 7 + cmd/server/app/cmd/commands/docs.go | 7 + cmd/server/app/cmd/commands/root.go | 7 + cmd/server/app/cmd/commands/server.go | 7 + cmd/server/app/cmd/commands/version.go | 7 + cmd/server/app/cmd/options/options.go | 21 +- cmd/server/app/config/config.go | 21 +- .../controller/agentcontroller/agent.go | 21 +- .../controller/agentcontroller/config.go | 7 + .../network/controller/agentcontroller/cpu.go | 21 +- .../controller/agentcontroller/cron.go | 21 +- .../controller/agentcontroller/disk.go | 21 +- .../controller/agentcontroller/file.go | 22 +- .../controller/agentcontroller/firewall.go | 21 +- .../controller/agentcontroller/memory.go | 21 +- .../controller/agentcontroller/network.go | 21 +- .../network/controller/agentcontroller/os.go | 21 +- .../network/controller/agentcontroller/rpm.go | 21 +- .../controller/agentcontroller/script.go | 191 ++++----- .../controller/agentcontroller/service.go | 21 +- .../controller/agentcontroller/sysctl.go | 21 +- .../controller/agentcontroller/timecompare.go | 7 + .../controller/agentcontroller/user.go | 21 +- .../app/network/controller/auditloghandler.go | 161 ++++--- cmd/server/app/network/controller/batch.go | 361 ++++++++-------- cmd/server/app/network/controller/cluster.go | 21 +- cmd/server/app/network/controller/config.go | 21 +- cmd/server/app/network/controller/depart.go | 349 ++++++++-------- .../app/network/controller/fileservice.go | 7 + cmd/server/app/network/controller/machine.go | 21 +- cmd/server/app/network/controller/plugin.go | 7 + .../controller/pluginWebsocketProxy.go | 7 + .../app/network/controller/pluginapi/batch.go | 7 + .../network/controller/pluginapi/config.go | 7 + .../network/controller/pluginapi/machine.go | 7 + .../network/controller/pluginapi/package.go | 7 + .../network/controller/pluginapi/plugin.go | 7 + .../network/controller/pluginapi/script.go | 7 + .../network/controller/pluginapi/service.go | 7 + .../app/network/controller/pluginapi/tag.go | 7 + .../app/network/controller/pushalarm.go | 22 +- cmd/server/app/network/controller/role.go | 393 +++++++++--------- cmd/server/app/network/controller/script.go | 7 + cmd/server/app/network/controller/user.go | 21 +- cmd/server/app/network/controller/version.go | 7 + .../app/network/controller/web_terminal.go | 22 +- cmd/server/app/network/httpserver.go | 21 +- cmd/server/app/network/jwt/jwt.go | 21 +- cmd/server/app/network/middleware/auth.go | 7 + cmd/server/app/network/middleware/logger.go | 21 +- cmd/server/app/network/session.go | 7 + cmd/server/app/network/socketserver.go | 21 +- cmd/server/app/network/websocket/client.go | 7 + .../app/network/websocket/client_manager.go | 7 + cmd/server/app/network/websocket/sshclient.go | 22 +- .../app/network/websocket/webterminal.go | 21 +- cmd/server/app/resource/resource.go | 22 +- cmd/server/app/resource/resource_prod.go | 22 +- cmd/server/app/service/auditlog/auditlog.go | 175 ++++---- cmd/server/app/service/auth/casbin.go | 21 +- cmd/server/app/service/auth/casbin_test.go | 21 +- cmd/server/app/service/batch/batch.go | 21 +- cmd/server/app/service/cluster/cluster.go | 21 +- cmd/server/app/service/common/common.go | 21 +- .../app/service/configfile/configfile.go | 7 + .../app/service/configmanage/configmanage.go | 21 +- .../service/configmanage/internal/hosts.go | 7 + .../app/service/configmanage/internal/repo.go | 7 + .../configmanage/internal/sshconfig.go | 7 + .../configmanage/internal/sshdconfig.go | 7 + .../service/configmanage/internal/sysctl.go | 7 + cmd/server/app/service/cron/cron.go | 21 +- cmd/server/app/service/depart/depart.go | 21 +- .../app/service/internal/dao/auditlogdao.go | 21 +- .../service/internal/dao/batchmanagerdao.go | 7 + .../app/service/internal/dao/configfiledao.go | 7 + .../service/internal/dao/configmanagedao.go | 21 +- .../app/service/internal/dao/crondao.go | 21 +- .../app/service/internal/dao/departdao.go | 21 +- .../service/internal/dao/machinemanagerdao.go | 21 +- cmd/server/app/service/internal/dao/plugin.go | 21 +- .../app/service/internal/dao/roledao.go | 21 +- .../app/service/internal/dao/scriptdao.go | 7 + .../app/service/internal/dao/userdao.go | 21 +- .../app/service/internal/dao/userroledao.go | 7 + .../app/service/machine/machinemanager.go | 7 + cmd/server/app/service/plugin/event.go | 7 + cmd/server/app/service/plugin/heartbeat.go | 7 + cmd/server/app/service/plugin/plugin.go | 7 + cmd/server/app/service/plugin/proxy.go | 7 + cmd/server/app/service/role/role.go | 21 +- cmd/server/app/service/script/script.go | 7 + cmd/server/app/service/tag/tag.go | 7 + cmd/server/app/service/user/user.go | 21 +- cmd/server/main.go | 21 +- frontend/env.d.ts | 7 + frontend/index.html | 7 + frontend/src/App.vue | 7 + frontend/src/components/AuthButton.vue | 7 + frontend/src/components/PGTable.vue | 7 + frontend/src/components/PGTree.vue | 7 + frontend/src/components/StateDot.vue | 7 + frontend/src/main.ts | 9 +- frontend/src/module/cookie.ts | 7 + frontend/src/module/permission.ts | 7 + frontend/src/request/audit.ts | 7 + frontend/src/request/basic.ts | 7 + frontend/src/request/batch.ts | 7 + frontend/src/request/cluster.ts | 7 + frontend/src/request/overview.ts | 7 + frontend/src/request/plugin.ts | 7 + frontend/src/request/request.ts | 7 + frontend/src/request/role.ts | 7 + frontend/src/request/user.ts | 7 + frontend/src/router/index.ts | 7 + frontend/src/stores/index.ts | 9 +- frontend/src/stores/plugin.ts | 7 + frontend/src/stores/router.ts | 7 + frontend/src/stores/tagview.ts | 7 + frontend/src/stores/user.ts | 7 + frontend/src/styles/base.css | 7 + frontend/src/types/audit.ts | 7 + frontend/src/types/batch.ts | 7 + frontend/src/types/cluster.ts | 7 + frontend/src/types/plugin.ts | 7 + frontend/src/views/Audit/Audit.vue | 7 + frontend/src/views/Audit/AuditDetail.vue | 7 + frontend/src/views/Batch/Batch.vue | 7 + frontend/src/views/Batch/Detail.vue | 7 + .../views/Batch/components/UpdateBatch.vue | 7 + .../src/views/Batch/components/UpdateRpm.vue | 7 + frontend/src/views/Cluster/Cluster.vue | 7 + frontend/src/views/Cluster/CreateBatch.vue | 7 + .../src/views/Cluster/MachineDetail/Base.vue | 7 + .../src/views/Cluster/MachineDetail/Index.vue | 7 + .../views/Cluster/MachineDetail/Network.vue | 7 + .../views/Cluster/MachineDetail/Package.vue | 7 + .../views/Cluster/MachineDetail/Service.vue | 7 + .../views/Cluster/MachineDetail/Sysctl.vue | 7 + .../views/Cluster/MachineDetail/Terminal.vue | 7 + .../src/views/Cluster/MachineDetail/User.vue | 7 + .../views/Cluster/components/ChangeDepart.vue | 7 + frontend/src/views/Home/Home.vue | 7 + .../src/views/Home/components/BreadCrumb.vue | 7 + .../src/views/Home/components/Sidebar.vue | 7 + .../src/views/Home/components/TagView.vue | 7 + .../src/views/Home/components/changePwd.vue | 7 + frontend/src/views/Login/Login.vue | 7 + frontend/src/views/Login/logic.ts | 7 + frontend/src/views/Overview/Overview.vue | 7 + .../views/Overview/components/DepartChart.vue | 7 + frontend/src/views/Plugin/Plugin.vue | 7 + frontend/src/views/Plugin/PluginFrame.vue | 7 + .../src/views/Plugin/components/AddPlugin.vue | 7 + frontend/src/views/Plugin/plugin.ts | 7 + frontend/src/views/Role/Role.vue | 7 + .../src/views/Role/components/AddRole.vue | 7 + .../src/views/Role/components/RoleForm.vue | 7 + .../src/views/Role/components/UpdateRole.vue | 7 + .../src/views/Role/components/authData.ts | 7 + frontend/src/views/User/User.vue | 7 + .../src/views/User/components/AddUser.vue | 7 + .../src/views/User/components/UpdateUser.vue | 7 + .../src/views/User/components/importUser.vue | 7 + frontend/src/views/User/components/logic.ts | 7 + frontend/src/views/errorPage.vue | 7 + frontend/vite.config.ts | 7 + pkg/dbmanager/db.go | 7 + pkg/dbmanager/mysqlmanager/mysqlmanager.go | 21 +- pkg/dbmanager/redismanager/common.go | 21 +- pkg/dbmanager/redismanager/redismanager.go | 21 +- pkg/global/global.go | 21 +- pkg/utils/command.go | 21 +- pkg/utils/common.go | 21 +- pkg/utils/crypto.go | 7 + pkg/utils/file.go | 22 +- pkg/utils/message/common/agent.go | 7 + pkg/utils/message/net/tool.go | 21 +- pkg/utils/message/protocol/message.go | 7 + pkg/utils/message/protocol/tlvcodec.go | 7 + pkg/utils/os/baseos/baseos.go | 7 + pkg/utils/os/baseos/cpu.go | 7 + pkg/utils/os/baseos/cpu_test.go | 7 + pkg/utils/os/baseos/disk.go | 7 + pkg/utils/os/baseos/disk_test.go | 7 + pkg/utils/os/baseos/firewall.go | 7 + pkg/utils/os/baseos/firewall_test.go | 7 + pkg/utils/os/baseos/memory.go | 7 + pkg/utils/os/baseos/memory_test.go | 7 + pkg/utils/os/baseos/network.go | 21 +- pkg/utils/os/baseos/network_test.go | 7 + pkg/utils/os/baseos/rpm.go | 21 +- pkg/utils/os/baseos/rpm_test.go | 7 + pkg/utils/os/baseos/service.go | 7 + pkg/utils/os/baseos/service_test.go | 7 + pkg/utils/os/baseos/sysctl.go | 7 + pkg/utils/os/baseos/sysctl_test.go | 7 + pkg/utils/os/baseos/system.go | 7 + pkg/utils/os/baseos/system_test.go | 7 + pkg/utils/os/baseos/time.go | 7 + pkg/utils/os/baseos/time_test.go | 7 + pkg/utils/os/baseos/user.go | 7 + pkg/utils/os/baseos/user_test.go | 7 + pkg/utils/os/centos/centos.go | 7 + pkg/utils/os/common/cpu.go | 7 + pkg/utils/os/common/cron.go | 21 +- pkg/utils/os/common/disk.go | 7 + pkg/utils/os/common/file.go | 23 +- pkg/utils/os/common/firewall.go | 7 + pkg/utils/os/common/interface.go | 7 + pkg/utils/os/common/memory.go | 7 + pkg/utils/os/common/network.go | 7 + pkg/utils/os/common/os.go | 7 + pkg/utils/os/common/package.go | 7 + pkg/utils/os/common/service.go | 7 + pkg/utils/os/common/system.go | 7 + pkg/utils/os/common/user.go | 7 + pkg/utils/os/kylin/kylin.go | 7 + pkg/utils/os/nestos/nestos.go | 7 + pkg/utils/os/openeuler/openeuler.go | 7 + pkg/utils/os/os.go | 7 + pkg/utils/templete.go | 7 + sdk/common/common.go | 7 + sdk/common/extention.go | 7 + sdk/common/machine.go | 7 + sdk/common/permission.go | 7 + sdk/common/script.go | 7 + sdk/common/service.go | 123 +++--- sdk/common/status.go | 7 + sdk/common/tag.go | 7 + sdk/logger/logger.go | 21 +- sdk/plugin/client/batch.go | 7 + sdk/plugin/client/bindsync.go | 7 + sdk/plugin/client/client.go | 7 + sdk/plugin/client/config.go | 7 + sdk/plugin/client/extention.go | 7 + sdk/plugin/client/fileservice.go | 7 + sdk/plugin/client/handler.go | 7 + sdk/plugin/client/heartbeat.go | 7 + sdk/plugin/client/machine.go | 7 + sdk/plugin/client/permission.go | 7 + sdk/plugin/client/plugin.go | 7 + sdk/plugin/client/script.go | 7 + sdk/plugin/client/service.go | 7 + sdk/response/response.go | 7 + sdk/utils/config/config.go | 21 +- sdk/utils/httputils/judgeProtocol.go | 7 + sdk/utils/httputils/request.go | 7 + 276 files changed, 2865 insertions(+), 1960 deletions(-) diff --git a/cmd/agent/app/config/config.go b/cmd/agent/app/config/config.go index 5296d5aa..1d81a86c 100644 --- a/cmd/agent/app/config/config.go +++ b/cmd/agent/app/config/config.go @@ -1,18 +1,10 @@ -/****************************************************************************** - * Copyright (c) KylinSoft Co., Ltd.2021-2022. All rights reserved. - * PilotGo is licensed under the Mulan PSL v2. - * You can use this software accodring to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN 'AS IS' BASIS, WITHOUT WARRANTIES OF ANY KIND, - * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - * See the Mulan PSL v2 for more details. - * Author: yangzhao1 - * Date: 2022-04-05 10:28:34 - * LastEditTime: 2022-04-06 15:08:42 - * Description: provide agent log manager of pilotgo - ******************************************************************************/ - +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ package config import ( diff --git a/cmd/agent/app/filemonitor/filemonitor.go b/cmd/agent/app/filemonitor/filemonitor.go index 7b649680..e536540d 100644 --- a/cmd/agent/app/filemonitor/filemonitor.go +++ b/cmd/agent/app/filemonitor/filemonitor.go @@ -1,111 +1,104 @@ -/****************************************************************************** - * Copyright (c) KylinSoft Co., Ltd.2021-2022. All rights reserved. - * PilotGo is licensed under the Mulan PSL v2. - * You can use this software accodring to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - *     http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN 'AS IS' BASIS, WITHOUT WARRANTIES OF ANY KIND, - * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - * See the Mulan PSL v2 for more details. - * Author: zhanghan - * Date: 2022-07-05 13:03:16 - * LastEditTime: 2023-02-21 19:02:55 - * Description: file monitor init - ******************************************************************************/ -package filemonitor - -import ( - "fmt" - "path" - "strings" - - "gitee.com/openeuler/PilotGo/cmd/agent/app/localstorage" - "gitee.com/openeuler/PilotGo/cmd/agent/app/network" - "gitee.com/openeuler/PilotGo/pkg/utils/message/protocol" - "gitee.com/openeuler/PilotGo/sdk/logger" - "github.com/fsnotify/fsnotify" - "github.com/google/uuid" -) - -// repo路径 -const RepoPath = "/etc/yum.repos.d" - -// 网络配置 -const NetWorkPath = "/etc/sysconfig/network-scripts" - -var RESP_MSG = make(chan interface{}) - -func FileMonitorInit() error { - // get agent uuid - uuid := localstorage.AgentUUID() - - // 1、NewWatcher 初始化一个 watcher - watcher, err := fsnotify.NewWatcher() - if err != nil { - return err - } - defer watcher.Close() - - // 2、使用 watcher 的 Add 方法增加需要监听的文件或目录到监听队列中 - err = watcher.Add(RepoPath) - if err != nil { - logger.Debug("failed to monitor repo") - } - logger.Info("start to monitor repo") - - err = watcher.Add(NetWorkPath) - if err != nil { - logger.Debug("failed to monitor network") - } - logger.Info("start to monitor network") - - //3、创建新的 goroutine,等待管道中的事件或错误 - done := make(chan bool) - go func() { - defer close(done) - for { - select { - case e, ok := <-watcher.Events: - if !ok { - return - } - fileExt := path.Ext(e.Name) - if strings.Contains(fileExt, ".sw") || strings.Contains(fileExt, "~") || strings.Contains(e.Name, "~") { - continue - } - - if e.Op&fsnotify.Write == fsnotify.Write { - RESP_MSG <- fmt.Sprintf("机器 %s 上的文件已被修改 : %s", uuid, e.Name) - } - - case err, ok := <-watcher.Errors: - if !ok { - return - } - logger.Error("error: %s", err) - } - } - }() - <-done - return nil -} - -func FileMonitor(client *network.SocketClient) { - for data := range RESP_MSG { - if data == nil { - continue - } - - msg := &protocol.Message{ - UUID: uuid.New().String(), - Type: protocol.FileMonitor, - Status: 0, - Data: data, - } - - if err := client.Send(msg); err != nil { - logger.Debug("send message failed, error: %s", err) - } - - } -} +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ +package filemonitor + +import ( + "fmt" + "path" + "strings" + + "gitee.com/openeuler/PilotGo/cmd/agent/app/localstorage" + "gitee.com/openeuler/PilotGo/cmd/agent/app/network" + "gitee.com/openeuler/PilotGo/pkg/utils/message/protocol" + "gitee.com/openeuler/PilotGo/sdk/logger" + "github.com/fsnotify/fsnotify" + "github.com/google/uuid" +) + +// repo路径 +const RepoPath = "/etc/yum.repos.d" + +// 网络配置 +const NetWorkPath = "/etc/sysconfig/network-scripts" + +var RESP_MSG = make(chan interface{}) + +func FileMonitorInit() error { + // get agent uuid + uuid := localstorage.AgentUUID() + + // 1、NewWatcher 初始化一个 watcher + watcher, err := fsnotify.NewWatcher() + if err != nil { + return err + } + defer watcher.Close() + + // 2、使用 watcher 的 Add 方法增加需要监听的文件或目录到监听队列中 + err = watcher.Add(RepoPath) + if err != nil { + logger.Debug("failed to monitor repo") + } + logger.Info("start to monitor repo") + + err = watcher.Add(NetWorkPath) + if err != nil { + logger.Debug("failed to monitor network") + } + logger.Info("start to monitor network") + + //3、创建新的 goroutine,等待管道中的事件或错误 + done := make(chan bool) + go func() { + defer close(done) + for { + select { + case e, ok := <-watcher.Events: + if !ok { + return + } + fileExt := path.Ext(e.Name) + if strings.Contains(fileExt, ".sw") || strings.Contains(fileExt, "~") || strings.Contains(e.Name, "~") { + continue + } + + if e.Op&fsnotify.Write == fsnotify.Write { + RESP_MSG <- fmt.Sprintf("机器 %s 上的文件已被修改 : %s", uuid, e.Name) + } + + case err, ok := <-watcher.Errors: + if !ok { + return + } + logger.Error("error: %s", err) + } + } + }() + <-done + return nil +} + +func FileMonitor(client *network.SocketClient) { + for data := range RESP_MSG { + if data == nil { + continue + } + + msg := &protocol.Message{ + UUID: uuid.New().String(), + Type: protocol.FileMonitor, + Status: 0, + Data: data, + } + + if err := client.Send(msg); err != nil { + logger.Debug("send message failed, error: %s", err) + } + + } +} diff --git a/cmd/agent/app/global/global.go b/cmd/agent/app/global/global.go index f85eef97..aae27344 100644 --- a/cmd/agent/app/global/global.go +++ b/cmd/agent/app/global/global.go @@ -1,3 +1,10 @@ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ package global import ( diff --git a/cmd/agent/app/localstorage/localstorage.go b/cmd/agent/app/localstorage/localstorage.go index 4ef09b48..0802938e 100644 --- a/cmd/agent/app/localstorage/localstorage.go +++ b/cmd/agent/app/localstorage/localstorage.go @@ -1,18 +1,10 @@ -/****************************************************************************** - * Copyright (c) KylinSoft Co., Ltd.2021-2022. All rights reserved. - * PilotGo is licensed under the Mulan PSL v2. - * You can use this software accodring to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN 'AS IS' BASIS, WITHOUT WARRANTIES OF ANY KIND, - * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - * See the Mulan PSL v2 for more details. - * Author: yangzhao1 - * Date: 2022-04-13 15:11:03 - * LastEditTime: 2022-04-18 16:02:57 - * Description: provide agent log manager of pilotgo - ******************************************************************************/ - +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ package localstorage import ( diff --git a/cmd/agent/app/network/client.go b/cmd/agent/app/network/client.go index 5632683e..a6bf55fe 100644 --- a/cmd/agent/app/network/client.go +++ b/cmd/agent/app/network/client.go @@ -1,17 +1,10 @@ -/****************************************************************************** - * Copyright (c) KylinSoft Co., Ltd.2021-2022. All rights reserved. - * PilotGo is licensed under the Mulan PSL v2. - * You can use this software accodring to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - *     http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN 'AS IS' BASIS, WITHOUT WARRANTIES OF ANY KIND, - * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - * See the Mulan PSL v2 for more details. - * Author: zhanghan - * Date: 2022-01-24 15:08:08 - * LastEditTime: 2022-04-09 17:24:42 - * Description: provide agent service functions. - ******************************************************************************/ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ package network import ( diff --git a/cmd/agent/app/register/handler/command.go b/cmd/agent/app/register/handler/command.go index dfbab064..7d8695ad 100644 --- a/cmd/agent/app/register/handler/command.go +++ b/cmd/agent/app/register/handler/command.go @@ -1,3 +1,10 @@ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ package handler import ( diff --git a/cmd/agent/app/register/handler/cron.go b/cmd/agent/app/register/handler/cron.go index 02d6496e..a105183b 100644 --- a/cmd/agent/app/register/handler/cron.go +++ b/cmd/agent/app/register/handler/cron.go @@ -1,3 +1,10 @@ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ package handler import ( diff --git a/cmd/agent/app/register/handler/disk.go b/cmd/agent/app/register/handler/disk.go index 3c416080..eef32163 100644 --- a/cmd/agent/app/register/handler/disk.go +++ b/cmd/agent/app/register/handler/disk.go @@ -1,3 +1,10 @@ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ package handler import ( diff --git a/cmd/agent/app/register/handler/file.go b/cmd/agent/app/register/handler/file.go index f134f024..92df2791 100644 --- a/cmd/agent/app/register/handler/file.go +++ b/cmd/agent/app/register/handler/file.go @@ -1,3 +1,10 @@ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ package handler import ( diff --git a/cmd/agent/app/register/handler/firewall.go b/cmd/agent/app/register/handler/firewall.go index 4c421d54..1838b750 100644 --- a/cmd/agent/app/register/handler/firewall.go +++ b/cmd/agent/app/register/handler/firewall.go @@ -1,3 +1,10 @@ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ package handler import ( diff --git a/cmd/agent/app/register/handler/machine.go b/cmd/agent/app/register/handler/machine.go index a0463b52..60b1e170 100644 --- a/cmd/agent/app/register/handler/machine.go +++ b/cmd/agent/app/register/handler/machine.go @@ -1,3 +1,10 @@ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ package handler import ( diff --git a/cmd/agent/app/register/handler/network.go b/cmd/agent/app/register/handler/network.go index 41ff19cb..1f22d8a7 100644 --- a/cmd/agent/app/register/handler/network.go +++ b/cmd/agent/app/register/handler/network.go @@ -1,3 +1,10 @@ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ package handler import ( diff --git a/cmd/agent/app/register/handler/rpm.go b/cmd/agent/app/register/handler/rpm.go index edacf0a1..4ad437f8 100644 --- a/cmd/agent/app/register/handler/rpm.go +++ b/cmd/agent/app/register/handler/rpm.go @@ -1,3 +1,10 @@ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ package handler import ( diff --git a/cmd/agent/app/register/handler/service.go b/cmd/agent/app/register/handler/service.go index 67bc733b..3b094482 100644 --- a/cmd/agent/app/register/handler/service.go +++ b/cmd/agent/app/register/handler/service.go @@ -1,3 +1,10 @@ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ package handler import ( diff --git a/cmd/agent/app/register/handler/sysctl.go b/cmd/agent/app/register/handler/sysctl.go index 8c95c130..5f438bb3 100644 --- a/cmd/agent/app/register/handler/sysctl.go +++ b/cmd/agent/app/register/handler/sysctl.go @@ -1,3 +1,10 @@ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ package handler import ( diff --git a/cmd/agent/app/register/handler/user.go b/cmd/agent/app/register/handler/user.go index 31d88213..d0b3b207 100644 --- a/cmd/agent/app/register/handler/user.go +++ b/cmd/agent/app/register/handler/user.go @@ -1,3 +1,10 @@ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ package handler import ( diff --git a/cmd/agent/app/register/registerhandler.go b/cmd/agent/app/register/registerhandler.go index a60f59ae..9487c775 100644 --- a/cmd/agent/app/register/registerhandler.go +++ b/cmd/agent/app/register/registerhandler.go @@ -1,17 +1,10 @@ -/****************************************************************************** - * Copyright (c) KylinSoft Co., Ltd.2021-2022. All rights reserved. - * PilotGo is licensed under the Mulan PSL v2. - * You can use this software accodring to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - *     http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN 'AS IS' BASIS, WITHOUT WARRANTIES OF ANY KIND, - * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - * See the Mulan PSL v2 for more details. - * Author: zhanghan - * Date: 2022-07-05 13:03:16 - * LastEditTime: 2023-08-30 16:00:51 - * Description: socket client register - ******************************************************************************/ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ package register import ( diff --git a/cmd/agent/main.go b/cmd/agent/main.go index bb5102fd..0133c7bc 100644 --- a/cmd/agent/main.go +++ b/cmd/agent/main.go @@ -1,17 +1,10 @@ -/****************************************************************************** - * Copyright (c) KylinSoft Co., Ltd.2021-2022. All rights reserved. - * PilotGo is licensed under the Mulan PSL v2. - * You can use this software accodring to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - *     http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN 'AS IS' BASIS, WITHOUT WARRANTIES OF ANY KIND, - * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - * See the Mulan PSL v2 for more details. - * Author: zhanghan - * Date: 2021-11-18 10:25:52 - * LastEditTime: 2023-02-21 19:03:23 - * Description: agent main - ******************************************************************************/ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ package main import ( diff --git a/cmd/server/app/agentmanager/agent.go b/cmd/server/app/agentmanager/agent.go index fdad9337..55082aaf 100644 --- a/cmd/server/app/agentmanager/agent.go +++ b/cmd/server/app/agentmanager/agent.go @@ -1,17 +1,10 @@ -/****************************************************************************** - * Copyright (c) KylinSoft Co., Ltd.2021-2022. All rights reserved. - * PilotGo is licensed under the Mulan PSL v2. - * You can use this software accodring to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - *     http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN 'AS IS' BASIS, WITHOUT WARRANTIES OF ANY KIND, - * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - * See the Mulan PSL v2 for more details. - * Author: zhanghan - * Date: 2022-02-18 02:33:55 - * LastEditTime: 2023-07-11 16:52:58 - * Description: socket server's agentmanager - ******************************************************************************/ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ package agentmanager import ( diff --git a/cmd/server/app/agentmanager/agentmanager.go b/cmd/server/app/agentmanager/agentmanager.go index 56e28e5f..2f190f81 100644 --- a/cmd/server/app/agentmanager/agentmanager.go +++ b/cmd/server/app/agentmanager/agentmanager.go @@ -1,17 +1,10 @@ -/****************************************************************************** - * Copyright (c) KylinSoft Co., Ltd.2021-2022. All rights reserved. - * PilotGo is licensed under the Mulan PSL v2. - * You can use this software accodring to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - *     http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN 'AS IS' BASIS, WITHOUT WARRANTIES OF ANY KIND, - * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - * See the Mulan PSL v2 for more details. - * Author: zhanghan - * Date: 2021-01-18 02:33:55 - * LastEditTime: 2023-07-10 14:49:50 - * Description: socket server - ******************************************************************************/ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ package agentmanager import ( diff --git a/cmd/server/app/agentmanager/cmd.go b/cmd/server/app/agentmanager/cmd.go index 3565bb86..0d71429d 100644 --- a/cmd/server/app/agentmanager/cmd.go +++ b/cmd/server/app/agentmanager/cmd.go @@ -1,3 +1,10 @@ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ package agentmanager import ( diff --git a/cmd/server/app/agentmanager/file.go b/cmd/server/app/agentmanager/file.go index 0936545e..508ff0a6 100644 --- a/cmd/server/app/agentmanager/file.go +++ b/cmd/server/app/agentmanager/file.go @@ -1,3 +1,10 @@ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ package agentmanager import ( diff --git a/cmd/server/app/agentmanager/firewall.go b/cmd/server/app/agentmanager/firewall.go index fb81707a..5e21b244 100644 --- a/cmd/server/app/agentmanager/firewall.go +++ b/cmd/server/app/agentmanager/firewall.go @@ -1,3 +1,10 @@ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ package agentmanager import ( diff --git a/cmd/server/app/agentmanager/host.go b/cmd/server/app/agentmanager/host.go index 8c1b3ffd..8bb72f18 100644 --- a/cmd/server/app/agentmanager/host.go +++ b/cmd/server/app/agentmanager/host.go @@ -1,3 +1,10 @@ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ package agentmanager import ( diff --git a/cmd/server/app/agentmanager/network.go b/cmd/server/app/agentmanager/network.go index 59af274d..618b9bf0 100644 --- a/cmd/server/app/agentmanager/network.go +++ b/cmd/server/app/agentmanager/network.go @@ -1,3 +1,10 @@ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 +*/ package agentmanager import ( diff --git a/cmd/server/app/agentmanager/rpm.go b/cmd/server/app/agentmanager/rpm.go index e2a0f35b..c1f259a8 100644 --- a/cmd/server/app/agentmanager/rpm.go +++ b/cmd/server/app/agentmanager/rpm.go @@ -1,3 +1,10 @@ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ package agentmanager import ( diff --git a/cmd/server/app/agentmanager/service.go b/cmd/server/app/agentmanager/service.go index 1e95cbb1..2bc00686 100644 --- a/cmd/server/app/agentmanager/service.go +++ b/cmd/server/app/agentmanager/service.go @@ -1,3 +1,10 @@ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ package agentmanager import ( diff --git a/cmd/server/app/agentmanager/user.go b/cmd/server/app/agentmanager/user.go index 8ab0071c..1d9cda29 100644 --- a/cmd/server/app/agentmanager/user.go +++ b/cmd/server/app/agentmanager/user.go @@ -1,3 +1,10 @@ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ package agentmanager import ( diff --git a/cmd/server/app/cmd/commands/configtemplete.go b/cmd/server/app/cmd/commands/configtemplete.go index 20085b56..d8686d3c 100644 --- a/cmd/server/app/cmd/commands/configtemplete.go +++ b/cmd/server/app/cmd/commands/configtemplete.go @@ -1,3 +1,10 @@ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ package commands import ( diff --git a/cmd/server/app/cmd/commands/docs.go b/cmd/server/app/cmd/commands/docs.go index 3cc55495..34eecb95 100644 --- a/cmd/server/app/cmd/commands/docs.go +++ b/cmd/server/app/cmd/commands/docs.go @@ -1,3 +1,10 @@ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ package commands import ( diff --git a/cmd/server/app/cmd/commands/root.go b/cmd/server/app/cmd/commands/root.go index 91c4ab34..cf913f19 100644 --- a/cmd/server/app/cmd/commands/root.go +++ b/cmd/server/app/cmd/commands/root.go @@ -1,3 +1,10 @@ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ package commands import ( diff --git a/cmd/server/app/cmd/commands/server.go b/cmd/server/app/cmd/commands/server.go index 8a9ddcb9..facd2705 100644 --- a/cmd/server/app/cmd/commands/server.go +++ b/cmd/server/app/cmd/commands/server.go @@ -1,3 +1,10 @@ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ package commands import ( diff --git a/cmd/server/app/cmd/commands/version.go b/cmd/server/app/cmd/commands/version.go index 646d51ff..f89f8564 100644 --- a/cmd/server/app/cmd/commands/version.go +++ b/cmd/server/app/cmd/commands/version.go @@ -1,3 +1,10 @@ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ package commands import ( diff --git a/cmd/server/app/cmd/options/options.go b/cmd/server/app/cmd/options/options.go index 7f1a6082..c5e51aa5 100644 --- a/cmd/server/app/cmd/options/options.go +++ b/cmd/server/app/cmd/options/options.go @@ -1,17 +1,10 @@ -/****************************************************************************** - * Copyright (c) KylinSoft Co., Ltd.2021-2022. All rights reserved. - * PilotGo is licensed under the Mulan PSL v2. - * You can use this software accodring to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN 'AS IS' BASIS, WITHOUT WARRANTIES OF ANY KIND, - * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - * See the Mulan PSL v2 for more details. - * Author: yangzhao1 - * Date: 2022-04-06 13:27:45 - * LastEditTime: 2023-09-04 16:16:36 - * Description: provide agent log manager of pilotgo - ******************************************************************************/ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ package options import ( diff --git a/cmd/server/app/config/config.go b/cmd/server/app/config/config.go index fe9e2ee8..47ae750d 100644 --- a/cmd/server/app/config/config.go +++ b/cmd/server/app/config/config.go @@ -1,17 +1,10 @@ -/****************************************************************************** - * Copyright (c) KylinSoft Co., Ltd.2021-2022. All rights reserved. - * PilotGo is licensed under the Mulan PSL v2. - * You can use this software accodring to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN 'AS IS' BASIS, WITHOUT WARRANTIES OF ANY KIND, - * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - * See the Mulan PSL v2 for more details. - * Author: yangzhao1 - * Date: 2022-04-06 13:27:45 - * LastEditTime: 2023-09-04 16:16:36 - * Description: provide agent log manager of pilotgo - ******************************************************************************/ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ package config import "gitee.com/openeuler/PilotGo/cmd/server/app/cmd/options" diff --git a/cmd/server/app/network/controller/agentcontroller/agent.go b/cmd/server/app/network/controller/agentcontroller/agent.go index f549a62a..b68a1c42 100644 --- a/cmd/server/app/network/controller/agentcontroller/agent.go +++ b/cmd/server/app/network/controller/agentcontroller/agent.go @@ -1,17 +1,10 @@ -/****************************************************************************** - * Copyright (c) KylinSoft Co., Ltd.2021-2022. All rights reserved. - * PilotGo is licensed under the Mulan PSL v2. - * You can use this software accodring to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - *     http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN 'AS IS' BASIS, WITHOUT WARRANTIES OF ANY KIND, - * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - * See the Mulan PSL v2 for more details. - * Author: zhanghan - * Date: 2022-01-24 15:08:08 - * LastEditTime: 2023-09-08 16:45:13 - * Description: Get the basic information of the machine - ******************************************************************************/ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ package agentcontroller import ( diff --git a/cmd/server/app/network/controller/agentcontroller/config.go b/cmd/server/app/network/controller/agentcontroller/config.go index 3e6bda84..2c60bdc1 100644 --- a/cmd/server/app/network/controller/agentcontroller/config.go +++ b/cmd/server/app/network/controller/agentcontroller/config.go @@ -1,3 +1,10 @@ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ package agentcontroller import ( diff --git a/cmd/server/app/network/controller/agentcontroller/cpu.go b/cmd/server/app/network/controller/agentcontroller/cpu.go index 87bcd90d..ca1e6695 100644 --- a/cmd/server/app/network/controller/agentcontroller/cpu.go +++ b/cmd/server/app/network/controller/agentcontroller/cpu.go @@ -1,17 +1,10 @@ -/****************************************************************************** - * Copyright (c) KylinSoft Co., Ltd.2021-2022. All rights reserved. - * PilotGo is licensed under the Mulan PSL v2. - * You can use this software accodring to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - *     http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN 'AS IS' BASIS, WITHOUT WARRANTIES OF ANY KIND, - * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - * See the Mulan PSL v2 for more details. - * Author: zhanghan - * Date: 2022-02-16 15:13:25 - * LastEditTime: 2022-04-13 15:51:43 - * Description: provide agent cpu manager functions. - ******************************************************************************/ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ package agentcontroller import ( diff --git a/cmd/server/app/network/controller/agentcontroller/cron.go b/cmd/server/app/network/controller/agentcontroller/cron.go index 69acd9d7..c8e42dc3 100644 --- a/cmd/server/app/network/controller/agentcontroller/cron.go +++ b/cmd/server/app/network/controller/agentcontroller/cron.go @@ -1,17 +1,10 @@ -/****************************************************************************** - * Copyright (c) KylinSoft Co., Ltd.2021-2022. All rights reserved. - * PilotGo is licensed under the Mulan PSL v2. - * You can use this software accodring to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - *     http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN 'AS IS' BASIS, WITHOUT WARRANTIES OF ANY KIND, - * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - * See the Mulan PSL v2 for more details. - * Author: zhanghan - * Date: 2022-05-23 10:25:52 - * LastEditTime: 2022-05-23 15:16:10 - * Description: os scheduled task - ******************************************************************************/ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ package agentcontroller import ( diff --git a/cmd/server/app/network/controller/agentcontroller/disk.go b/cmd/server/app/network/controller/agentcontroller/disk.go index 2d3d2497..6163d9c4 100644 --- a/cmd/server/app/network/controller/agentcontroller/disk.go +++ b/cmd/server/app/network/controller/agentcontroller/disk.go @@ -1,17 +1,10 @@ -/****************************************************************************** - * Copyright (c) KylinSoft Co., Ltd.2021-2022. All rights reserved. - * PilotGo is licensed under the Mulan PSL v2. - * You can use this software accodring to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - *     http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN 'AS IS' BASIS, WITHOUT WARRANTIES OF ANY KIND, - * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - * See the Mulan PSL v2 for more details. - * Author: zhanghan - * Date: 2022-02-16 15:13:25 - * LastEditTime: 2022-02-24 15:51:43 - * Description: provide agent disk manager functions. - ******************************************************************************/ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ package agentcontroller import ( diff --git a/cmd/server/app/network/controller/agentcontroller/file.go b/cmd/server/app/network/controller/agentcontroller/file.go index 3fb9306c..ecb7ac7e 100644 --- a/cmd/server/app/network/controller/agentcontroller/file.go +++ b/cmd/server/app/network/controller/agentcontroller/file.go @@ -1,18 +1,10 @@ -/****************************************************************************** - * Copyright (c) KylinSoft Co., Ltd.2021-2022. All rights reserved. - * PilotGo is licensed under the Mulan PSL v2. - * You can use this software accodring to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - *     http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN 'AS IS' BASIS, WITHOUT WARRANTIES OF ANY KIND, - * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - * See the Mulan PSL v2 for more details. - * Author: zhanghan - * Date: 2022-05-26 10:25:52 - * LastEditTime: 2023-07-11 19:25:23 - * Description: agent config file handler - ******************************************************************************/ - +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ package agentcontroller import ( diff --git a/cmd/server/app/network/controller/agentcontroller/firewall.go b/cmd/server/app/network/controller/agentcontroller/firewall.go index da1f4023..d11b5fdd 100644 --- a/cmd/server/app/network/controller/agentcontroller/firewall.go +++ b/cmd/server/app/network/controller/agentcontroller/firewall.go @@ -1,17 +1,10 @@ -/****************************************************************************** - * Copyright (c) KylinSoft Co., Ltd.2021-2022. All rights reserved. - * PilotGo is licensed under the Mulan PSL v2. - * You can use this software accodring to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - *     http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN 'AS IS' BASIS, WITHOUT WARRANTIES OF ANY KIND, - * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - * See the Mulan PSL v2 for more details. - * Author: zhanghan - * Date: 2022-02-17 02:43:29 - * LastEditTime: 2022-04-13 01:51:51 - * Description: provide agent firewall manager functions. - ******************************************************************************/ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ package agentcontroller import ( diff --git a/cmd/server/app/network/controller/agentcontroller/memory.go b/cmd/server/app/network/controller/agentcontroller/memory.go index 64ef3f42..9931e8b0 100644 --- a/cmd/server/app/network/controller/agentcontroller/memory.go +++ b/cmd/server/app/network/controller/agentcontroller/memory.go @@ -1,17 +1,10 @@ -/****************************************************************************** - * Copyright (c) KylinSoft Co., Ltd.2021-2022. All rights reserved. - * PilotGo is licensed under the Mulan PSL v2. - * You can use this software accodring to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - *     http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN 'AS IS' BASIS, WITHOUT WARRANTIES OF ANY KIND, - * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - * See the Mulan PSL v2 for more details. - * Author: zhanghan - * Date: 2022-02-17 02:43:29 - * LastEditTime: 2022-04-13 01:51:51 - * Description: provide agent memory manager functions. - ******************************************************************************/ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ package agentcontroller import ( diff --git a/cmd/server/app/network/controller/agentcontroller/network.go b/cmd/server/app/network/controller/agentcontroller/network.go index 2fa401f8..cdb336d2 100644 --- a/cmd/server/app/network/controller/agentcontroller/network.go +++ b/cmd/server/app/network/controller/agentcontroller/network.go @@ -1,17 +1,10 @@ -/****************************************************************************** - * Copyright (c) KylinSoft Co., Ltd.2021-2022. All rights reserved. - * PilotGo is licensed under the Mulan PSL v2. - * You can use this software accodring to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - *     http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN 'AS IS' BASIS, WITHOUT WARRANTIES OF ANY KIND, - * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - * See the Mulan PSL v2 for more details. - * Author: zhanghan - * Date: 2022-02-17 02:43:29 - * LastEditTime: 2023-02-21 16:01:22 - * Description: provide agent network manager functions. - ******************************************************************************/ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ package agentcontroller import ( diff --git a/cmd/server/app/network/controller/agentcontroller/os.go b/cmd/server/app/network/controller/agentcontroller/os.go index f89e8f82..44f2815e 100644 --- a/cmd/server/app/network/controller/agentcontroller/os.go +++ b/cmd/server/app/network/controller/agentcontroller/os.go @@ -1,17 +1,10 @@ -/****************************************************************************** - * Copyright (c) KylinSoft Co., Ltd.2021-2022. All rights reserved. - * PilotGo is licensed under the Mulan PSL v2. - * You can use this software accodring to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - *     http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN 'AS IS' BASIS, WITHOUT WARRANTIES OF ANY KIND, - * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - * See the Mulan PSL v2 for more details. - * Author: zhanghan - * Date: 2022-02-17 02:43:29 - * LastEditTime: 2022-04-13 01:51:51 - * Description: provide agent rpm manager functions. - ******************************************************************************/ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ package agentcontroller import ( diff --git a/cmd/server/app/network/controller/agentcontroller/rpm.go b/cmd/server/app/network/controller/agentcontroller/rpm.go index e77eac92..51563c4e 100644 --- a/cmd/server/app/network/controller/agentcontroller/rpm.go +++ b/cmd/server/app/network/controller/agentcontroller/rpm.go @@ -1,17 +1,10 @@ -/****************************************************************************** - * Copyright (c) KylinSoft Co., Ltd.2021-2022. All rights reserved. - * PilotGo is licensed under the Mulan PSL v2. - * You can use this software accodring to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - *     http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN 'AS IS' BASIS, WITHOUT WARRANTIES OF ANY KIND, - * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - * See the Mulan PSL v2 for more details. - * Author: zhanghan - * Date: 2022-02-17 02:43:29 - * LastEditTime: 2022-04-13 01:51:51 - * Description: provide agent rpm manager functions. - ******************************************************************************/ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ package agentcontroller import ( diff --git a/cmd/server/app/network/controller/agentcontroller/script.go b/cmd/server/app/network/controller/agentcontroller/script.go index ed907131..13f40649 100644 --- a/cmd/server/app/network/controller/agentcontroller/script.go +++ b/cmd/server/app/network/controller/agentcontroller/script.go @@ -1,99 +1,92 @@ -/****************************************************************************** - * Copyright (c) KylinSoft Co., Ltd.2021-2022. All rights reserved. - * PilotGo is licensed under the Mulan PSL v2. - * You can use this software accodring to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - *     http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN 'AS IS' BASIS, WITHOUT WARRANTIES OF ANY KIND, - * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - * See the Mulan PSL v2 for more details. - * Author: zhanghan - * Date: 2022-02-17 02:43:29 - * LastEditTime: 2022-04-20 15:51:51 - * Description: provide agent run script functions. - ******************************************************************************/ -package agentcontroller - -import ( - "regexp" - - "gitee.com/openeuler/PilotGo/cmd/server/app/agentmanager" - "gitee.com/openeuler/PilotGo/sdk/logger" - "gitee.com/openeuler/PilotGo/sdk/response" - "github.com/gin-gonic/gin" -) - -func RunCmd(c *gin.Context) { - logger.Debug("process get agent request") - // TODO: process agent info - uuid := c.Query("uuid") - cmd := c.Query("cmd") - - agent := agentmanager.GetAgent(uuid) - if agent != nil { - data, err := agent.RunCommand(cmd) - if err != nil { - logger.Error("run command error, agent:%s, cmd:%s", uuid, cmd) - response.Fail(c, gin.H{"status": false}, err.Error()) - } - logger.Info("run command on agent result:%v", data) - response.Success(c, nil, "run command success") - return - } - - logger.Info("unknown agent:%s", uuid) - response.Fail(c, gin.H{"status": false}, "unknown agent") -} - -func RunScriptWithBooleanCheck(c *gin.Context) { - logger.Debug("process get agent script request") - uuid := c.Query("uuid") - cmd := c.Query("cmd") - - // 调用检测高危命令 - if containsDangerousCommand(cmd) { - logger.Warn("Detected dangerous command") - response.Fail(c, gin.H{"status": false}, "Dangerous command detected in script.") - return - } - - agent := agentmanager.GetAgent(uuid) - if agent != nil { - data, err := agent.RunCommand(cmd) - if err != nil { - logger.Error("run script error, agent:%s, cmd:%s", uuid, cmd) - response.Fail(c, gin.H{"status": false}, err.Error()) - return - } - logger.Info("run script on agent result:%v", data) - response.Success(c, nil, "run script success") - return - } - - logger.Info("unknown agent:%s", uuid) - response.Fail(c, gin.H{"status": false}, "unknown agent") -} - -func containsDangerousCommand(content string) bool { - for _, pattern := range dangerousCommandsList { - matched, err := regexp.MatchString(pattern, content) - if err != nil { - logger.Error("Error matching pattern %s: %v\n", pattern, err) - // TODO - continue - } - if matched { - return true - } - } - return false -} - -var dangerousCommandsList = []string{ - `.*rm\s+-[r,f,rf].*`, - `.*lvremove\s+-f.*`, - `.*poweroff.*`, - `.*shutdown\s+-[f,F,h,k,n,r,t,C].*`, - `.*pvremove\s+-f.*`, - `.*vgremove\s+-f.*`, -} +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ +package agentcontroller + +import ( + "regexp" + + "gitee.com/openeuler/PilotGo/cmd/server/app/agentmanager" + "gitee.com/openeuler/PilotGo/sdk/logger" + "gitee.com/openeuler/PilotGo/sdk/response" + "github.com/gin-gonic/gin" +) + +func RunCmd(c *gin.Context) { + logger.Debug("process get agent request") + // TODO: process agent info + uuid := c.Query("uuid") + cmd := c.Query("cmd") + + agent := agentmanager.GetAgent(uuid) + if agent != nil { + data, err := agent.RunCommand(cmd) + if err != nil { + logger.Error("run command error, agent:%s, cmd:%s", uuid, cmd) + response.Fail(c, gin.H{"status": false}, err.Error()) + } + logger.Info("run command on agent result:%v", data) + response.Success(c, nil, "run command success") + return + } + + logger.Info("unknown agent:%s", uuid) + response.Fail(c, gin.H{"status": false}, "unknown agent") +} + +func RunScriptWithBooleanCheck(c *gin.Context) { + logger.Debug("process get agent script request") + uuid := c.Query("uuid") + cmd := c.Query("cmd") + + // 调用检测高危命令 + if containsDangerousCommand(cmd) { + logger.Warn("Detected dangerous command") + response.Fail(c, gin.H{"status": false}, "Dangerous command detected in script.") + return + } + + agent := agentmanager.GetAgent(uuid) + if agent != nil { + data, err := agent.RunCommand(cmd) + if err != nil { + logger.Error("run script error, agent:%s, cmd:%s", uuid, cmd) + response.Fail(c, gin.H{"status": false}, err.Error()) + return + } + logger.Info("run script on agent result:%v", data) + response.Success(c, nil, "run script success") + return + } + + logger.Info("unknown agent:%s", uuid) + response.Fail(c, gin.H{"status": false}, "unknown agent") +} + +func containsDangerousCommand(content string) bool { + for _, pattern := range dangerousCommandsList { + matched, err := regexp.MatchString(pattern, content) + if err != nil { + logger.Error("Error matching pattern %s: %v\n", pattern, err) + // TODO + continue + } + if matched { + return true + } + } + return false +} + +var dangerousCommandsList = []string{ + `.*rm\s+-[r,f,rf].*`, + `.*lvremove\s+-f.*`, + `.*poweroff.*`, + `.*shutdown\s+-[f,F,h,k,n,r,t,C].*`, + `.*pvremove\s+-f.*`, + `.*vgremove\s+-f.*`, +} diff --git a/cmd/server/app/network/controller/agentcontroller/service.go b/cmd/server/app/network/controller/agentcontroller/service.go index b93d742c..e0eb2df4 100644 --- a/cmd/server/app/network/controller/agentcontroller/service.go +++ b/cmd/server/app/network/controller/agentcontroller/service.go @@ -1,17 +1,10 @@ -/****************************************************************************** - * Copyright (c) KylinSoft Co., Ltd.2021-2022. All rights reserved. - * PilotGo is licensed under the Mulan PSL v2. - * You can use this software accodring to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - *     http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN 'AS IS' BASIS, WITHOUT WARRANTIES OF ANY KIND, - * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - * See the Mulan PSL v2 for more details. - * Author: zhanghan - * Date: 2022-02-16 09:28:46 - * LastEditTime: 2022-04-11 17:07:55 - * Description: provide agent service manager functions. - ******************************************************************************/ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ package agentcontroller import ( diff --git a/cmd/server/app/network/controller/agentcontroller/sysctl.go b/cmd/server/app/network/controller/agentcontroller/sysctl.go index b4d077fb..45fe4c92 100644 --- a/cmd/server/app/network/controller/agentcontroller/sysctl.go +++ b/cmd/server/app/network/controller/agentcontroller/sysctl.go @@ -1,17 +1,10 @@ -/****************************************************************************** - * Copyright (c) KylinSoft Co., Ltd.2021-2022. All rights reserved. - * PilotGo is licensed under the Mulan PSL v2. - * You can use this software accodring to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - *     http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN 'AS IS' BASIS, WITHOUT WARRANTIES OF ANY KIND, - * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - * See the Mulan PSL v2 for more details. - * Author: zhanghan - * Date: 2022-02-16 09:28:46 - * LastEditTime: 2022-03-25 02:00:34 - * Description: provide Kernel configuration. - ******************************************************************************/ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ package agentcontroller import ( diff --git a/cmd/server/app/network/controller/agentcontroller/timecompare.go b/cmd/server/app/network/controller/agentcontroller/timecompare.go index 9d2628c2..3700aada 100644 --- a/cmd/server/app/network/controller/agentcontroller/timecompare.go +++ b/cmd/server/app/network/controller/agentcontroller/timecompare.go @@ -1,3 +1,10 @@ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 +*/ package agentcontroller import ( diff --git a/cmd/server/app/network/controller/agentcontroller/user.go b/cmd/server/app/network/controller/agentcontroller/user.go index b5687296..91bee7e4 100644 --- a/cmd/server/app/network/controller/agentcontroller/user.go +++ b/cmd/server/app/network/controller/agentcontroller/user.go @@ -1,17 +1,10 @@ -/****************************************************************************** - * Copyright (c) KylinSoft Co., Ltd.2021-2022. All rights reserved. - * PilotGo is licensed under the Mulan PSL v2. - * You can use this software accodring to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - *     http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN 'AS IS' BASIS, WITHOUT WARRANTIES OF ANY KIND, - * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - * See the Mulan PSL v2 for more details. - * Author: zhanghan - * Date: 2022-02-17 02:43:29 - * LastEditTime: 2022-02-24 14:32:25 - * Description: provide agent user manager functions. - ******************************************************************************/ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ package agentcontroller import ( diff --git a/cmd/server/app/network/controller/auditloghandler.go b/cmd/server/app/network/controller/auditloghandler.go index 58491476..c0e5887e 100644 --- a/cmd/server/app/network/controller/auditloghandler.go +++ b/cmd/server/app/network/controller/auditloghandler.go @@ -1,84 +1,77 @@ -/****************************************************************************** - * Copyright (c) KylinSoft Co., Ltd.2021-2022. All rights reserved. - * PilotGo is licensed under the Mulan PSL v2. - * You can use this software accodring to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - *     http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN 'AS IS' BASIS, WITHOUT WARRANTIES OF ANY KIND, - * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - * See the Mulan PSL v2 for more details. - * Author: zhanghan - * Date: 2022-02-23 17:44:00 - * LastEditTime: 2022-03-24 00:18:14 - * Description: provide agent log manager functions. - ******************************************************************************/ -package controller - -import ( - "gitee.com/openeuler/PilotGo/cmd/server/app/service/auditlog" - "gitee.com/openeuler/PilotGo/cmd/server/app/service/common" - "gitee.com/openeuler/PilotGo/sdk/response" - "github.com/gin-gonic/gin" -) - -// 查询所有审计日志 -func AuditLogAllHandler(c *gin.Context) { - query := &common.PaginationQ{} - err := c.ShouldBindQuery(query) - if err != nil { - response.Fail(c, gin.H{"status": false}, err.Error()) - return - } - - num := query.Size * (query.CurrentPageNum - 1) - total, data, err := auditlog.GetAuditLogPaged(num, query.Size) - if err != nil { - response.Fail(c, gin.H{"status": false}, err.Error()) - return - } - common.JsonPagination(c, data, total, query) -} - -// 根据模块名字查询日志 -func ModuleLogHandler(c *gin.Context) { - var moduleName string - if c.Bind(&moduleName) != nil { - response.Fail(c, nil, "parameter error") - return - } - loglist, err := auditlog.GetByModule(moduleName) - if err != nil { - response.Fail(c, gin.H{"status": false}, err.Error()) - return - } - response.Success(c, loglist, "模块审计日志查询成功!") -} - -// 查询所有父日志为空的日志 -func LogAllHandler(c *gin.Context) { - query := &common.PaginationQ{} - err := c.ShouldBindQuery(query) - if err != nil { - response.Fail(c, gin.H{"status": false}, err.Error()) - return - } - - num := query.Size * (query.CurrentPageNum - 1) - total, data, err := auditlog.GetParentLog(num, query.Size) - if err != nil { - response.Fail(c, gin.H{"status": false}, err.Error()) - return - } - common.JsonPagination(c, data, total, query) -} - -// 查询其子日志 -func GetAuditLogByIdHandler(c *gin.Context) { - parent_uuid := c.Query("uuid") - data, err := auditlog.GetAuditLogById(parent_uuid) - if err != nil { - response.Fail(c, nil, err.Error()) - return - } - response.Success(c, data, "审计子日志查询成功!") -} +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ +package controller + +import ( + "gitee.com/openeuler/PilotGo/cmd/server/app/service/auditlog" + "gitee.com/openeuler/PilotGo/cmd/server/app/service/common" + "gitee.com/openeuler/PilotGo/sdk/response" + "github.com/gin-gonic/gin" +) + +// 查询所有审计日志 +func AuditLogAllHandler(c *gin.Context) { + query := &common.PaginationQ{} + err := c.ShouldBindQuery(query) + if err != nil { + response.Fail(c, gin.H{"status": false}, err.Error()) + return + } + + num := query.Size * (query.CurrentPageNum - 1) + total, data, err := auditlog.GetAuditLogPaged(num, query.Size) + if err != nil { + response.Fail(c, gin.H{"status": false}, err.Error()) + return + } + common.JsonPagination(c, data, total, query) +} + +// 根据模块名字查询日志 +func ModuleLogHandler(c *gin.Context) { + var moduleName string + if c.Bind(&moduleName) != nil { + response.Fail(c, nil, "parameter error") + return + } + loglist, err := auditlog.GetByModule(moduleName) + if err != nil { + response.Fail(c, gin.H{"status": false}, err.Error()) + return + } + response.Success(c, loglist, "模块审计日志查询成功!") +} + +// 查询所有父日志为空的日志 +func LogAllHandler(c *gin.Context) { + query := &common.PaginationQ{} + err := c.ShouldBindQuery(query) + if err != nil { + response.Fail(c, gin.H{"status": false}, err.Error()) + return + } + + num := query.Size * (query.CurrentPageNum - 1) + total, data, err := auditlog.GetParentLog(num, query.Size) + if err != nil { + response.Fail(c, gin.H{"status": false}, err.Error()) + return + } + common.JsonPagination(c, data, total, query) +} + +// 查询其子日志 +func GetAuditLogByIdHandler(c *gin.Context) { + parent_uuid := c.Query("uuid") + data, err := auditlog.GetAuditLogById(parent_uuid) + if err != nil { + response.Fail(c, nil, err.Error()) + return + } + response.Success(c, data, "审计子日志查询成功!") +} diff --git a/cmd/server/app/network/controller/batch.go b/cmd/server/app/network/controller/batch.go index 0ba8f353..6391e7fc 100644 --- a/cmd/server/app/network/controller/batch.go +++ b/cmd/server/app/network/controller/batch.go @@ -1,177 +1,184 @@ -package controller - -import ( - "strconv" - - "gitee.com/openeuler/PilotGo/cmd/server/app/network/jwt" - "gitee.com/openeuler/PilotGo/cmd/server/app/service/auditlog" - "gitee.com/openeuler/PilotGo/cmd/server/app/service/batch" - "gitee.com/openeuler/PilotGo/cmd/server/app/service/common" - "gitee.com/openeuler/PilotGo/pkg/utils/message/net" - "gitee.com/openeuler/PilotGo/sdk/response" - "github.com/gin-gonic/gin" - "github.com/google/uuid" -) - -// 添加批次 -func CreateBatchHandler(c *gin.Context) { - params := &batch.CreateBatchParam{} - if err := c.Bind(params); err != nil { - response.Fail(c, nil, net.GetValidMsg(err, params)) - return - } - - u, err := jwt.ParseUser(c) - if err != nil { - response.Fail(c, nil, "user token error:"+err.Error()) - return - } - log := &auditlog.AuditLog{ - LogUUID: uuid.New().String(), - ParentUUID: "", - Module: auditlog.ModuleBatch, - Status: auditlog.StatusOK, - UserID: u.ID, - Action: "创建批次", - } - auditlog.Add(log) - params.Manager = u.Email - - if err := batch.CreateBatch(params); err != nil { - auditlog.UpdateStatus(log, auditlog.StatusFailed) - response.Fail(c, nil, err.Error()) - return - } - response.Success(c, nil, "批次入库成功") -} - -// 分页查询所有批次 -func BatchInfoHandler(c *gin.Context) { - p := &common.PaginationQ{} - err := c.ShouldBindQuery(p) - if err != nil { - response.Fail(c, gin.H{"status": false}, err.Error()) - return - } - - num := p.Size * (p.CurrentPageNum - 1) - total, data, err := batch.GetBatchPaged(num, p.Size) - if err != nil { - response.Fail(c, gin.H{"status": false}, err.Error()) - return - } - common.JsonPagination(c, data, total, p) -} - -// 删除批次 -func DeleteBatchHandler(c *gin.Context) { - batchdel := struct { - BatchID []int `json:"BatchID"` - }{} - if err := c.Bind(&batchdel); err != nil { - response.Fail(c, nil, "parameter error") - return - } - if len(batchdel.BatchID) == 0 { - response.Fail(c, nil, "请输入删除批次ID") - return - } - - u, err := jwt.ParseUser(c) - if err != nil { - response.Fail(c, nil, "user token error:"+err.Error()) - return - } - log := &auditlog.AuditLog{ - LogUUID: uuid.New().String(), - ParentUUID: "", - Module: auditlog.ModuleBatch, - Status: auditlog.StatusOK, - UserID: u.ID, - Action: "删除批次", - } - auditlog.Add(log) - - if err := batch.DeleteBatch(batchdel.BatchID); err != nil { - auditlog.UpdateStatus(log, auditlog.StatusFailed) - response.Fail(c, gin.H{"status": false}, err.Error()) - return - } - response.Success(c, nil, "批次删除成功") -} - -// 更改批次 -func UpdateBatchHandler(c *gin.Context) { - batchinfo := struct { - BatchId int `json:"BatchID"` - BatchName string `json:"BatchName"` - Description string `json:"Description"` - }{} - if err := c.Bind(&batchinfo); err != nil { - response.Fail(c, nil, "parameter error") - return - } - - u, err := jwt.ParseUser(c) - if err != nil { - response.Fail(c, nil, "user token error:"+err.Error()) - return - } - log := &auditlog.AuditLog{ - LogUUID: uuid.New().String(), - ParentUUID: "", - Module: auditlog.ModuleBatch, - Status: auditlog.StatusOK, - UserID: u.ID, - Action: "编辑批次", - } - auditlog.Add(log) - - err = batch.UpdateBatch(batchinfo.BatchId, batchinfo.BatchName, batchinfo.Description) - if err != nil { - auditlog.UpdateStatus(log, auditlog.StatusFailed) - response.Fail(c, gin.H{"status": false}, "update batch failed: "+err.Error()) - return - } - response.Success(c, nil, "批次修改成功") -} - -// 查询某一个批次 -func BatchMachineInfoHandler(c *gin.Context) { - p := &common.PaginationQ{} - err := c.ShouldBindQuery(p) - if err != nil { - response.Fail(c, gin.H{"status": false}, err.Error()) - return - } - - Batchid := c.Query("ID") - batchid, err := strconv.Atoi(Batchid) - if err != nil { - response.Fail(c, nil, "批次ID输入格式有误") - return - } - - num := p.Size * (p.CurrentPageNum - 1) - total, data, err := batch.GetBatchMachines(num, p.Size, batchid) - if err != nil { - response.Fail(c, gin.H{"status": false}, err.Error()) - return - } - common.JsonPagination(c, data, total, p) -} - -// 一次性获取素有批次,供下拉列表选择 -func SelectBatchHandler(c *gin.Context) { - batch, err := batch.SelectBatch() - if err != nil { - response.Fail(c, nil, "获取批次信息错误"+err.Error()) - return - } - - if len(batch) == 0 { - response.Fail(c, nil, "未获取到批次信息") - return - } - response.Success(c, gin.H{"data": batch}, "批次信息获取成功") -} +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ +package controller + +import ( + "strconv" + + "gitee.com/openeuler/PilotGo/cmd/server/app/network/jwt" + "gitee.com/openeuler/PilotGo/cmd/server/app/service/auditlog" + "gitee.com/openeuler/PilotGo/cmd/server/app/service/batch" + "gitee.com/openeuler/PilotGo/cmd/server/app/service/common" + "gitee.com/openeuler/PilotGo/pkg/utils/message/net" + "gitee.com/openeuler/PilotGo/sdk/response" + "github.com/gin-gonic/gin" + "github.com/google/uuid" +) + +// 添加批次 +func CreateBatchHandler(c *gin.Context) { + params := &batch.CreateBatchParam{} + if err := c.Bind(params); err != nil { + response.Fail(c, nil, net.GetValidMsg(err, params)) + return + } + + u, err := jwt.ParseUser(c) + if err != nil { + response.Fail(c, nil, "user token error:"+err.Error()) + return + } + log := &auditlog.AuditLog{ + LogUUID: uuid.New().String(), + ParentUUID: "", + Module: auditlog.ModuleBatch, + Status: auditlog.StatusOK, + UserID: u.ID, + Action: "创建批次", + } + auditlog.Add(log) + params.Manager = u.Email + + if err := batch.CreateBatch(params); err != nil { + auditlog.UpdateStatus(log, auditlog.StatusFailed) + response.Fail(c, nil, err.Error()) + return + } + response.Success(c, nil, "批次入库成功") +} + +// 分页查询所有批次 +func BatchInfoHandler(c *gin.Context) { + p := &common.PaginationQ{} + err := c.ShouldBindQuery(p) + if err != nil { + response.Fail(c, gin.H{"status": false}, err.Error()) + return + } + + num := p.Size * (p.CurrentPageNum - 1) + total, data, err := batch.GetBatchPaged(num, p.Size) + if err != nil { + response.Fail(c, gin.H{"status": false}, err.Error()) + return + } + common.JsonPagination(c, data, total, p) +} + +// 删除批次 +func DeleteBatchHandler(c *gin.Context) { + batchdel := struct { + BatchID []int `json:"BatchID"` + }{} + if err := c.Bind(&batchdel); err != nil { + response.Fail(c, nil, "parameter error") + return + } + if len(batchdel.BatchID) == 0 { + response.Fail(c, nil, "请输入删除批次ID") + return + } + + u, err := jwt.ParseUser(c) + if err != nil { + response.Fail(c, nil, "user token error:"+err.Error()) + return + } + log := &auditlog.AuditLog{ + LogUUID: uuid.New().String(), + ParentUUID: "", + Module: auditlog.ModuleBatch, + Status: auditlog.StatusOK, + UserID: u.ID, + Action: "删除批次", + } + auditlog.Add(log) + + if err := batch.DeleteBatch(batchdel.BatchID); err != nil { + auditlog.UpdateStatus(log, auditlog.StatusFailed) + response.Fail(c, gin.H{"status": false}, err.Error()) + return + } + response.Success(c, nil, "批次删除成功") +} + +// 更改批次 +func UpdateBatchHandler(c *gin.Context) { + batchinfo := struct { + BatchId int `json:"BatchID"` + BatchName string `json:"BatchName"` + Description string `json:"Description"` + }{} + if err := c.Bind(&batchinfo); err != nil { + response.Fail(c, nil, "parameter error") + return + } + + u, err := jwt.ParseUser(c) + if err != nil { + response.Fail(c, nil, "user token error:"+err.Error()) + return + } + log := &auditlog.AuditLog{ + LogUUID: uuid.New().String(), + ParentUUID: "", + Module: auditlog.ModuleBatch, + Status: auditlog.StatusOK, + UserID: u.ID, + Action: "编辑批次", + } + auditlog.Add(log) + + err = batch.UpdateBatch(batchinfo.BatchId, batchinfo.BatchName, batchinfo.Description) + if err != nil { + auditlog.UpdateStatus(log, auditlog.StatusFailed) + response.Fail(c, gin.H{"status": false}, "update batch failed: "+err.Error()) + return + } + response.Success(c, nil, "批次修改成功") +} + +// 查询某一个批次 +func BatchMachineInfoHandler(c *gin.Context) { + p := &common.PaginationQ{} + err := c.ShouldBindQuery(p) + if err != nil { + response.Fail(c, gin.H{"status": false}, err.Error()) + return + } + + Batchid := c.Query("ID") + batchid, err := strconv.Atoi(Batchid) + if err != nil { + response.Fail(c, nil, "批次ID输入格式有误") + return + } + + num := p.Size * (p.CurrentPageNum - 1) + total, data, err := batch.GetBatchMachines(num, p.Size, batchid) + if err != nil { + response.Fail(c, gin.H{"status": false}, err.Error()) + return + } + common.JsonPagination(c, data, total, p) +} + +// 一次性获取素有批次,供下拉列表选择 +func SelectBatchHandler(c *gin.Context) { + batch, err := batch.SelectBatch() + if err != nil { + response.Fail(c, nil, "获取批次信息错误"+err.Error()) + return + } + + if len(batch) == 0 { + response.Fail(c, nil, "未获取到批次信息") + return + } + response.Success(c, gin.H{"data": batch}, "批次信息获取成功") +} diff --git a/cmd/server/app/network/controller/cluster.go b/cmd/server/app/network/controller/cluster.go index b3159900..46010e57 100644 --- a/cmd/server/app/network/controller/cluster.go +++ b/cmd/server/app/network/controller/cluster.go @@ -1,17 +1,10 @@ -/****************************************************************************** - * Copyright (c) KylinSoft Co., Ltd.2021-2022. All rights reserved. - * PilotGo is licensed under the Mulan PSL v2. - * You can use this software accodring to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - *     http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN 'AS IS' BASIS, WITHOUT WARRANTIES OF ANY KIND, - * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - * See the Mulan PSL v2 for more details. - * Author: zhanghan - * Date: 2022-03-24 00:46:05 - * LastEditTime: 2022-04-29 11:29:44 - * Description: 集群概览 - ******************************************************************************/ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ package controller import ( diff --git a/cmd/server/app/network/controller/config.go b/cmd/server/app/network/controller/config.go index 7ab8cdd9..6ee4862b 100644 --- a/cmd/server/app/network/controller/config.go +++ b/cmd/server/app/network/controller/config.go @@ -1,17 +1,10 @@ -/****************************************************************************** - * Copyright (c) KylinSoft Co., Ltd.2021-2022. All rights reserved. - * PilotGo is licensed under the Mulan PSL v2. - * You can use this software accodring to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - *     http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN 'AS IS' BASIS, WITHOUT WARRANTIES OF ANY KIND, - * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - * See the Mulan PSL v2 for more details. - * Author: zhanghan - * Date: 2022-06-16 10:25:52 - * LastEditTime: 2022-06-16 16:16:10 - * Description: file info handler - ******************************************************************************/ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ package controller import ( diff --git a/cmd/server/app/network/controller/depart.go b/cmd/server/app/network/controller/depart.go index b58067bc..d01fa250 100644 --- a/cmd/server/app/network/controller/depart.go +++ b/cmd/server/app/network/controller/depart.go @@ -1,178 +1,171 @@ -/****************************************************************************** - * Copyright (c) KylinSoft Co., Ltd.2021-2022. All rights reserved. - * PilotGo is licensed under the Mulan PSL v2. - * You can use this software accodring to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - *     http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN 'AS IS' BASIS, WITHOUT WARRANTIES OF ANY KIND, - * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - * See the Mulan PSL v2 for more details. - * Author: zhanghan - * Date: 2022-06-02 10:25:52 - * LastEditTime: 2022-06-08 16:16:10 - * Description: depart info handler - ******************************************************************************/ -package controller - -import ( - "strconv" - - "gitee.com/openeuler/PilotGo/cmd/server/app/network/jwt" - "gitee.com/openeuler/PilotGo/cmd/server/app/service/auditlog" - "gitee.com/openeuler/PilotGo/cmd/server/app/service/depart" - "gitee.com/openeuler/PilotGo/pkg/utils/message/net" - "gitee.com/openeuler/PilotGo/sdk/response" - "github.com/gin-gonic/gin" - "github.com/google/uuid" -) - -type NewDepart struct { - DepartID int `json:"DepartID" binding:"required" msg:"部门id不能为空"` - DepartName string `json:"DepartName" binding:"required" msg:"部门名称不能为空"` -} - -// 获取部门下所有机器列表,若想获取根节点部门,传入departid=1 -func MachineListHandler(c *gin.Context) { - DepartId := c.Query("DepartId") - DepId, err := strconv.Atoi(DepartId) - if err != nil { - response.Fail(c, nil, "参数错误") - return - } - - machinelist, err := depart.MachineList(DepId) - if err != nil { - response.Fail(c, nil, err.Error()) - return - } - response.Success(c, machinelist, "部门下所属机器获取成功") -} - -// 根据部门id在部门树中查询部门节点 -func DepartHandler(c *gin.Context) { - departID := c.Query("DepartID") - tmp, err := strconv.Atoi(departID) - if err != nil { - response.Fail(c, nil, "部门ID有误") - return - } - //构造部门树 - departRoot, err := depart.DepartInfo() - if err != nil { - response.Fail(c, nil, err.Error()) - return - } - //查询节点 - node, err := depart.Dept(tmp, departRoot) - if err != nil { - response.Fail(c, nil, err.Error()) - return - } - response.Success(c, node, "获取当前部门及子部门信息") -} - -// 生成部门树 -func DepartInfoHandler(c *gin.Context) { - departRoot, err := depart.DepartInfo() - if err != nil { - response.Fail(c, nil, err.Error()) - return - } - response.Success(c, departRoot, "获取全部的部门信息") -} - -// 添加部门节点 -func AddDepartHandler(c *gin.Context) { - newDepart := depart.AddDepartNode{} - if err := c.Bind(&newDepart); err != nil { - response.Fail(c, nil, net.GetValidMsg(err, &newDepart)) - return - } - - u, err := jwt.ParseUser(c) - if err != nil { - response.Fail(c, nil, "user token error:"+err.Error()) - return - } - log := &auditlog.AuditLog{ - LogUUID: uuid.New().String(), - ParentUUID: "", - Module: auditlog.ModuleDepart, - Status: auditlog.StatusOK, - UserID: u.ID, - Action: "添加部门信息", - } - auditlog.Add(log) - - err = depart.AddDepart(&newDepart) - if err != nil { - auditlog.UpdateStatus(log, auditlog.StatusFailed) - response.Fail(c, nil, err.Error()) - return - } - response.Success(c, nil, "部门信息入库成功") -} - -// 删除部门节点 -func DeleteDepartDataHandler(c *gin.Context) { - var DelDept depart.DeleteDeparts - if err := c.Bind(&DelDept); err != nil { - response.Fail(c, nil, "parameter error") - return - } - - u, err := jwt.ParseUser(c) - if err != nil { - response.Fail(c, nil, "user token error:"+err.Error()) - return - } - log := &auditlog.AuditLog{ - LogUUID: uuid.New().String(), - ParentUUID: "", - Module: auditlog.ModuleDepart, - Status: auditlog.StatusOK, - UserID: u.ID, - Action: "删除部门信息", - } - auditlog.Add(log) - - err = depart.DeleteDepart(&DelDept) - if err != nil { - auditlog.UpdateStatus(log, auditlog.StatusFailed) - response.Fail(c, nil, err.Error()) - return - } - response.Success(c, nil, "部门删除成功") -} - -// 更改部门节点名字 -func UpdateDepartHandler(c *gin.Context) { - var new NewDepart - if err := c.Bind(&new); err != nil { - response.Fail(c, nil, net.GetValidMsg(err, &new)) - return - } - - u, err := jwt.ParseUser(c) - if err != nil { - response.Fail(c, nil, "user token error:"+err.Error()) - return - } - log := &auditlog.AuditLog{ - LogUUID: uuid.New().String(), - ParentUUID: "", - Module: auditlog.ModuleDepart, - Status: auditlog.StatusOK, - UserID: u.ID, - Action: "修改部门信息", - } - auditlog.Add(log) - - err = depart.UpdateDepart(new.DepartID, new.DepartName) - if err != nil { - auditlog.UpdateStatus(log, auditlog.StatusFailed) - response.Fail(c, nil, err.Error()) - return - } - response.Success(c, nil, "部门更新成功") -} +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ +package controller + +import ( + "strconv" + + "gitee.com/openeuler/PilotGo/cmd/server/app/network/jwt" + "gitee.com/openeuler/PilotGo/cmd/server/app/service/auditlog" + "gitee.com/openeuler/PilotGo/cmd/server/app/service/depart" + "gitee.com/openeuler/PilotGo/pkg/utils/message/net" + "gitee.com/openeuler/PilotGo/sdk/response" + "github.com/gin-gonic/gin" + "github.com/google/uuid" +) + +type NewDepart struct { + DepartID int `json:"DepartID" binding:"required" msg:"部门id不能为空"` + DepartName string `json:"DepartName" binding:"required" msg:"部门名称不能为空"` +} + +// 获取部门下所有机器列表,若想获取根节点部门,传入departid=1 +func MachineListHandler(c *gin.Context) { + DepartId := c.Query("DepartId") + DepId, err := strconv.Atoi(DepartId) + if err != nil { + response.Fail(c, nil, "参数错误") + return + } + + machinelist, err := depart.MachineList(DepId) + if err != nil { + response.Fail(c, nil, err.Error()) + return + } + response.Success(c, machinelist, "部门下所属机器获取成功") +} + +// 根据部门id在部门树中查询部门节点 +func DepartHandler(c *gin.Context) { + departID := c.Query("DepartID") + tmp, err := strconv.Atoi(departID) + if err != nil { + response.Fail(c, nil, "部门ID有误") + return + } + //构造部门树 + departRoot, err := depart.DepartInfo() + if err != nil { + response.Fail(c, nil, err.Error()) + return + } + //查询节点 + node, err := depart.Dept(tmp, departRoot) + if err != nil { + response.Fail(c, nil, err.Error()) + return + } + response.Success(c, node, "获取当前部门及子部门信息") +} + +// 生成部门树 +func DepartInfoHandler(c *gin.Context) { + departRoot, err := depart.DepartInfo() + if err != nil { + response.Fail(c, nil, err.Error()) + return + } + response.Success(c, departRoot, "获取全部的部门信息") +} + +// 添加部门节点 +func AddDepartHandler(c *gin.Context) { + newDepart := depart.AddDepartNode{} + if err := c.Bind(&newDepart); err != nil { + response.Fail(c, nil, net.GetValidMsg(err, &newDepart)) + return + } + + u, err := jwt.ParseUser(c) + if err != nil { + response.Fail(c, nil, "user token error:"+err.Error()) + return + } + log := &auditlog.AuditLog{ + LogUUID: uuid.New().String(), + ParentUUID: "", + Module: auditlog.ModuleDepart, + Status: auditlog.StatusOK, + UserID: u.ID, + Action: "添加部门信息", + } + auditlog.Add(log) + + err = depart.AddDepart(&newDepart) + if err != nil { + auditlog.UpdateStatus(log, auditlog.StatusFailed) + response.Fail(c, nil, err.Error()) + return + } + response.Success(c, nil, "部门信息入库成功") +} + +// 删除部门节点 +func DeleteDepartDataHandler(c *gin.Context) { + var DelDept depart.DeleteDeparts + if err := c.Bind(&DelDept); err != nil { + response.Fail(c, nil, "parameter error") + return + } + + u, err := jwt.ParseUser(c) + if err != nil { + response.Fail(c, nil, "user token error:"+err.Error()) + return + } + log := &auditlog.AuditLog{ + LogUUID: uuid.New().String(), + ParentUUID: "", + Module: auditlog.ModuleDepart, + Status: auditlog.StatusOK, + UserID: u.ID, + Action: "删除部门信息", + } + auditlog.Add(log) + + err = depart.DeleteDepart(&DelDept) + if err != nil { + auditlog.UpdateStatus(log, auditlog.StatusFailed) + response.Fail(c, nil, err.Error()) + return + } + response.Success(c, nil, "部门删除成功") +} + +// 更改部门节点名字 +func UpdateDepartHandler(c *gin.Context) { + var new NewDepart + if err := c.Bind(&new); err != nil { + response.Fail(c, nil, net.GetValidMsg(err, &new)) + return + } + + u, err := jwt.ParseUser(c) + if err != nil { + response.Fail(c, nil, "user token error:"+err.Error()) + return + } + log := &auditlog.AuditLog{ + LogUUID: uuid.New().String(), + ParentUUID: "", + Module: auditlog.ModuleDepart, + Status: auditlog.StatusOK, + UserID: u.ID, + Action: "修改部门信息", + } + auditlog.Add(log) + + err = depart.UpdateDepart(new.DepartID, new.DepartName) + if err != nil { + auditlog.UpdateStatus(log, auditlog.StatusFailed) + response.Fail(c, nil, err.Error()) + return + } + response.Success(c, nil, "部门更新成功") +} diff --git a/cmd/server/app/network/controller/fileservice.go b/cmd/server/app/network/controller/fileservice.go index 014a9a28..876c7e1e 100644 --- a/cmd/server/app/network/controller/fileservice.go +++ b/cmd/server/app/network/controller/fileservice.go @@ -1,3 +1,10 @@ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ package controller import ( diff --git a/cmd/server/app/network/controller/machine.go b/cmd/server/app/network/controller/machine.go index 56cff788..2b60922d 100644 --- a/cmd/server/app/network/controller/machine.go +++ b/cmd/server/app/network/controller/machine.go @@ -1,17 +1,10 @@ -/****************************************************************************** - * Copyright (c) KylinSoft Co., Ltd.2021-2022. All rights reserved. - * PilotGo is licensed under the Mulan PSL v2. - * You can use this software accodring to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - *     http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN 'AS IS' BASIS, WITHOUT WARRANTIES OF ANY KIND, - * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - * See the Mulan PSL v2 for more details. - * Author: wanghao - * Date: 2022-02-18 13:03:16 - * LastEditTime: 2022-06-08 09:58:35 - * Description: provide machine manager functions. - ******************************************************************************/ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ package controller import ( diff --git a/cmd/server/app/network/controller/plugin.go b/cmd/server/app/network/controller/plugin.go index c27fe547..f6b1bb0d 100644 --- a/cmd/server/app/network/controller/plugin.go +++ b/cmd/server/app/network/controller/plugin.go @@ -1,3 +1,10 @@ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ package controller import ( diff --git a/cmd/server/app/network/controller/pluginWebsocketProxy.go b/cmd/server/app/network/controller/pluginWebsocketProxy.go index 23919b62..f50729ac 100644 --- a/cmd/server/app/network/controller/pluginWebsocketProxy.go +++ b/cmd/server/app/network/controller/pluginWebsocketProxy.go @@ -1,3 +1,10 @@ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: Wangjunqi123 + * Date: Fri Oct 25 16:02:57 2024 +0800 + */ package controller import ( diff --git a/cmd/server/app/network/controller/pluginapi/batch.go b/cmd/server/app/network/controller/pluginapi/batch.go index 5b79e0e3..a1eca821 100644 --- a/cmd/server/app/network/controller/pluginapi/batch.go +++ b/cmd/server/app/network/controller/pluginapi/batch.go @@ -1,3 +1,10 @@ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ package pluginapi import ( diff --git a/cmd/server/app/network/controller/pluginapi/config.go b/cmd/server/app/network/controller/pluginapi/config.go index 9cf1acea..5a33af96 100644 --- a/cmd/server/app/network/controller/pluginapi/config.go +++ b/cmd/server/app/network/controller/pluginapi/config.go @@ -1,3 +1,10 @@ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ package pluginapi import ( diff --git a/cmd/server/app/network/controller/pluginapi/machine.go b/cmd/server/app/network/controller/pluginapi/machine.go index 9c515576..0d2370fc 100644 --- a/cmd/server/app/network/controller/pluginapi/machine.go +++ b/cmd/server/app/network/controller/pluginapi/machine.go @@ -1,3 +1,10 @@ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ package pluginapi import ( diff --git a/cmd/server/app/network/controller/pluginapi/package.go b/cmd/server/app/network/controller/pluginapi/package.go index c1a2ced8..d273183e 100644 --- a/cmd/server/app/network/controller/pluginapi/package.go +++ b/cmd/server/app/network/controller/pluginapi/package.go @@ -1,3 +1,10 @@ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ package pluginapi import ( diff --git a/cmd/server/app/network/controller/pluginapi/plugin.go b/cmd/server/app/network/controller/pluginapi/plugin.go index a539998c..d827dda7 100644 --- a/cmd/server/app/network/controller/pluginapi/plugin.go +++ b/cmd/server/app/network/controller/pluginapi/plugin.go @@ -1,3 +1,10 @@ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ package pluginapi import ( diff --git a/cmd/server/app/network/controller/pluginapi/script.go b/cmd/server/app/network/controller/pluginapi/script.go index 39221d43..1431b93e 100644 --- a/cmd/server/app/network/controller/pluginapi/script.go +++ b/cmd/server/app/network/controller/pluginapi/script.go @@ -1,3 +1,10 @@ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ // 插件系统对外提供的api package pluginapi diff --git a/cmd/server/app/network/controller/pluginapi/service.go b/cmd/server/app/network/controller/pluginapi/service.go index 5a67bc7d..9634420f 100644 --- a/cmd/server/app/network/controller/pluginapi/service.go +++ b/cmd/server/app/network/controller/pluginapi/service.go @@ -1,3 +1,10 @@ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ package pluginapi import ( diff --git a/cmd/server/app/network/controller/pluginapi/tag.go b/cmd/server/app/network/controller/pluginapi/tag.go index 326ca3fa..efec840e 100644 --- a/cmd/server/app/network/controller/pluginapi/tag.go +++ b/cmd/server/app/network/controller/pluginapi/tag.go @@ -1,3 +1,10 @@ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ package pluginapi import ( diff --git a/cmd/server/app/network/controller/pushalarm.go b/cmd/server/app/network/controller/pushalarm.go index 8b70bf05..6c623d17 100644 --- a/cmd/server/app/network/controller/pushalarm.go +++ b/cmd/server/app/network/controller/pushalarm.go @@ -1,18 +1,10 @@ -/****************************************************************************** - * Copyright (c) KylinSoft Co., Ltd.2021-2022. All rights reserved. - * PilotGo is licensed under the Mulan PSL v2. - * You can use this software accodring to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - *     http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN 'AS IS' BASIS, WITHOUT WARRANTIES OF ANY KIND, - * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - * See the Mulan PSL v2 for more details. - * Author: zhanghan - * Date: 2022-06-24 10:48:55 - * LastEditTime: 2022-06-24 16:48:55 - * Description: 通过web socket方式推送告警 - ******************************************************************************/ - +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ package controller import ( diff --git a/cmd/server/app/network/controller/role.go b/cmd/server/app/network/controller/role.go index 706d5729..ee9078e0 100644 --- a/cmd/server/app/network/controller/role.go +++ b/cmd/server/app/network/controller/role.go @@ -1,200 +1,193 @@ -/****************************************************************************** - * Copyright (c) KylinSoft Co., Ltd.2021-2022. All rights reserved. - * PilotGo is licensed under the Mulan PSL v2. - * You can use this software accodring to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - *     http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN 'AS IS' BASIS, WITHOUT WARRANTIES OF ANY KIND, - * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - * See the Mulan PSL v2 for more details. - * Author: zhanghan - * Date: 2022-03-07 15:32:38 - * LastEditTime: 2022-04-12 14:10:09 - * Description: 权限控制 - ******************************************************************************/ -package controller - -import ( - "gitee.com/openeuler/PilotGo/cmd/server/app/network/jwt" - "gitee.com/openeuler/PilotGo/cmd/server/app/service/auditlog" - "gitee.com/openeuler/PilotGo/cmd/server/app/service/common" - "gitee.com/openeuler/PilotGo/cmd/server/app/service/plugin" - roleservice "gitee.com/openeuler/PilotGo/cmd/server/app/service/role" - "gitee.com/openeuler/PilotGo/sdk/response" - "github.com/gin-gonic/gin" - "github.com/google/uuid" -) - -// 获取所有角色 -func GetRolesHandler(c *gin.Context) { - data, err := roleservice.GetRoles() - if err != nil { - response.Fail(c, gin.H{"status": false}, err.Error()) - return - } - response.Success(c, data, "角色权限列表") -} - -// 分页获取所有角色 -func GetRolesPagedHandler(c *gin.Context) { - p := &common.PaginationQ{} - err := c.ShouldBindQuery(p) - if err != nil { - response.Fail(c, gin.H{"status": false}, err.Error()) - return - } - - num := p.Size * (p.CurrentPageNum - 1) - total, data, err := roleservice.GetRolePaged(num, p.Size) - if err != nil { - response.Fail(c, gin.H{"status": false}, err.Error()) - return - } - common.JsonPagination(c, data, total, p) -} - -// 添加角色 -func AddRoleHandler(c *gin.Context) { - params := &struct { - Role string `json:"role"` - Description string `json:"description"` - }{} - if err := c.Bind(params); err != nil { - response.Fail(c, nil, "parameter error:"+err.Error()) - return - } - - u, err := jwt.ParseUser(c) - if err != nil { - response.Fail(c, nil, "user token error:"+err.Error()) - return - } - log := &auditlog.AuditLog{ - LogUUID: uuid.New().String(), - ParentUUID: "", - Module: auditlog.ModuleRole, - Status: auditlog.StatusOK, - UserID: u.ID, - Action: "添加角色", - } - auditlog.Add(log) - - userRole := &roleservice.Role{ - Name: params.Role, - Description: params.Description, - } - - err = roleservice.AddRole(userRole) - if err != nil { - auditlog.UpdateStatus(log, auditlog.StatusFailed) - response.Fail(c, nil, err.Error()) - return - } - response.Success(c, nil, "新增角色成功") -} - -// 删除角色 -func DeleteRoleHandler(c *gin.Context) { - params := &struct { - RoleId int `json:"role"` - }{} - if err := c.Bind(params); err != nil { - response.Fail(c, nil, "parameter error:"+err.Error()) - return - } - - u, err := jwt.ParseUser(c) - if err != nil { - response.Fail(c, nil, "user token error:"+err.Error()) - return - } - log := &auditlog.AuditLog{ - LogUUID: uuid.New().String(), - ParentUUID: "", - Module: auditlog.ModuleRole, - Status: auditlog.StatusOK, - UserID: u.ID, - Action: "删除角色", - } - auditlog.Add(log) - - err = roleservice.DeleteRole(params.RoleId) - if err != nil { - auditlog.UpdateStatus(log, auditlog.StatusFailed) - response.Fail(c, nil, "有用户绑定此角色,不可删除") - return - } - response.Success(c, nil, "角色删除成功") -} - -// 更改角色 -func UpdateRoleInfoHandler(c *gin.Context) { - params := &struct { - Role string `json:"role"` - Description string `json:"description"` - }{} - if err := c.Bind(params); err != nil { - response.Fail(c, nil, "parameter error:"+err.Error()) - return - } - - u, err := jwt.ParseUser(c) - if err != nil { - response.Fail(c, nil, "user token error:"+err.Error()) - return - } - log := &auditlog.AuditLog{ - LogUUID: uuid.New().String(), - ParentUUID: "", - Module: auditlog.ModuleRole, - Status: auditlog.StatusOK, - UserID: u.ID, - Action: "修改角色信息", - } - auditlog.Add(log) - - err = roleservice.UpdateRoleInfo(params.Role, params.Description) - if err != nil { - auditlog.UpdateStatus(log, auditlog.StatusFailed) - response.Fail(c, nil, err.Error()) - return - } - response.Success(c, nil, "角色信息修改成功") -} - -// 更改角色权限 -func RolePermissionChangeHandler(c *gin.Context) { - params := &struct { - Buttons []string `json:"buttons"` - Menus []string `json:"menus"` - Role string `json:"role"` - PluginPermissions []plugin.PluginPermission `json:"pluginpermissions"` - }{} - if err := c.Bind(params); err != nil { - response.Fail(c, nil, "parameter error:"+err.Error()) - return - } - - u, err := jwt.ParseUser(c) - if err != nil { - response.Fail(c, nil, "user token error:"+err.Error()) - return - } - log := &auditlog.AuditLog{ - LogUUID: uuid.New().String(), - ParentUUID: "", - Module: auditlog.ModuleRole, - Status: auditlog.StatusOK, - UserID: u.ID, - Action: "修改角色权限", - } - auditlog.Add(log) - - err = roleservice.UpdateRolePermissions(params.Role, params.Buttons, params.Menus, params.PluginPermissions) - if err != nil { - auditlog.UpdateStatus(log, auditlog.StatusFailed) - response.Fail(c, nil, err.Error()) - return - } - response.Success(c, nil, "角色权限变更成功") -} +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ +package controller + +import ( + "gitee.com/openeuler/PilotGo/cmd/server/app/network/jwt" + "gitee.com/openeuler/PilotGo/cmd/server/app/service/auditlog" + "gitee.com/openeuler/PilotGo/cmd/server/app/service/common" + "gitee.com/openeuler/PilotGo/cmd/server/app/service/plugin" + roleservice "gitee.com/openeuler/PilotGo/cmd/server/app/service/role" + "gitee.com/openeuler/PilotGo/sdk/response" + "github.com/gin-gonic/gin" + "github.com/google/uuid" +) + +// 获取所有角色 +func GetRolesHandler(c *gin.Context) { + data, err := roleservice.GetRoles() + if err != nil { + response.Fail(c, gin.H{"status": false}, err.Error()) + return + } + response.Success(c, data, "角色权限列表") +} + +// 分页获取所有角色 +func GetRolesPagedHandler(c *gin.Context) { + p := &common.PaginationQ{} + err := c.ShouldBindQuery(p) + if err != nil { + response.Fail(c, gin.H{"status": false}, err.Error()) + return + } + + num := p.Size * (p.CurrentPageNum - 1) + total, data, err := roleservice.GetRolePaged(num, p.Size) + if err != nil { + response.Fail(c, gin.H{"status": false}, err.Error()) + return + } + common.JsonPagination(c, data, total, p) +} + +// 添加角色 +func AddRoleHandler(c *gin.Context) { + params := &struct { + Role string `json:"role"` + Description string `json:"description"` + }{} + if err := c.Bind(params); err != nil { + response.Fail(c, nil, "parameter error:"+err.Error()) + return + } + + u, err := jwt.ParseUser(c) + if err != nil { + response.Fail(c, nil, "user token error:"+err.Error()) + return + } + log := &auditlog.AuditLog{ + LogUUID: uuid.New().String(), + ParentUUID: "", + Module: auditlog.ModuleRole, + Status: auditlog.StatusOK, + UserID: u.ID, + Action: "添加角色", + } + auditlog.Add(log) + + userRole := &roleservice.Role{ + Name: params.Role, + Description: params.Description, + } + + err = roleservice.AddRole(userRole) + if err != nil { + auditlog.UpdateStatus(log, auditlog.StatusFailed) + response.Fail(c, nil, err.Error()) + return + } + response.Success(c, nil, "新增角色成功") +} + +// 删除角色 +func DeleteRoleHandler(c *gin.Context) { + params := &struct { + RoleId int `json:"role"` + }{} + if err := c.Bind(params); err != nil { + response.Fail(c, nil, "parameter error:"+err.Error()) + return + } + + u, err := jwt.ParseUser(c) + if err != nil { + response.Fail(c, nil, "user token error:"+err.Error()) + return + } + log := &auditlog.AuditLog{ + LogUUID: uuid.New().String(), + ParentUUID: "", + Module: auditlog.ModuleRole, + Status: auditlog.StatusOK, + UserID: u.ID, + Action: "删除角色", + } + auditlog.Add(log) + + err = roleservice.DeleteRole(params.RoleId) + if err != nil { + auditlog.UpdateStatus(log, auditlog.StatusFailed) + response.Fail(c, nil, "有用户绑定此角色,不可删除") + return + } + response.Success(c, nil, "角色删除成功") +} + +// 更改角色 +func UpdateRoleInfoHandler(c *gin.Context) { + params := &struct { + Role string `json:"role"` + Description string `json:"description"` + }{} + if err := c.Bind(params); err != nil { + response.Fail(c, nil, "parameter error:"+err.Error()) + return + } + + u, err := jwt.ParseUser(c) + if err != nil { + response.Fail(c, nil, "user token error:"+err.Error()) + return + } + log := &auditlog.AuditLog{ + LogUUID: uuid.New().String(), + ParentUUID: "", + Module: auditlog.ModuleRole, + Status: auditlog.StatusOK, + UserID: u.ID, + Action: "修改角色信息", + } + auditlog.Add(log) + + err = roleservice.UpdateRoleInfo(params.Role, params.Description) + if err != nil { + auditlog.UpdateStatus(log, auditlog.StatusFailed) + response.Fail(c, nil, err.Error()) + return + } + response.Success(c, nil, "角色信息修改成功") +} + +// 更改角色权限 +func RolePermissionChangeHandler(c *gin.Context) { + params := &struct { + Buttons []string `json:"buttons"` + Menus []string `json:"menus"` + Role string `json:"role"` + PluginPermissions []plugin.PluginPermission `json:"pluginpermissions"` + }{} + if err := c.Bind(params); err != nil { + response.Fail(c, nil, "parameter error:"+err.Error()) + return + } + + u, err := jwt.ParseUser(c) + if err != nil { + response.Fail(c, nil, "user token error:"+err.Error()) + return + } + log := &auditlog.AuditLog{ + LogUUID: uuid.New().String(), + ParentUUID: "", + Module: auditlog.ModuleRole, + Status: auditlog.StatusOK, + UserID: u.ID, + Action: "修改角色权限", + } + auditlog.Add(log) + + err = roleservice.UpdateRolePermissions(params.Role, params.Buttons, params.Menus, params.PluginPermissions) + if err != nil { + auditlog.UpdateStatus(log, auditlog.StatusFailed) + response.Fail(c, nil, err.Error()) + return + } + response.Success(c, nil, "角色权限变更成功") +} diff --git a/cmd/server/app/network/controller/script.go b/cmd/server/app/network/controller/script.go index b0b8202d..15d1a16c 100644 --- a/cmd/server/app/network/controller/script.go +++ b/cmd/server/app/network/controller/script.go @@ -1,3 +1,10 @@ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ package controller import ( diff --git a/cmd/server/app/network/controller/user.go b/cmd/server/app/network/controller/user.go index 48c77fdb..fe81ae52 100644 --- a/cmd/server/app/network/controller/user.go +++ b/cmd/server/app/network/controller/user.go @@ -1,17 +1,10 @@ -/****************************************************************************** - * Copyright (c) KylinSoft Co., Ltd.2021-2022. All rights reserved. - * PilotGo is licensed under the Mulan PSL v2. - * You can use this software accodring to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - *     http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN 'AS IS' BASIS, WITHOUT WARRANTIES OF ANY KIND, - * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - * See the Mulan PSL v2 for more details. - * Author: zhanghan - * Date: 2021-12-18 02:33:55 - * LastEditTime: 2023-09-04 14:06:46 - * Description: 用户登录、增删改查 - ******************************************************************************/ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ package controller import ( diff --git a/cmd/server/app/network/controller/version.go b/cmd/server/app/network/controller/version.go index 4e947208..86b3815e 100644 --- a/cmd/server/app/network/controller/version.go +++ b/cmd/server/app/network/controller/version.go @@ -1,3 +1,10 @@ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ package controller import ( diff --git a/cmd/server/app/network/controller/web_terminal.go b/cmd/server/app/network/controller/web_terminal.go index 6464aaa6..17af58df 100644 --- a/cmd/server/app/network/controller/web_terminal.go +++ b/cmd/server/app/network/controller/web_terminal.go @@ -1,18 +1,10 @@ -/****************************************************************************** - * Copyright (c) KylinSoft Co., Ltd.2021-2022. All rights reserved. - * PilotGo is licensed under the Mulan PSL v2. - * You can use this software accodring to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - *     http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN 'AS IS' BASIS, WITHOUT WARRANTIES OF ANY KIND, - * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - * See the Mulan PSL v2 for more details. - * Author: zhanghan - * Date: 2022-04-20 16:48:55 - * LastEditTime: 2022-04-20 17:48:55 - * Description: web socket连接控制 - ******************************************************************************/ - +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ package controller import ( diff --git a/cmd/server/app/network/httpserver.go b/cmd/server/app/network/httpserver.go index 67c7eedc..3fb7449a 100644 --- a/cmd/server/app/network/httpserver.go +++ b/cmd/server/app/network/httpserver.go @@ -1,17 +1,10 @@ -/****************************************************************************** - * Copyright (c) KylinSoft Co., Ltd.2021-2022. All rights reserved. - * PilotGo is licensed under the Mulan PSL v2. - * You can use this software accodring to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - *     http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN 'AS IS' BASIS, WITHOUT WARRANTIES OF ANY KIND, - * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - * See the Mulan PSL v2 for more details. - * Author: zhanghan - * Date: 2021-11-18 13:03:16 - * LastEditTime: 2023-09-05 11:08:13 - * Description: Interface routing forwarding - ******************************************************************************/ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ package network import ( diff --git a/cmd/server/app/network/jwt/jwt.go b/cmd/server/app/network/jwt/jwt.go index 7310712a..089ad43b 100644 --- a/cmd/server/app/network/jwt/jwt.go +++ b/cmd/server/app/network/jwt/jwt.go @@ -1,17 +1,10 @@ -/****************************************************************************** - * Copyright (c) KylinSoft Co., Ltd.2021-2022. All rights reserved. - * PilotGo is licensed under the Mulan PSL v2. - * You can use this software accodring to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - *     http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN 'AS IS' BASIS, WITHOUT WARRANTIES OF ANY KIND, - * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - * See the Mulan PSL v2 for more details. - * Author: zhanghan - * Date: 2021-11-1 15:08:08 - * LastEditTime: 2023-09-04 16:52:24 - * Description: jwt是一个基于token的轻量级认证方式 - ******************************************************************************/ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ package jwt import ( diff --git a/cmd/server/app/network/middleware/auth.go b/cmd/server/app/network/middleware/auth.go index f5a9e6be..326a97d0 100644 --- a/cmd/server/app/network/middleware/auth.go +++ b/cmd/server/app/network/middleware/auth.go @@ -1,3 +1,10 @@ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ package middleware import ( diff --git a/cmd/server/app/network/middleware/logger.go b/cmd/server/app/network/middleware/logger.go index df8f9242..19426b8a 100644 --- a/cmd/server/app/network/middleware/logger.go +++ b/cmd/server/app/network/middleware/logger.go @@ -1,17 +1,10 @@ -/****************************************************************************** - * Copyright (c) KylinSoft Co., Ltd.2021-2022. All rights reserved. - * PilotGo is licensed under the Mulan PSL v2. - * You can use this software accodring to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - *     http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN 'AS IS' BASIS, WITHOUT WARRANTIES OF ANY KIND, - * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - * See the Mulan PSL v2 for more details. - * Author: zhanghan - * Date: 2022-07-11 15:25:53 - * LastEditTime: 2022-07-11 10:35:54 - * Description: panic recover - ******************************************************************************/ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ package middleware import ( diff --git a/cmd/server/app/network/session.go b/cmd/server/app/network/session.go index 82b2cefe..ef026168 100644 --- a/cmd/server/app/network/session.go +++ b/cmd/server/app/network/session.go @@ -1,3 +1,10 @@ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ package network import ( diff --git a/cmd/server/app/network/socketserver.go b/cmd/server/app/network/socketserver.go index 25d7718b..0d0eb563 100644 --- a/cmd/server/app/network/socketserver.go +++ b/cmd/server/app/network/socketserver.go @@ -1,17 +1,10 @@ -/****************************************************************************** - * Copyright (c) KylinSoft Co., Ltd.2021-2022. All rights reserved. - * PilotGo is licensed under the Mulan PSL v2. - * You can use this software accodring to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - *     http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN 'AS IS' BASIS, WITHOUT WARRANTIES OF ANY KIND, - * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - * See the Mulan PSL v2 for more details. - * Author: zhanghan - * Date: 2022-02-18 02:39:36 - * LastEditTime: 2022-03-04 02:25:56 - * Description: provide agent log manager functions. - ******************************************************************************/ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ package network import ( diff --git a/cmd/server/app/network/websocket/client.go b/cmd/server/app/network/websocket/client.go index 4413b696..e6ef424b 100644 --- a/cmd/server/app/network/websocket/client.go +++ b/cmd/server/app/network/websocket/client.go @@ -1,3 +1,10 @@ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ package websocket import ( diff --git a/cmd/server/app/network/websocket/client_manager.go b/cmd/server/app/network/websocket/client_manager.go index 4af298ef..73391c8a 100644 --- a/cmd/server/app/network/websocket/client_manager.go +++ b/cmd/server/app/network/websocket/client_manager.go @@ -1,3 +1,10 @@ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ package websocket import ( diff --git a/cmd/server/app/network/websocket/sshclient.go b/cmd/server/app/network/websocket/sshclient.go index 88498689..3b0c873e 100644 --- a/cmd/server/app/network/websocket/sshclient.go +++ b/cmd/server/app/network/websocket/sshclient.go @@ -1,18 +1,10 @@ -/****************************************************************************** - * Copyright (c) KylinSoft Co., Ltd.2021-2022. All rights reserved. - * PilotGo is licensed under the Mulan PSL v2. - * You can use this software accodring to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - *     http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN 'AS IS' BASIS, WITHOUT WARRANTIES OF ANY KIND, - * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - * See the Mulan PSL v2 for more details. - * Author: zhanghan - * Date: 2022-04-20 16:48:55 - * LastEditTime: 2022-12-8 14:48:55 - * Description: 解析ssh 客户端连接信息 - ******************************************************************************/ - +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ package websocket import ( diff --git a/cmd/server/app/network/websocket/webterminal.go b/cmd/server/app/network/websocket/webterminal.go index bf598c64..89f7d177 100644 --- a/cmd/server/app/network/websocket/webterminal.go +++ b/cmd/server/app/network/websocket/webterminal.go @@ -1,17 +1,10 @@ -/****************************************************************************** - * Copyright (c) KylinSoft Co., Ltd.2021-2022. All rights reserved. - * PilotGo is licensed under the Mulan PSL v2. - * You can use this software accodring to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - *     http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN 'AS IS' BASIS, WITHOUT WARRANTIES OF ANY KIND, - * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - * See the Mulan PSL v2 for more details. - * Author: zhanghan - * Date: 2022-04-20 16:48:55 - * LastEditTime: 2022-04-20 17:48:55 - * Description: web socket连接结构体 - ******************************************************************************/ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ package websocket import ( diff --git a/cmd/server/app/resource/resource.go b/cmd/server/app/resource/resource.go index db0ffa36..e47e5bf7 100644 --- a/cmd/server/app/resource/resource.go +++ b/cmd/server/app/resource/resource.go @@ -1,20 +1,14 @@ //go:build !production // +build !production -/****************************************************************************** - * Copyright (c) KylinSoft Co., Ltd.2021-2022. All rights reserved. - * PilotGo is licensed under the Mulan PSL v2. - * You can use this software accodring to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - *     http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN 'AS IS' BASIS, WITHOUT WARRANTIES OF ANY KIND, - * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - * See the Mulan PSL v2 for more details. - * Author: zhanghan - * Date: 2022-07-12 13:03:16 - * LastEditTime: 2023-09-01 17:04:59 - * Description: static router - ******************************************************************************/ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ + package resource import ( diff --git a/cmd/server/app/resource/resource_prod.go b/cmd/server/app/resource/resource_prod.go index 80b9e5e7..114221c0 100644 --- a/cmd/server/app/resource/resource_prod.go +++ b/cmd/server/app/resource/resource_prod.go @@ -1,20 +1,14 @@ //go:build production // +build production -/****************************************************************************** - * Copyright (c) KylinSoft Co., Ltd.2021-2022. All rights reserved. - * PilotGo is licensed under the Mulan PSL v2. - * You can use this software accodring to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - *     http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN 'AS IS' BASIS, WITHOUT WARRANTIES OF ANY KIND, - * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - * See the Mulan PSL v2 for more details. - * Author: zhanghan - * Date: 2022-07-12 13:03:16 - * LastEditTime: 2023-09-01 17:04:59 - * Description: static router - ******************************************************************************/ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ + package resource import ( diff --git a/cmd/server/app/service/auditlog/auditlog.go b/cmd/server/app/service/auditlog/auditlog.go index 533b7086..f2c8980f 100644 --- a/cmd/server/app/service/auditlog/auditlog.go +++ b/cmd/server/app/service/auditlog/auditlog.go @@ -1,84 +1,91 @@ -package auditlog - -import ( - "fmt" - "net/http" - "strconv" - - "gitee.com/openeuler/PilotGo/cmd/server/app/service/internal/dao" -) - -// 日志执行操作状态 -const ( - StatusOK = "OK" - StatusFailed = "failed" -) - -// 日志记录归属模块 -const ( - ModuleUser = "user" // 登录 注销(父日志没有创建者和部门信息) 添加 删除 修改密码 重置密码 修改用户信息 - ModuleRole = "role" // 角色权限 编辑角色 删除角色 添加角色 - ModulePlugin = "plugin" // null - ModuleBatch = "batch" // 添加批次 删除批次 编辑批次 - ModuleMachine = "machine" // null - ModuleDepart = "depart" - //LogTypeRPM = "软件包安装/卸载" // rpm安装 rpm卸载 - //LogTypeService = "运行服务" // null - //LogTypeSysctl = "配置内核参数" // null - //LogTypeBroadcast = "配置文件下发" // 配置文件下发 -) - -type AuditLog = dao.AuditLog - -// 单机操作成功状态:是否成功,机器数量,成功率 -const ( - ActionOK = "1,1,1.00" - ActionFalse = "0,1,0.00" -) - -// 计算批量机器操作的状态:成功数,总数目,比率 -func BatchActionStatus(StatusCodes []string) (status string) { - var StatusOKCounts int - for _, success := range StatusCodes { - if success == strconv.Itoa(http.StatusOK) { - StatusOKCounts++ - } - } - num, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", float64(StatusOKCounts)/float64(len(StatusCodes))), 64) - rate := strconv.FormatFloat(num, 'f', 2, 64) - status = strconv.Itoa(StatusOKCounts) + "," + strconv.Itoa(len(StatusCodes)) + "," + rate - return -} - -func Add(log *dao.AuditLog) error { - return log.Record() -} - -// 修改日志的操作状态 -func UpdateStatus(log *dao.AuditLog, status string) error { - return log.UpdateStatus(status) -} - -// 添加message信息 -func UpdateMessage(log *dao.AuditLog, message string) error { - return log.UpdateMessage(message) -} - -// 分页查询 -func GetAuditLogPaged(offset, size int) (int64, []AuditLog, error) { - return dao.GetAuditLogPaged(offset, size) -} - -// 查询子日志 -func GetAuditLogById(logUUId string) ([]dao.AuditLog, error) { - return dao.GetAuditLogById(logUUId) -} - -// 查询父日志为空的记录 -func GetParentLog(offset, size int) (int64, []AuditLog, error) { - return dao.GetParentLog(offset, size) -} - -func GetByModule(name string) ([]dao.AuditLog, error) { - return dao.GetAuditLogByModule(name) -} +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ +package auditlog + +import ( + "fmt" + "net/http" + "strconv" + + "gitee.com/openeuler/PilotGo/cmd/server/app/service/internal/dao" +) + +// 日志执行操作状态 +const ( + StatusOK = "OK" + StatusFailed = "failed" +) + +// 日志记录归属模块 +const ( + ModuleUser = "user" // 登录 注销(父日志没有创建者和部门信息) 添加 删除 修改密码 重置密码 修改用户信息 + ModuleRole = "role" // 角色权限 编辑角色 删除角色 添加角色 + ModulePlugin = "plugin" // null + ModuleBatch = "batch" // 添加批次 删除批次 编辑批次 + ModuleMachine = "machine" // null + ModuleDepart = "depart" + //LogTypeRPM = "软件包安装/卸载" // rpm安装 rpm卸载 + //LogTypeService = "运行服务" // null + //LogTypeSysctl = "配置内核参数" // null + //LogTypeBroadcast = "配置文件下发" // 配置文件下发 +) + +type AuditLog = dao.AuditLog + +// 单机操作成功状态:是否成功,机器数量,成功率 +const ( + ActionOK = "1,1,1.00" + ActionFalse = "0,1,0.00" +) + +// 计算批量机器操作的状态:成功数,总数目,比率 +func BatchActionStatus(StatusCodes []string) (status string) { + var StatusOKCounts int + for _, success := range StatusCodes { + if success == strconv.Itoa(http.StatusOK) { + StatusOKCounts++ + } + } + num, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", float64(StatusOKCounts)/float64(len(StatusCodes))), 64) + rate := strconv.FormatFloat(num, 'f', 2, 64) + status = strconv.Itoa(StatusOKCounts) + "," + strconv.Itoa(len(StatusCodes)) + "," + rate + return +} + +func Add(log *dao.AuditLog) error { + return log.Record() +} + +// 修改日志的操作状态 +func UpdateStatus(log *dao.AuditLog, status string) error { + return log.UpdateStatus(status) +} + +// 添加message信息 +func UpdateMessage(log *dao.AuditLog, message string) error { + return log.UpdateMessage(message) +} + +// 分页查询 +func GetAuditLogPaged(offset, size int) (int64, []AuditLog, error) { + return dao.GetAuditLogPaged(offset, size) +} + +// 查询子日志 +func GetAuditLogById(logUUId string) ([]dao.AuditLog, error) { + return dao.GetAuditLogById(logUUId) +} + +// 查询父日志为空的记录 +func GetParentLog(offset, size int) (int64, []AuditLog, error) { + return dao.GetParentLog(offset, size) +} + +func GetByModule(name string) ([]dao.AuditLog, error) { + return dao.GetAuditLogByModule(name) +} diff --git a/cmd/server/app/service/auth/casbin.go b/cmd/server/app/service/auth/casbin.go index 50521c10..0b696f07 100644 --- a/cmd/server/app/service/auth/casbin.go +++ b/cmd/server/app/service/auth/casbin.go @@ -1,17 +1,10 @@ -/****************************************************************************** - * Copyright (c) KylinSoft Co., Ltd.2021-2022. All rights reserved. - * PilotGo is licensed under the Mulan PSL v2. - * You can use this software accodring to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - *     http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN 'AS IS' BASIS, WITHOUT WARRANTIES OF ANY KIND, - * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - * See the Mulan PSL v2 for more details. - * Author: zhanghan - * Date: 2021-07-04 09:08:08 - * LastEditTime: 2023-09-04 11:12:43 - * Description: casbin服务 - ******************************************************************************/ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ package auth import ( diff --git a/cmd/server/app/service/auth/casbin_test.go b/cmd/server/app/service/auth/casbin_test.go index 8d445008..25ccf481 100644 --- a/cmd/server/app/service/auth/casbin_test.go +++ b/cmd/server/app/service/auth/casbin_test.go @@ -1,17 +1,10 @@ -/****************************************************************************** - * Copyright (c) KylinSoft Co., Ltd.2021-2022. All rights reserved. - * PilotGo is licensed under the Mulan PSL v2. - * You can use this software accodring to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - *     http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN 'AS IS' BASIS, WITHOUT WARRANTIES OF ANY KIND, - * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - * See the Mulan PSL v2 for more details. - * Author: zhanghan - * Date: 2021-07-04 09:08:08 - * LastEditTime: 2023-09-01 16:22:14 - * Description: casbin服务 - ******************************************************************************/ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ package auth import ( diff --git a/cmd/server/app/service/batch/batch.go b/cmd/server/app/service/batch/batch.go index bd623f2f..99f3a79b 100644 --- a/cmd/server/app/service/batch/batch.go +++ b/cmd/server/app/service/batch/batch.go @@ -1,17 +1,10 @@ -/****************************************************************************** - * Copyright (c) KylinSoft Co., Ltd.2021-2022. All rights reserved. - * PilotGo is licensed under the Mulan PSL v2. - * You can use this software accodring to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - *     http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN 'AS IS' BASIS, WITHOUT WARRANTIES OF ANY KIND, - * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - * See the Mulan PSL v2 for more details. - * Author: zhanghan - * Date: 2021-05-18 09:08:08 - * LastEditTime: 2023-09-15 14:58:17 - * Description: 批次管理业务逻辑 - ******************************************************************************/ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ package batch import ( diff --git a/cmd/server/app/service/cluster/cluster.go b/cmd/server/app/service/cluster/cluster.go index 6e81ea81..5bf9d884 100644 --- a/cmd/server/app/service/cluster/cluster.go +++ b/cmd/server/app/service/cluster/cluster.go @@ -1,17 +1,10 @@ -/****************************************************************************** - * Copyright (c) KylinSoft Co., Ltd.2021-2022. All rights reserved. - * PilotGo is licensed under the Mulan PSL v2. - * You can use this software accodring to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - *     http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN 'AS IS' BASIS, WITHOUT WARRANTIES OF ANY KIND, - * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - * See the Mulan PSL v2 for more details. - * Author: zhanghan - * Date: 2021-04-29 09:08:08 - * LastEditTime: 2022-04-29 09:25:41 - * Description: 集群概览业务逻辑 - ******************************************************************************/ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ package cluster import ( diff --git a/cmd/server/app/service/common/common.go b/cmd/server/app/service/common/common.go index 04149417..28550632 100644 --- a/cmd/server/app/service/common/common.go +++ b/cmd/server/app/service/common/common.go @@ -1,17 +1,10 @@ -/****************************************************************************** - * Copyright (c) KylinSoft Co., Ltd.2021-2022. All rights reserved. - * PilotGo is licensed under the Mulan PSL v2. - * You can use this software accodring to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - *     http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN 'AS IS' BASIS, WITHOUT WARRANTIES OF ANY KIND, - * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - * See the Mulan PSL v2 for more details. - * Author: zhanghan - * Date: 2022-02-23 17:44:00 - * LastEditTime: 2022-04-22 14:18:14 - * Description: 公共函数 - ******************************************************************************/ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ package common import ( diff --git a/cmd/server/app/service/configfile/configfile.go b/cmd/server/app/service/configfile/configfile.go index 9f4a4e5f..b78dec55 100644 --- a/cmd/server/app/service/configfile/configfile.go +++ b/cmd/server/app/service/configfile/configfile.go @@ -1,3 +1,10 @@ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ package configfile import "gitee.com/openeuler/PilotGo/cmd/server/app/service/internal/dao" diff --git a/cmd/server/app/service/configmanage/configmanage.go b/cmd/server/app/service/configmanage/configmanage.go index 6963a43d..580035e5 100644 --- a/cmd/server/app/service/configmanage/configmanage.go +++ b/cmd/server/app/service/configmanage/configmanage.go @@ -1,17 +1,10 @@ -/****************************************************************************** - * Copyright (c) KylinSoft Co., Ltd.2021-2022. All rights reserved. - * PilotGo is licensed under the Mulan PSL v2. - * You can use this software accodring to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - *     http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN 'AS IS' BASIS, WITHOUT WARRANTIES OF ANY KIND, - * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - * See the Mulan PSL v2 for more details. - * Author: zhanghan - * Date: 2022-05-26 10:25:52 - * LastEditTime: 2022-06-02 10:16:10 - * Description: agent config file service - ******************************************************************************/ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ package configmanage import ( diff --git a/cmd/server/app/service/configmanage/internal/hosts.go b/cmd/server/app/service/configmanage/internal/hosts.go index 34f313a3..ae334d67 100644 --- a/cmd/server/app/service/configmanage/internal/hosts.go +++ b/cmd/server/app/service/configmanage/internal/hosts.go @@ -1,3 +1,10 @@ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ package internal type HostsConfig struct{} diff --git a/cmd/server/app/service/configmanage/internal/repo.go b/cmd/server/app/service/configmanage/internal/repo.go index ccabe160..060cbd22 100644 --- a/cmd/server/app/service/configmanage/internal/repo.go +++ b/cmd/server/app/service/configmanage/internal/repo.go @@ -1,3 +1,10 @@ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ package internal import "gitee.com/openeuler/PilotGo/pkg/utils/os/common" diff --git a/cmd/server/app/service/configmanage/internal/sshconfig.go b/cmd/server/app/service/configmanage/internal/sshconfig.go index 5bf0569c..8a3747a7 100644 --- a/cmd/server/app/service/configmanage/internal/sshconfig.go +++ b/cmd/server/app/service/configmanage/internal/sshconfig.go @@ -1 +1,8 @@ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ package internal diff --git a/cmd/server/app/service/configmanage/internal/sshdconfig.go b/cmd/server/app/service/configmanage/internal/sshdconfig.go index 5bf0569c..8a3747a7 100644 --- a/cmd/server/app/service/configmanage/internal/sshdconfig.go +++ b/cmd/server/app/service/configmanage/internal/sshdconfig.go @@ -1 +1,8 @@ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ package internal diff --git a/cmd/server/app/service/configmanage/internal/sysctl.go b/cmd/server/app/service/configmanage/internal/sysctl.go index 348e6516..27e8e05a 100644 --- a/cmd/server/app/service/configmanage/internal/sysctl.go +++ b/cmd/server/app/service/configmanage/internal/sysctl.go @@ -1,3 +1,10 @@ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ package internal type SysctlConfig struct{} diff --git a/cmd/server/app/service/cron/cron.go b/cmd/server/app/service/cron/cron.go index cba633a6..79ea3f3b 100644 --- a/cmd/server/app/service/cron/cron.go +++ b/cmd/server/app/service/cron/cron.go @@ -1,17 +1,10 @@ -/****************************************************************************** - * Copyright (c) KylinSoft Co., Ltd.2021-2022. All rights reserved. - * PilotGo is licensed under the Mulan PSL v2. - * You can use this software accodring to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - *     http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN 'AS IS' BASIS, WITHOUT WARRANTIES OF ANY KIND, - * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - * See the Mulan PSL v2 for more details. - * Author: zhanghan - * Date: 2022-05-23 10:25:52 - * LastEditTime: 2022-05-23 15:16:10 - * Description: os scheduled task - ******************************************************************************/ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ package cron import ( diff --git a/cmd/server/app/service/depart/depart.go b/cmd/server/app/service/depart/depart.go index f18d4d86..f752876f 100644 --- a/cmd/server/app/service/depart/depart.go +++ b/cmd/server/app/service/depart/depart.go @@ -1,17 +1,10 @@ -/****************************************************************************** - * Copyright (c) KylinSoft Co., Ltd.2021-2022. All rights reserved. - * PilotGo is licensed under the Mulan PSL v2. - * You can use this software accodring to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - *     http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN 'AS IS' BASIS, WITHOUT WARRANTIES OF ANY KIND, - * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - * See the Mulan PSL v2 for more details. - * Author: zhanghan - * Date: 2022-06-02 10:25:52 - * LastEditTime: 2022-06-02 16:16:10 - * Description: depart info service - ******************************************************************************/ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ package depart import ( diff --git a/cmd/server/app/service/internal/dao/auditlogdao.go b/cmd/server/app/service/internal/dao/auditlogdao.go index 901466d4..46fa7c19 100644 --- a/cmd/server/app/service/internal/dao/auditlogdao.go +++ b/cmd/server/app/service/internal/dao/auditlogdao.go @@ -1,17 +1,10 @@ -/****************************************************************************** - * Copyright (c) KylinSoft Co., Ltd.2021-2022. All rights reserved. - * PilotGo is licensed under the Mulan PSL v2. - * You can use this software accodring to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - *     http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN 'AS IS' BASIS, WITHOUT WARRANTIES OF ANY KIND, - * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - * See the Mulan PSL v2 for more details. - * Author: zhanghan - * Date: 2021-04-28 13:08:08 - * LastEditTime: 2022-04-28 14:25:41 - * Description: agent操作日志相关数据获取 - ******************************************************************************/ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ package dao import ( diff --git a/cmd/server/app/service/internal/dao/batchmanagerdao.go b/cmd/server/app/service/internal/dao/batchmanagerdao.go index a76575f6..e00ffaf0 100644 --- a/cmd/server/app/service/internal/dao/batchmanagerdao.go +++ b/cmd/server/app/service/internal/dao/batchmanagerdao.go @@ -1,3 +1,10 @@ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ package dao import ( diff --git a/cmd/server/app/service/internal/dao/configfiledao.go b/cmd/server/app/service/internal/dao/configfiledao.go index 6785186c..160cee01 100644 --- a/cmd/server/app/service/internal/dao/configfiledao.go +++ b/cmd/server/app/service/internal/dao/configfiledao.go @@ -1,3 +1,10 @@ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ package dao import ( diff --git a/cmd/server/app/service/internal/dao/configmanagedao.go b/cmd/server/app/service/internal/dao/configmanagedao.go index 26b56225..5daff49b 100644 --- a/cmd/server/app/service/internal/dao/configmanagedao.go +++ b/cmd/server/app/service/internal/dao/configmanagedao.go @@ -1,17 +1,10 @@ -/****************************************************************************** - * Copyright (c) KylinSoft Co., Ltd.2021-2022. All rights reserved. - * PilotGo is licensed under the Mulan PSL v2. - * You can use this software accodring to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - *     http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN 'AS IS' BASIS, WITHOUT WARRANTIES OF ANY KIND, - * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - * See the Mulan PSL v2 for more details. - * Author: zhanghan - * Date: 2022-05-26 10:25:52 - * LastEditTime: 2022-06-02 10:16:10 - * Description: agent config file dao - ******************************************************************************/ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ package dao import ( diff --git a/cmd/server/app/service/internal/dao/crondao.go b/cmd/server/app/service/internal/dao/crondao.go index 34d85c74..6525e5d0 100644 --- a/cmd/server/app/service/internal/dao/crondao.go +++ b/cmd/server/app/service/internal/dao/crondao.go @@ -1,17 +1,10 @@ -/****************************************************************************** - * Copyright (c) KylinSoft Co., Ltd.2021-2022. All rights reserved. - * PilotGo is licensed under the Mulan PSL v2. - * You can use this software accodring to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - *     http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN 'AS IS' BASIS, WITHOUT WARRANTIES OF ANY KIND, - * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - * See the Mulan PSL v2 for more details. - * Author: zhanghan - * Date: 2022-05-23 10:25:52 - * LastEditTime: 2023-06-28 15:58:39 - * Description: os scheduled task - ******************************************************************************/ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ package dao import ( diff --git a/cmd/server/app/service/internal/dao/departdao.go b/cmd/server/app/service/internal/dao/departdao.go index 18efdfc3..12e6a4d3 100644 --- a/cmd/server/app/service/internal/dao/departdao.go +++ b/cmd/server/app/service/internal/dao/departdao.go @@ -1,17 +1,10 @@ -/****************************************************************************** - * Copyright (c) KylinSoft Co., Ltd.2021-2022. All rights reserved. - * PilotGo is licensed under the Mulan PSL v2. - * You can use this software accodring to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - *     http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN 'AS IS' BASIS, WITHOUT WARRANTIES OF ANY KIND, - * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - * See the Mulan PSL v2 for more details. - * Author: zhanghan - * Date: 2021-04-28 13:08:08 - * LastEditTime: 2023-06-28 16:02:24 - * Description: depart相关数据获取 - ******************************************************************************/ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ package dao import ( diff --git a/cmd/server/app/service/internal/dao/machinemanagerdao.go b/cmd/server/app/service/internal/dao/machinemanagerdao.go index 4e41c10e..b150e087 100644 --- a/cmd/server/app/service/internal/dao/machinemanagerdao.go +++ b/cmd/server/app/service/internal/dao/machinemanagerdao.go @@ -1,17 +1,10 @@ -/****************************************************************************** - * Copyright (c) KylinSoft Co., Ltd.2021-2022. All rights reserved. - * PilotGo is licensed under the Mulan PSL v2. - * You can use this software accodring to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - *     http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN 'AS IS' BASIS, WITHOUT WARRANTIES OF ANY KIND, - * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - * See the Mulan PSL v2 for more details. - * Author: wanghao - * Date: 2022-01-04 12:56:59 - * LastEditTime: 2023-07-11 19:34:18 - * Description: 部门管理数据库相关函数 - ******************************************************************************/ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ package dao import ( diff --git a/cmd/server/app/service/internal/dao/plugin.go b/cmd/server/app/service/internal/dao/plugin.go index c2b71da6..70a9a071 100644 --- a/cmd/server/app/service/internal/dao/plugin.go +++ b/cmd/server/app/service/internal/dao/plugin.go @@ -1,17 +1,10 @@ -/****************************************************************************** - * Copyright (c) KylinSoft Co., Ltd.2021-2022. All rights reserved. - * PilotGo is licensed under the Mulan PSL v2. - * You can use this software accodring to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN 'AS IS' BASIS, WITHOUT WARRANTIES OF ANY KIND, - * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - * See the Mulan PSL v2 for more details. - * Author: guozhengxin - * Date: 2022-05-26 10:25:52 - * LastEditTime: 2023-06-28 15:59:45 - * Description: plugin info record - ******************************************************************************/ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ package dao import "gitee.com/openeuler/PilotGo/pkg/dbmanager/mysqlmanager" diff --git a/cmd/server/app/service/internal/dao/roledao.go b/cmd/server/app/service/internal/dao/roledao.go index a18491fd..46b3c2fd 100644 --- a/cmd/server/app/service/internal/dao/roledao.go +++ b/cmd/server/app/service/internal/dao/roledao.go @@ -1,17 +1,10 @@ -/****************************************************************************** - * Copyright (c) KylinSoft Co., Ltd.2021-2022. All rights reserved. - * PilotGo is licensed under the Mulan PSL v2. - * You can use this software accodring to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - *     http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN 'AS IS' BASIS, WITHOUT WARRANTIES OF ANY KIND, - * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - * See the Mulan PSL v2 for more details. - * Author: zhanghan - * Date: 2021-01-24 15:08:08 - * LastEditTime: 2023-09-04 14:03:47 - * Description: 角色模块相关数据获取 - ******************************************************************************/ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ package dao import ( diff --git a/cmd/server/app/service/internal/dao/scriptdao.go b/cmd/server/app/service/internal/dao/scriptdao.go index 80ceee1f..7df041fa 100644 --- a/cmd/server/app/service/internal/dao/scriptdao.go +++ b/cmd/server/app/service/internal/dao/scriptdao.go @@ -1,3 +1,10 @@ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ package dao import ( diff --git a/cmd/server/app/service/internal/dao/userdao.go b/cmd/server/app/service/internal/dao/userdao.go index b3c239ac..5e3b4908 100644 --- a/cmd/server/app/service/internal/dao/userdao.go +++ b/cmd/server/app/service/internal/dao/userdao.go @@ -1,17 +1,10 @@ -/****************************************************************************** - * Copyright (c) KylinSoft Co., Ltd.2021-2022. All rights reserved. - * PilotGo is licensed under the Mulan PSL v2. - * You can use this software accodring to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - *     http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN 'AS IS' BASIS, WITHOUT WARRANTIES OF ANY KIND, - * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - * See the Mulan PSL v2 for more details. - * Author: zhanghan - * Date: 2021-01-24 15:08:08 - * LastEditTime: 2023-09-04 14:02:00 - * Description: 用户模块相关数据获取 - ******************************************************************************/ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ package dao import ( diff --git a/cmd/server/app/service/internal/dao/userroledao.go b/cmd/server/app/service/internal/dao/userroledao.go index f1ade192..11f3fb5c 100644 --- a/cmd/server/app/service/internal/dao/userroledao.go +++ b/cmd/server/app/service/internal/dao/userroledao.go @@ -1,3 +1,10 @@ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ package dao import ( diff --git a/cmd/server/app/service/machine/machinemanager.go b/cmd/server/app/service/machine/machinemanager.go index 4d207a1a..b7fcba25 100644 --- a/cmd/server/app/service/machine/machinemanager.go +++ b/cmd/server/app/service/machine/machinemanager.go @@ -1,3 +1,10 @@ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ package machine import ( diff --git a/cmd/server/app/service/plugin/event.go b/cmd/server/app/service/plugin/event.go index ca9d0e69..d10f5503 100644 --- a/cmd/server/app/service/plugin/event.go +++ b/cmd/server/app/service/plugin/event.go @@ -1,3 +1,10 @@ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: zhanghan + * Date: Mon Nov 25 16:52:07 2024 +0800 + */ package plugin import ( diff --git a/cmd/server/app/service/plugin/heartbeat.go b/cmd/server/app/service/plugin/heartbeat.go index a0bffa7c..cb60ff61 100644 --- a/cmd/server/app/service/plugin/heartbeat.go +++ b/cmd/server/app/service/plugin/heartbeat.go @@ -1,3 +1,10 @@ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ package plugin import ( diff --git a/cmd/server/app/service/plugin/plugin.go b/cmd/server/app/service/plugin/plugin.go index 3e556666..3f74dd42 100644 --- a/cmd/server/app/service/plugin/plugin.go +++ b/cmd/server/app/service/plugin/plugin.go @@ -1,3 +1,10 @@ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ package plugin import ( diff --git a/cmd/server/app/service/plugin/proxy.go b/cmd/server/app/service/plugin/proxy.go index b0736c3a..7b5816e6 100644 --- a/cmd/server/app/service/plugin/proxy.go +++ b/cmd/server/app/service/plugin/proxy.go @@ -1 +1,8 @@ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ package plugin diff --git a/cmd/server/app/service/role/role.go b/cmd/server/app/service/role/role.go index eade7102..73200cbb 100644 --- a/cmd/server/app/service/role/role.go +++ b/cmd/server/app/service/role/role.go @@ -1,17 +1,10 @@ -/****************************************************************************** - * Copyright (c) KylinSoft Co., Ltd.2021-2022. All rights reserved. - * PilotGo is licensed under the Mulan PSL v2. - * You can use this software accodring to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - *     http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN 'AS IS' BASIS, WITHOUT WARRANTIES OF ANY KIND, - * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - * See the Mulan PSL v2 for more details. - * Author: zhanghan - * Date: 2022-04-27 15:32:50 - * LastEditTime: 2022-04-27 17:17:48 - * Description: 用户角色逻辑代码 - ******************************************************************************/ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ package role import ( diff --git a/cmd/server/app/service/script/script.go b/cmd/server/app/service/script/script.go index abd8e9bb..fb8d54f0 100644 --- a/cmd/server/app/service/script/script.go +++ b/cmd/server/app/service/script/script.go @@ -1,3 +1,10 @@ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ package script import ( diff --git a/cmd/server/app/service/tag/tag.go b/cmd/server/app/service/tag/tag.go index 68795d72..0285f95b 100644 --- a/cmd/server/app/service/tag/tag.go +++ b/cmd/server/app/service/tag/tag.go @@ -1,3 +1,10 @@ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ package tag import ( diff --git a/cmd/server/app/service/user/user.go b/cmd/server/app/service/user/user.go index 4bd10d81..0998eb2d 100644 --- a/cmd/server/app/service/user/user.go +++ b/cmd/server/app/service/user/user.go @@ -1,17 +1,10 @@ -/****************************************************************************** - * Copyright (c) KylinSoft Co., Ltd.2021-2022. All rights reserved. - * PilotGo is licensed under the Mulan PSL v2. - * You can use this software accodring to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - *     http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN 'AS IS' BASIS, WITHOUT WARRANTIES OF ANY KIND, - * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - * See the Mulan PSL v2 for more details. - * Author: zhanghan - * Date: 2022-03-21 15:32:50 - * LastEditTime: 2023-09-04 13:54:45 - * Description: 用户模块逻辑代码 - ******************************************************************************/ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ package user import ( diff --git a/cmd/server/main.go b/cmd/server/main.go index 6c22e134..4cd7cd97 100644 --- a/cmd/server/main.go +++ b/cmd/server/main.go @@ -1,17 +1,10 @@ -/****************************************************************************** - * Copyright (c) KylinSoft Co., Ltd.2021-2022. All rights reserved. - * PilotGo is licensed under the Mulan PSL v2. - * You can use this software accodring to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - *     http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN 'AS IS' BASIS, WITHOUT WARRANTIES OF ANY KIND, - * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - * See the Mulan PSL v2 for more details. - * Author: zhanghan - * Date: 2021-11-18 10:25:52 - * LastEditTime: 2023-06-12 15:18:57 - * Description: server main - ******************************************************************************/ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: linjieren + * Date: Thu Jul 25 16:18:53 2024 +0800 + */ package main import ( diff --git a/frontend/env.d.ts b/frontend/env.d.ts index 5b53a159..284854ab 100644 --- a/frontend/env.d.ts +++ b/frontend/env.d.ts @@ -1,3 +1,10 @@ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * PilotGo licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: Gzx1999 + * Date: Wed Jan 3 18:00:12 2024 +0800 + */ /// declare module '*.vue' { diff --git a/frontend/index.html b/frontend/index.html index 881fb4a7..7a6eb7aa 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -1,3 +1,10 @@ + diff --git a/frontend/src/App.vue b/frontend/src/App.vue index d2234c30..6767a3d1 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -1,3 +1,10 @@ +