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