Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion agent/app/service/dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func (u *DashboardService) Restart(operation string) error {
if operation != "1panel" && operation != "system" {
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" {
itemCmd = fmt.Sprintf("%s reboot", cmd.SudoHandleCmd())
}
Expand Down
21 changes: 14 additions & 7 deletions agent/utils/encrypt/encrypt.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,19 @@ func StringEncryptWithBase64(text string) (string, error) {
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) {
if len(text) == 0 {
return "", nil
Expand All @@ -37,13 +50,7 @@ func StringEncrypt(text string) (string, error) {
global.CONF.Base.EncryptKey = encryptSetting.Value
}
key := global.CONF.Base.EncryptKey
pass := []byte(text)
xpass, err := aesEncryptWithSalt([]byte(key), pass)
if err == nil {
pass64 := base64.StdEncoding.EncodeToString(xpass)
return pass64, err
}
return "", err
return StringEncryptWithKey(text, key)
}

func StringDecryptWithBase64(text string) (string, error) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the provided code snippet, there is a conflict between implementing aesEncryptWithSalt and using it directly within StringEncrypt function with key instead of passing it into StringEncryptWithoutSalt. This might lead to confusion on how to pass key while using aesEncrypt method. Additionally, the encryption key should be set from global configuration before using StringEncrypt without salt but this issue will resolve if Key value gets passed along with text during Encrypt call.

Potential areas needing adjustment:

  • Remove duplicate calls to aes encrypt with different key

Suggestion (if not used elsewhere):
If using base64 encoding for encrypted message, consider removing the commented out aes encryption lines that use Base64 encoding directly after each loop iteration which could increase complexity.

Optimization/Simplification Suggestion 1:
Refactor to reduce redundancy. If you decide to keep both implementations and only one gets executed at a time, combine the AES operations inside StringEncrypt() and then use an appropriate encoder based on whether it needs Base64 encoded messages (base64.StdEncoding.EncodeToString()).
Optimization/Simplification Suggestion 2:
Use strings.Replace function to ensure consistent escaping or better yet, always encode the key first regardless of what data structure(s) you have been storing the keys in as long as they're stored separately.

This way, overall, you would avoid conflicts introduced due to inconsistent usage patterns between calling StringEncrypt directly vs through multiple encryptions via the Salted version.
Final Code Implementation Notes:
To further optimize/clarify the usage of key when encrypting text, implement a helper function that accepts text & returns key in case we don't need it globally; also include error handling around checking global variable availability outside its initialization context.
Lastly, since we are modifying encryption logic here, consider updating related comments/documentation sections in other places where the same functionality was implemented in similar contexts. In addition to these general recommendations, you may consult official resources like Go's documentation for best practices and coding guidelines specific to cryptography in C++.

Expand Down
2 changes: 1 addition & 1 deletion agent/utils/files/file_op.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func (f FileOp) CreateDirWithPath(isDir bool, pathItem string) (string, error) {
if !isDir {
checkPath = path.Dir(pathItem)
}
if f.Stat(checkPath) {
if !f.Stat(checkPath) {
if err := f.CreateDir(checkPath, os.ModePerm); err != nil {
global.LOG.Errorf("mkdir %s failed, err: %v", checkPath, err)
return pathItem, err
Expand Down
24 changes: 6 additions & 18 deletions frontend/src/assets/iconfont/iconfont.css
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
@font-face {
font-family: "iconfont"; /* Project id 4776196 */
src: url('iconfont.woff2?t=1738832240410') format('woff2'),
url('iconfont.woff?t=1738832240410') format('woff'),
url('iconfont.ttf?t=1738832240410') format('truetype'),
url('iconfont.svg?t=1738832240410#iconfont') format('svg');
src: url('iconfont.woff2?t=1739873339591') format('woff2'),
url('iconfont.woff?t=1739873339591') format('woff'),
url('iconfont.ttf?t=1739873339591') format('truetype'),
url('iconfont.svg?t=1739873339591#iconfont') format('svg');
}

.iconfont {
Expand All @@ -14,8 +14,8 @@
-moz-osx-font-smoothing: grayscale;
}

.p-terminal3:before {
content: "\eace";
.p-terminal2:before {
content: "\e82f";
}

.p-tuijian:before {
Expand Down Expand Up @@ -70,14 +70,6 @@
content: "\e638";
}

.p-terminal:before {
content: "\e864";
}

.p-terminal1:before {
content: "\e663";
}

.p-arrow-right:before {
content: "\e665";
}
Expand Down Expand Up @@ -386,10 +378,6 @@
content: "\e701";
}

.p-zhongduan:before {
content: "\e61e";
}

.p-17:before {
content: "\e618";
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The difference between the two versions seems to be in CSS selector usage and some inline stylesheet tags. There isn't anything that needs an immediate fix but they are both currently using the same style sheet with no changes needed.

I recommend maintaining this consistency as it is already functioning normally; there's not much value in changing styles just for one part of code while the rest remains unchanged. The current approach doesn't introduce any inconsistencies or breakages.

For now, I will let you maintain this setup without making any further adjustments. For future projects, make sure your coding environment supports all relevant file formats like 'css', 'html' etc. This helps prevent unexpected issues when files from different sources clash due to incompatible extensions. However, since these codes are still quite new and haven’t had time yet to encounter such problems, don't worry about them right now. Keep up the good work!

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/assets/iconfont/iconfont.js

Large diffs are not rendered by default.

29 changes: 4 additions & 25 deletions frontend/src/assets/iconfont/iconfont.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
"description": "",
"glyphs": [
{
"icon_id": "40071541",
"icon_id": "5127551",
"name": "terminal",
"font_class": "terminal3",
"unicode": "eace",
"unicode_decimal": 60110
"font_class": "terminal2",
"unicode": "e82f",
"unicode_decimal": 59439
},
{
"icon_id": "34213658",
Expand Down Expand Up @@ -103,20 +103,6 @@
"unicode": "e638",
"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",
"name": "arrow-right",
Expand Down Expand Up @@ -656,13 +642,6 @@
"unicode": "e701",
"unicode_decimal": 59137
},
{
"icon_id": "11052436",
"name": "命令行",
"font_class": "zhongduan",
"unicode": "e61e",
"unicode_decimal": 58910
},
{
"icon_id": "11124973",
"name": "表单",
Expand Down
8 changes: 1 addition & 7 deletions frontend/src/assets/iconfont/iconfont.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified frontend/src/assets/iconfont/iconfont.ttf
Binary file not shown.
Binary file modified frontend/src/assets/iconfont/iconfont.woff
Binary file not shown.
Binary file modified frontend/src/assets/iconfont/iconfont.woff2
Binary file not shown.
4 changes: 2 additions & 2 deletions frontend/src/components/license-import/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,12 @@ const submit = async () => {
globalStore.themeConfig.themeColor = xpackRes.data.themeColor;
}
loading.value = false;
switchTheme();
initFavicon();
uploadRef.value!.clearFiles();
uploaderFiles.value = [];
open.value = false;
MsgSuccess(i18n.global.t('commons.msg.operationSuccess'));
switchTheme();
initFavicon();
window.location.reload();
})
.catch(() => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To provide a proper answer I need more comprehensive information about the current code provided. Without that, it's difficult to analyze whether there are any irregularities, potential issues or optimizations needed.

However, typically when evaluating such codes related to data management and updates, key components could include:

  • The structure of xpackRes, ensuring all necessary properties have been correctly included.

  • Proper handling of asynchronous actions like clearing input files (uploadRef) with promises is important here especially since it uses a reactive programming technique involving value changes (async/await).

  • Correctly interacting with theme color from x-pack res and applying that in local store is crucial.

Potential Improvements:

  • Ensure loading state transition works smoothly using async functions appropriately. Transition should happen after each action not before.

Potential Issues / Irregularities: None found based on provided snippet details as no specific bugs were mentioned directly above. But remember, errors tend to creep up during large scale rewrites due to different conditions and edge cases.

Optimization Suggestions: Since this function appears standalone in its context, further optimization would lie within understanding what else might be happening at other places where variables 'globalStore', themeConfig, etc. can cause interference if they're improperly shared across threads. Additionally, better use of ES6 modules may also help reduce coupling between parts which can improve readability/maintainability.

In general, please ensure that all aspects including data manipulation, error handling, threading logic, and component states properly interact according to your application requirements and architecture/design decisions (whether done explicitly via stateless/reusable UI components vs a single monolithic app).

Lastly, always look into existing best practices, tutorials, and guidelines while maintaining compatibility with previous versions for backward compatibility purposes.

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/routers/modules/terminal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const terminalRouter = {
redirect: '/terminal',
meta: {
title: 'menu.terminal',
icon: 'p-terminal3',
icon: 'p-terminal2',
},
children: [
{
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/views/setting/license/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ const loadVersion = (row: any) => {
if (row.productPro && row.productPro !== '0') {
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.perpetual');
Expand Down
Loading