1
0
mirror of https://github.com/1Panel-dev/1Panel.git synced 2025-02-28 19:14:13 +08:00

feat: Optimize encryption method (#7908)

This commit is contained in:
ssongliu 2025-02-19 15:38:14 +08:00 committed by GitHub
parent b6dcf33114
commit 79ecd60ea8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
13 changed files with 32 additions and 64 deletions

View File

@ -81,7 +81,7 @@ func (u *DashboardService) Restart(operation string) error {
if operation != "1panel" && operation != "system" { if operation != "1panel" && operation != "system" {
return fmt.Errorf("handle restart operation %s failed, err: nonsupport such operation", operation) return fmt.Errorf("handle restart operation %s failed, err: nonsupport such operation", operation)
} }
itemCmd := fmt.Sprintf("%s systemctl restart 1panel.service", cmd.SudoHandleCmd()) itemCmd := fmt.Sprintf("%s systemctl restart 1panel-agent.service", cmd.SudoHandleCmd())
if operation == "system" { if operation == "system" {
itemCmd = fmt.Sprintf("%s reboot", cmd.SudoHandleCmd()) itemCmd = fmt.Sprintf("%s reboot", cmd.SudoHandleCmd())
} }

View File

@ -25,6 +25,19 @@ func StringEncryptWithBase64(text string) (string, error) {
return encryptKeyItem, nil return encryptKeyItem, nil
} }
func StringEncryptWithKey(text, key string) (string, error) {
if len(text) == 0 {
return "", nil
}
pass := []byte(text)
xpass, err := aesEncryptWithSalt([]byte(key), pass)
if err == nil {
pass64 := base64.StdEncoding.EncodeToString(xpass)
return pass64, err
}
return "", err
}
func StringEncrypt(text string) (string, error) { func StringEncrypt(text string) (string, error) {
if len(text) == 0 { if len(text) == 0 {
return "", nil return "", nil
@ -37,13 +50,7 @@ func StringEncrypt(text string) (string, error) {
global.CONF.Base.EncryptKey = encryptSetting.Value global.CONF.Base.EncryptKey = encryptSetting.Value
} }
key := global.CONF.Base.EncryptKey key := global.CONF.Base.EncryptKey
pass := []byte(text) return StringEncryptWithKey(text, key)
xpass, err := aesEncryptWithSalt([]byte(key), pass)
if err == nil {
pass64 := base64.StdEncoding.EncodeToString(xpass)
return pass64, err
}
return "", err
} }
func StringDecryptWithBase64(text string) (string, error) { func StringDecryptWithBase64(text string) (string, error) {

View File

@ -69,7 +69,7 @@ func (f FileOp) CreateDirWithPath(isDir bool, pathItem string) (string, error) {
if !isDir { if !isDir {
checkPath = path.Dir(pathItem) checkPath = path.Dir(pathItem)
} }
if f.Stat(checkPath) { if !f.Stat(checkPath) {
if err := f.CreateDir(checkPath, os.ModePerm); err != nil { if err := f.CreateDir(checkPath, os.ModePerm); err != nil {
global.LOG.Errorf("mkdir %s failed, err: %v", checkPath, err) global.LOG.Errorf("mkdir %s failed, err: %v", checkPath, err)
return pathItem, err return pathItem, err

View File

@ -1,9 +1,9 @@
@font-face { @font-face {
font-family: "iconfont"; /* Project id 4776196 */ font-family: "iconfont"; /* Project id 4776196 */
src: url('iconfont.woff2?t=1738832240410') format('woff2'), src: url('iconfont.woff2?t=1739873339591') format('woff2'),
url('iconfont.woff?t=1738832240410') format('woff'), url('iconfont.woff?t=1739873339591') format('woff'),
url('iconfont.ttf?t=1738832240410') format('truetype'), url('iconfont.ttf?t=1739873339591') format('truetype'),
url('iconfont.svg?t=1738832240410#iconfont') format('svg'); url('iconfont.svg?t=1739873339591#iconfont') format('svg');
} }
.iconfont { .iconfont {
@ -14,8 +14,8 @@
-moz-osx-font-smoothing: grayscale; -moz-osx-font-smoothing: grayscale;
} }
.p-terminal3:before { .p-terminal2:before {
content: "\eace"; content: "\e82f";
} }
.p-tuijian:before { .p-tuijian:before {
@ -70,14 +70,6 @@
content: "\e638"; content: "\e638";
} }
.p-terminal:before {
content: "\e864";
}
.p-terminal1:before {
content: "\e663";
}
.p-arrow-right:before { .p-arrow-right:before {
content: "\e665"; content: "\e665";
} }
@ -386,10 +378,6 @@
content: "\e701"; content: "\e701";
} }
.p-zhongduan:before {
content: "\e61e";
}
.p-17:before { .p-17:before {
content: "\e618"; content: "\e618";
} }

File diff suppressed because one or more lines are too long

View File

@ -6,11 +6,11 @@
"description": "", "description": "",
"glyphs": [ "glyphs": [
{ {
"icon_id": "40071541", "icon_id": "5127551",
"name": "terminal", "name": "terminal",
"font_class": "terminal3", "font_class": "terminal2",
"unicode": "eace", "unicode": "e82f",
"unicode_decimal": 60110 "unicode_decimal": 59439
}, },
{ {
"icon_id": "34213658", "icon_id": "34213658",
@ -103,20 +103,6 @@
"unicode": "e638", "unicode": "e638",
"unicode_decimal": 58936 "unicode_decimal": 58936
}, },
{
"icon_id": "6172786",
"name": "terminal",
"font_class": "terminal",
"unicode": "e864",
"unicode_decimal": 59492
},
{
"icon_id": "14772948",
"name": "terminal",
"font_class": "terminal1",
"unicode": "e663",
"unicode_decimal": 58979
},
{ {
"icon_id": "15838431", "icon_id": "15838431",
"name": "arrow-right", "name": "arrow-right",
@ -656,13 +642,6 @@
"unicode": "e701", "unicode": "e701",
"unicode_decimal": 59137 "unicode_decimal": 59137
}, },
{
"icon_id": "11052436",
"name": "命令行",
"font_class": "zhongduan",
"unicode": "e61e",
"unicode_decimal": 58910
},
{ {
"icon_id": "11124973", "icon_id": "11124973",
"name": "表单", "name": "表单",

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 167 KiB

After

Width:  |  Height:  |  Size: 165 KiB

View File

@ -111,12 +111,12 @@ const submit = async () => {
globalStore.themeConfig.themeColor = xpackRes.data.themeColor; globalStore.themeConfig.themeColor = xpackRes.data.themeColor;
} }
loading.value = false; loading.value = false;
switchTheme();
initFavicon();
uploadRef.value!.clearFiles(); uploadRef.value!.clearFiles();
uploaderFiles.value = []; uploaderFiles.value = [];
open.value = false; open.value = false;
MsgSuccess(i18n.global.t('commons.msg.operationSuccess')); MsgSuccess(i18n.global.t('commons.msg.operationSuccess'));
switchTheme();
initFavicon();
window.location.reload(); window.location.reload();
}) })
.catch(() => { .catch(() => {

View File

@ -7,7 +7,7 @@ const terminalRouter = {
redirect: '/terminal', redirect: '/terminal',
meta: { meta: {
title: 'menu.terminal', title: 'menu.terminal',
icon: 'p-terminal3', icon: 'p-terminal2',
}, },
children: [ children: [
{ {

View File

@ -211,7 +211,7 @@ const loadVersion = (row: any) => {
if (row.productPro && row.productPro !== '0') { if (row.productPro && row.productPro !== '0') {
return i18n.global.t('license.subscription') + ' [ ' + row.expiresAt + ' ] '; return i18n.global.t('license.subscription') + ' [ ' + row.expiresAt + ' ] ';
} }
if (row.versionConstraint !== 'all') { if (row.versionConstraint && row.versionConstraint !== 'all') {
return i18n.global.t('license.versionConstraint', ['v' + row.versionConstraint.replace('.x', '')]); return i18n.global.t('license.versionConstraint', ['v' + row.versionConstraint.replace('.x', '')]);
} }
return i18n.global.t('license.perpetual'); return i18n.global.t('license.perpetual');