mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2026-10-09 08:00:27 +00:00
Compare commits
9
Commits
release-2.1.4
...
v2.0.9
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dd47fcc529 | ||
|
|
12add885f6 | ||
|
|
78e0233dc4 | ||
|
|
e76ea877b9 | ||
|
|
7654ab014a | ||
|
|
654eb94819 | ||
|
|
3d1082a4a8 | ||
|
|
dfbc549ea9 | ||
|
|
0adfe65476 |
@@ -113,7 +113,7 @@ func loadLocalConn() (*ssh.SSHClient, error) {
|
||||
itemPath = path.Join(currentInfo.HomeDir, ".ssh/id_ed25519_1panel")
|
||||
}
|
||||
if _, err := os.Stat(itemPath); err != nil {
|
||||
_ = sshService.CreateRootCert(dto.CreateRootCert{EncryptionMode: "ed25519", Name: "1panel", Description: "1Panel Terminal"})
|
||||
_ = sshService.CreateRootCert(dto.CreateRootCert{EncryptionMode: "ed25519", Name: "id_ed25519_1panel", Description: "1Panel Terminal"})
|
||||
}
|
||||
|
||||
privateKey, _ := os.ReadFile(itemPath)
|
||||
|
||||
@@ -37,6 +37,7 @@ type WebsiteRes struct {
|
||||
ChildSites []string `json:"childSites"`
|
||||
RuntimeType string `json:"runtimeType"`
|
||||
Favorite bool `json:"favorite"`
|
||||
IPV6 bool `json:"IPV6"`
|
||||
}
|
||||
|
||||
type WebsiteOption struct {
|
||||
|
||||
+38
-10
@@ -483,23 +483,51 @@ func (a AlertService) TestAlertConfig(req dto.AlertConfigTest) (bool, error) {
|
||||
|
||||
func (a AlertService) ExternalUpdateAlert(updateAlert dto.AlertCreate) error {
|
||||
upMap := make(map[string]interface{})
|
||||
var newStatus string
|
||||
if updateAlert.SendCount == 0 {
|
||||
upMap["status"] = constant.AlertDisable
|
||||
newStatus = constant.AlertDisable
|
||||
} else {
|
||||
upMap["status"] = constant.AlertEnable
|
||||
newStatus = constant.AlertEnable
|
||||
upMap["send_count"] = updateAlert.SendCount
|
||||
if updateAlert.Method != "" {
|
||||
upMap["method"] = updateAlert.Method
|
||||
}
|
||||
}
|
||||
upMap["method"] = updateAlert.Method
|
||||
alertInfo, _ := alertRepo.Get(alertRepo.WithByType(updateAlert.Type), alertRepo.WithByProject(updateAlert.Project))
|
||||
upMap["status"] = newStatus
|
||||
|
||||
alertInfo, _ := alertRepo.Get(
|
||||
alertRepo.WithByType(updateAlert.Type),
|
||||
alertRepo.WithByProject(updateAlert.Project),
|
||||
)
|
||||
|
||||
if alertInfo.ID > 0 {
|
||||
if err := alertRepo.Update(upMap, alertRepo.WithByProject(updateAlert.Project), alertRepo.WithByType(updateAlert.Type)); err != nil {
|
||||
return err
|
||||
shouldUpdate := false
|
||||
|
||||
if alertInfo.Status != newStatus {
|
||||
shouldUpdate = true
|
||||
}
|
||||
if val, ok := upMap["send_count"]; ok && val != alertInfo.SendCount {
|
||||
shouldUpdate = true
|
||||
}
|
||||
if val, ok := upMap["method"]; ok && val != "" && val != alertInfo.Method {
|
||||
shouldUpdate = true
|
||||
}
|
||||
|
||||
if shouldUpdate {
|
||||
if err := alertRepo.Update(
|
||||
upMap,
|
||||
alertRepo.WithByProject(updateAlert.Project),
|
||||
alertRepo.WithByType(updateAlert.Type),
|
||||
); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
} else {
|
||||
updateAlert.Status = constant.AlertEnable
|
||||
err := a.CreateAlert(updateAlert)
|
||||
if err != nil {
|
||||
return err
|
||||
if updateAlert.Method != "" && updateAlert.Title != "" {
|
||||
updateAlert.Status = newStatus
|
||||
if err := a.CreateAlert(updateAlert); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1075,7 +1075,7 @@ func (a AppService) SyncAppListFromRemote(taskID string) (err error) {
|
||||
tagId, ok := tagMap[tag]
|
||||
if ok {
|
||||
exist, _ := appTagRepo.GetFirst(ctx, appTagRepo.WithByTagID(tagId), appTagRepo.WithByAppID(app.ID))
|
||||
if exist != nil {
|
||||
if exist == nil {
|
||||
appTags = append(appTags, &model.AppTag{
|
||||
AppId: app.ID,
|
||||
TagId: tagId,
|
||||
|
||||
@@ -192,7 +192,7 @@ func (c *ClamService) Create(req dto.ClamCreate) error {
|
||||
if err := clamRepo.Create(&clam); err != nil {
|
||||
return err
|
||||
}
|
||||
if req.AlertCount != 0 {
|
||||
if req.AlertCount != 0 && req.AlertTitle != "" && req.AlertMethod != "" {
|
||||
createAlert := dto.AlertCreate{
|
||||
Title: req.AlertTitle,
|
||||
SendCount: req.AlertCount,
|
||||
|
||||
@@ -382,7 +382,7 @@ func (u *CronjobService) Import(req []dto.CronjobTrans) error {
|
||||
cronjob.Status = constant.StatusDisable
|
||||
}
|
||||
_ = cronjobRepo.Create(&cronjob)
|
||||
if item.AlertCount != 0 {
|
||||
if item.AlertCount != 0 && item.AlertTitle != "" && item.AlertMethod != "" {
|
||||
createAlert := dto.AlertCreate{
|
||||
Title: item.AlertTitle,
|
||||
SendCount: item.AlertCount,
|
||||
@@ -606,7 +606,7 @@ func (u *CronjobService) Create(req dto.CronjobOperate) error {
|
||||
if err := cronjobRepo.Create(&cronjob); err != nil {
|
||||
return err
|
||||
}
|
||||
if req.AlertCount != 0 {
|
||||
if req.AlertCount != 0 && req.AlertTitle != "" && req.AlertMethod != "" {
|
||||
createAlert := dto.AlertCreate{
|
||||
Title: req.AlertTitle,
|
||||
SendCount: req.AlertCount,
|
||||
|
||||
@@ -202,6 +202,7 @@ func (w WebsiteService) PageWebsite(req request.WebsiteSearch) (int64, []respons
|
||||
AppInstallID: appInstallID,
|
||||
RuntimeType: runtimeType,
|
||||
Favorite: web.Favorite,
|
||||
IPV6: web.IPV6,
|
||||
}
|
||||
|
||||
sites, _ := websiteRepo.List(websiteRepo.WithParentID(web.ID))
|
||||
|
||||
@@ -1135,13 +1135,12 @@ func saveCertificateFile(websiteSSL *model.WebsiteSSL, logger *log.Logger) {
|
||||
}
|
||||
|
||||
func GetSystemSSL() (bool, uint) {
|
||||
sslSetting, err := settingRepo.Get(settingRepo.WithByKey("SSL"))
|
||||
if err != nil {
|
||||
return false, 0
|
||||
}
|
||||
if sslSetting.Value == "enable" {
|
||||
sslID, _ := settingRepo.Get(settingRepo.WithByKey("SSLID"))
|
||||
idValue, _ := strconv.Atoi(sslID.Value)
|
||||
var sslSetting model.Setting
|
||||
_ = global.CoreDB.Model(&model.Setting{}).Where("key = ?", "SSL").First(&sslSetting).Error
|
||||
if sslSetting.Value == "Enable" {
|
||||
var sslIDSetting model.Setting
|
||||
_ = global.CoreDB.Model(&model.Setting{}).Where("key = ?", "SSLID").First(&sslIDSetting).Error
|
||||
idValue, _ := strconv.Atoi(sslIDSetting.Value)
|
||||
if idValue > 0 {
|
||||
return true, uint(idValue)
|
||||
}
|
||||
|
||||
@@ -2,34 +2,37 @@ package req_helper
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"crypto/tls"
|
||||
"fmt"
|
||||
"github.com/1Panel-dev/1Panel/agent/app/model"
|
||||
"github.com/1Panel-dev/1Panel/agent/global"
|
||||
"net/http"
|
||||
|
||||
"github.com/1Panel-dev/1Panel/agent/app/repo"
|
||||
)
|
||||
|
||||
func PostLocalCore(url string) error {
|
||||
settingRepo := repo.NewISettingRepo()
|
||||
port, err := settingRepo.GetValueByKey("ServerPort")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
sslStatus, err := settingRepo.GetValueByKey("SSL")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
var serverPortSetting model.Setting
|
||||
_ = global.CoreDB.Model(&model.Setting{}).Where("key = ?", "ServerPort").First(&serverPortSetting).Error
|
||||
var sslStatusSetting model.Setting
|
||||
_ = global.CoreDB.Model(&model.Setting{}).Where("key = ?", "SSL").First(&sslStatusSetting).Error
|
||||
|
||||
var prefix string
|
||||
if sslStatus == "Disable" {
|
||||
prefix = "http://"
|
||||
if sslStatusSetting.Value == "Disable" {
|
||||
prefix = "http"
|
||||
} else {
|
||||
prefix = "https://"
|
||||
prefix = "https"
|
||||
}
|
||||
reloadURL := fmt.Sprintf("%s://127.0.0.1:%s/api/v2%s", prefix, port, url)
|
||||
|
||||
reloadURL := fmt.Sprintf("%s://127.0.0.1:%s/api/v2%s", prefix, serverPortSetting.Value, url)
|
||||
req, err := http.NewRequest("POST", reloadURL, bytes.NewBuffer([]byte{}))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
client := &http.Client{}
|
||||
tr := &http.Transport{
|
||||
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
|
||||
}
|
||||
client := &http.Client{
|
||||
Transport: tr,
|
||||
}
|
||||
defer client.CloseIdleConnections()
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
|
||||
@@ -3,6 +3,9 @@ package router
|
||||
import (
|
||||
"encoding/base64"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"path"
|
||||
|
||||
"github.com/1Panel-dev/1Panel/core/app/service"
|
||||
"github.com/1Panel-dev/1Panel/core/cmd/server/docs"
|
||||
"github.com/1Panel-dev/1Panel/core/cmd/server/web"
|
||||
@@ -15,8 +18,6 @@ import (
|
||||
"github.com/gin-gonic/gin"
|
||||
swaggerfiles "github.com/swaggo/files"
|
||||
ginSwagger "github.com/swaggo/gin-swagger"
|
||||
"net/http"
|
||||
"path"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -61,6 +62,8 @@ func setWebStatic(rootRouter *gin.RouterGroup) {
|
||||
func Routers() *gin.Engine {
|
||||
Router = gin.Default()
|
||||
Router.Use(i18n.UseI18n())
|
||||
Router.Use(middleware.WhiteAllow())
|
||||
Router.Use(middleware.BindDomain())
|
||||
|
||||
swaggerRouter := Router.Group("1panel")
|
||||
docs.SwaggerInfo.BasePath = "/api/v2"
|
||||
@@ -77,8 +80,6 @@ func Routers() *gin.Engine {
|
||||
Router.Use(middleware.OperationLog())
|
||||
Router.Use(middleware.GlobalLoading())
|
||||
Router.Use(middleware.PasswordExpired())
|
||||
Router.Use(middleware.WhiteAllow())
|
||||
Router.Use(middleware.BindDomain())
|
||||
Router.Use(middleware.ApiAuth())
|
||||
|
||||
PrivateGroup := Router.Group("/api/v2/core")
|
||||
|
||||
@@ -3,6 +3,7 @@ export enum CompressType {
|
||||
Gz = 'gz',
|
||||
Bz2 = 'bz2',
|
||||
Tar = 'tar',
|
||||
TGz = 'tgz',
|
||||
TarGz = 'tar.gz',
|
||||
Xz = 'xz',
|
||||
Rar = 'rar',
|
||||
@@ -14,6 +15,7 @@ export enum CompressExtension {
|
||||
gz = '.gz',
|
||||
bz2 = '.tar.bz2',
|
||||
tar = '.tar',
|
||||
tgz = '.tgz',
|
||||
'tar.gz' = '.tar.gz',
|
||||
xz = '.tar.xz',
|
||||
rar = '.rar',
|
||||
@@ -26,6 +28,7 @@ export const MimetypeByExtensionObject: Record<string, string> = {
|
||||
'.tar.bz2': 'application/x-bzip2',
|
||||
'.bz2': 'application/x-bzip2',
|
||||
'.tar.gz': 'application/gzip',
|
||||
'.tgz': 'application/x-gzip',
|
||||
'.gz': 'application/gzip',
|
||||
'.xz': 'application/x-xz',
|
||||
'.rar': 'application/x-rar-compressed',
|
||||
|
||||
@@ -603,7 +603,7 @@ let selects = ref<any>([]);
|
||||
const initData = () => ({
|
||||
path: '/',
|
||||
expand: true,
|
||||
showHidden: true,
|
||||
showHidden: localStorage.getItem('show-hidden') === 'true',
|
||||
page: 1,
|
||||
pageSize: 100,
|
||||
search: '',
|
||||
@@ -1033,11 +1033,9 @@ const openDeCompress = (item: File.File) => {
|
||||
MsgWarning(i18n.global.t('file.canNotDeCompress'));
|
||||
return;
|
||||
}
|
||||
|
||||
fileDeCompress.mimeType = item.mimeType;
|
||||
if (CompressExtension[Mimetypes.get(item.mimeType)] != item.extension) {
|
||||
fileDeCompress.mimeType = MimetypeByExtensionObject[item.extension];
|
||||
} else {
|
||||
fileDeCompress.mimeType = item.mimeType;
|
||||
}
|
||||
|
||||
fileDeCompress.name = item.name;
|
||||
|
||||
@@ -32,6 +32,9 @@
|
||||
<el-form-item :label="$t('tool.supervisor.autoRestart')" prop="autoRestart">
|
||||
<el-switch v-model="process.autoRestart" active-value="true" inactive-value="false"></el-switch>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('tool.supervisor.autoStart')" prop="autoStart">
|
||||
<el-switch v-model="process.autoStart" active-value="true" inactive-value="false"></el-switch>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<span class="dialog-footer">
|
||||
@@ -73,6 +76,7 @@ const initData = (runtimeID: number) => ({
|
||||
numprocs: '1',
|
||||
id: runtimeID,
|
||||
autoRestart: 'true',
|
||||
autoStart: 'true',
|
||||
});
|
||||
const process = ref(initData(0));
|
||||
const em = defineEmits(['close']);
|
||||
@@ -100,6 +104,7 @@ const acceptParams = (operate: string, config: HostTool.SupersivorProcess, id: n
|
||||
numprocs: config.numprocs,
|
||||
id: id,
|
||||
autoRestart: config.autoRestart,
|
||||
autoStart: config.autoStart,
|
||||
};
|
||||
process.value.numprocsNum = Number(config.numprocs);
|
||||
}
|
||||
|
||||
@@ -101,6 +101,7 @@ const search = async () => {
|
||||
form.webSiteGroupId = res.data.webSiteGroupId;
|
||||
form.IPV6 = res.data.IPV6;
|
||||
form.alias = res.data.alias;
|
||||
form.favorite = res.data.favorite;
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user