Skip to content

Commit 79ecd60

Browse files
authored
feat: Optimize encryption method (#7908)
1 parent b6dcf33 commit 79ecd60

File tree

13 files changed

+32
-64
lines changed

13 files changed

+32
-64
lines changed

agent/app/service/dashboard.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ func (u *DashboardService) Restart(operation string) error {
8181
if operation != "1panel" && operation != "system" {
8282
return fmt.Errorf("handle restart operation %s failed, err: nonsupport such operation", operation)
8383
}
84-
itemCmd := fmt.Sprintf("%s systemctl restart 1panel.service", cmd.SudoHandleCmd())
84+
itemCmd := fmt.Sprintf("%s systemctl restart 1panel-agent.service", cmd.SudoHandleCmd())
8585
if operation == "system" {
8686
itemCmd = fmt.Sprintf("%s reboot", cmd.SudoHandleCmd())
8787
}

agent/utils/encrypt/encrypt.go

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,19 @@ func StringEncryptWithBase64(text string) (string, error) {
2525
return encryptKeyItem, nil
2626
}
2727

28+
func StringEncryptWithKey(text, key string) (string, error) {
29+
if len(text) == 0 {
30+
return "", nil
31+
}
32+
pass := []byte(text)
33+
xpass, err := aesEncryptWithSalt([]byte(key), pass)
34+
if err == nil {
35+
pass64 := base64.StdEncoding.EncodeToString(xpass)
36+
return pass64, err
37+
}
38+
return "", err
39+
}
40+
2841
func StringEncrypt(text string) (string, error) {
2942
if len(text) == 0 {
3043
return "", nil
@@ -37,13 +50,7 @@ func StringEncrypt(text string) (string, error) {
3750
global.CONF.Base.EncryptKey = encryptSetting.Value
3851
}
3952
key := global.CONF.Base.EncryptKey
40-
pass := []byte(text)
41-
xpass, err := aesEncryptWithSalt([]byte(key), pass)
42-
if err == nil {
43-
pass64 := base64.StdEncoding.EncodeToString(xpass)
44-
return pass64, err
45-
}
46-
return "", err
53+
return StringEncryptWithKey(text, key)
4754
}
4855

4956
func StringDecryptWithBase64(text string) (string, error) {

agent/utils/files/file_op.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ func (f FileOp) CreateDirWithPath(isDir bool, pathItem string) (string, error) {
6969
if !isDir {
7070
checkPath = path.Dir(pathItem)
7171
}
72-
if f.Stat(checkPath) {
72+
if !f.Stat(checkPath) {
7373
if err := f.CreateDir(checkPath, os.ModePerm); err != nil {
7474
global.LOG.Errorf("mkdir %s failed, err: %v", checkPath, err)
7575
return pathItem, err

frontend/src/assets/iconfont/iconfont.css

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
@font-face {
22
font-family: "iconfont"; /* Project id 4776196 */
3-
src: url('iconfont.woff2?t=1738832240410') format('woff2'),
4-
url('iconfont.woff?t=1738832240410') format('woff'),
5-
url('iconfont.ttf?t=1738832240410') format('truetype'),
6-
url('iconfont.svg?t=1738832240410#iconfont') format('svg');
3+
src: url('iconfont.woff2?t=1739873339591') format('woff2'),
4+
url('iconfont.woff?t=1739873339591') format('woff'),
5+
url('iconfont.ttf?t=1739873339591') format('truetype'),
6+
url('iconfont.svg?t=1739873339591#iconfont') format('svg');
77
}
88

99
.iconfont {
@@ -14,8 +14,8 @@
1414
-moz-osx-font-smoothing: grayscale;
1515
}
1616

17-
.p-terminal3:before {
18-
content: "\eace";
17+
.p-terminal2:before {
18+
content: "\e82f";
1919
}
2020

2121
.p-tuijian:before {
@@ -70,14 +70,6 @@
7070
content: "\e638";
7171
}
7272

73-
.p-terminal:before {
74-
content: "\e864";
75-
}
76-
77-
.p-terminal1:before {
78-
content: "\e663";
79-
}
80-
8173
.p-arrow-right:before {
8274
content: "\e665";
8375
}
@@ -386,10 +378,6 @@
386378
content: "\e701";
387379
}
388380

389-
.p-zhongduan:before {
390-
content: "\e61e";
391-
}
392-
393381
.p-17:before {
394382
content: "\e618";
395383
}

frontend/src/assets/iconfont/iconfont.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/src/assets/iconfont/iconfont.json

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
"description": "",
77
"glyphs": [
88
{
9-
"icon_id": "40071541",
9+
"icon_id": "5127551",
1010
"name": "terminal",
11-
"font_class": "terminal3",
12-
"unicode": "eace",
13-
"unicode_decimal": 60110
11+
"font_class": "terminal2",
12+
"unicode": "e82f",
13+
"unicode_decimal": 59439
1414
},
1515
{
1616
"icon_id": "34213658",
@@ -103,20 +103,6 @@
103103
"unicode": "e638",
104104
"unicode_decimal": 58936
105105
},
106-
{
107-
"icon_id": "6172786",
108-
"name": "terminal",
109-
"font_class": "terminal",
110-
"unicode": "e864",
111-
"unicode_decimal": 59492
112-
},
113-
{
114-
"icon_id": "14772948",
115-
"name": "terminal",
116-
"font_class": "terminal1",
117-
"unicode": "e663",
118-
"unicode_decimal": 58979
119-
},
120106
{
121107
"icon_id": "15838431",
122108
"name": "arrow-right",
@@ -656,13 +642,6 @@
656642
"unicode": "e701",
657643
"unicode_decimal": 59137
658644
},
659-
{
660-
"icon_id": "11052436",
661-
"name": "命令行",
662-
"font_class": "zhongduan",
663-
"unicode": "e61e",
664-
"unicode_decimal": 58910
665-
},
666645
{
667646
"icon_id": "11124973",
668647
"name": "表单",

frontend/src/assets/iconfont/iconfont.svg

Lines changed: 1 addition & 7 deletions
Loading
-520 Bytes
Binary file not shown.
-264 Bytes
Binary file not shown.
-172 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)