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
57 changes: 56 additions & 1 deletion .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,61 @@
"isDefault": true
},
"problemMatcher": []
},
{
"label": "[App] Gettext Extract",
"type": "shell",
"command": "cd app && pnpm gettext:extract",
"isBackground": true,
"presentation": {
"panel": "new"
},
"problemMatcher": []
},
{
"label": "[App] ESLint Fix",
"type": "shell",
"command": "cd app && pnpm lint --fix",
"presentation": {
"panel": "new"
},
"problemMatcher": []
},
{
"label": "[App] Typecheck",
"type": "shell",
"command": "cd app && pnpm typecheck",
"presentation": {
"panel": "new"
},
"problemMatcher": []
},
{
"label": "[App] Build",
"type": "shell",
"command": "cd app && pnpm build",
"presentation": {
"panel": "new"
},
"problemMatcher": []
},
{
"label": "Go Generate",
"type": "shell",
"command": "./gen.sh",
"presentation": {
"panel": "new"
},
"problemMatcher": []
},
{
"label": "Bump Version",
"type": "shell",
"command": "./version.sh",
"presentation": {
"panel": "new"
},
"problemMatcher": []
}
]
}
}
28 changes: 28 additions & 0 deletions api/settings/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@ package settings
import (
"fmt"
"net/http"
"time"

"github.com/0xJacky/Nginx-UI/internal/cron"
"github.com/0xJacky/Nginx-UI/internal/nginx"
"github.com/0xJacky/Nginx-UI/internal/system"
"github.com/0xJacky/Nginx-UI/settings"
"github.com/gin-gonic/gin"
"github.com/jpillora/overseer"
"github.com/uozi-tech/cosy"
cSettings "github.com/uozi-tech/cosy/settings"
)
Expand Down Expand Up @@ -61,6 +64,8 @@ func GetSettings(c *gin.Context) {

func SaveSettings(c *gin.Context) {
var json struct {
App cSettings.App `json:"app"`
Server cSettings.Server `json:"server"`
Auth settings.Auth `json:"auth"`
Cert settings.Cert `json:"cert"`
Http settings.HTTP `json:"http"`
Expand All @@ -78,6 +83,22 @@ func SaveSettings(c *gin.Context) {
go cron.RestartLogrotate()
}

// Validate SSL certificates if HTTPS is enabled
needRestart := false
if json.Server.EnableHTTPS != cSettings.ServerSettings.EnableHTTPS {
needRestart = true
}

if json.Server.EnableHTTPS {
err := system.ValidateSSLCertificates(json.Server.SSLCert, json.Server.SSLKey)
if err != nil {
cosy.ErrHandler(c, err)
return
}
}

cSettings.ProtectedFill(cSettings.AppSettings, &json.App)
cSettings.ProtectedFill(cSettings.ServerSettings, &json.Server)
cSettings.ProtectedFill(settings.AuthSettings, &json.Auth)
cSettings.ProtectedFill(settings.CertSettings, &json.Cert)
cSettings.ProtectedFill(settings.HTTPSettings, &json.Http)
Expand All @@ -91,5 +112,12 @@ func SaveSettings(c *gin.Context) {
return
}

if needRestart {
go func() {
time.Sleep(2 * time.Second)
overseer.Restart()
}()
}

GetSettings(c)
}
2 changes: 1 addition & 1 deletion app/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "nginx-ui-app-next",
"type": "module",
"version": "2.0.0-rc.4",
"version": "2.0.0-rc.5",
"packageManager": "pnpm@10.7.0+sha512.6b865ad4b62a1d9842b61d674a393903b871d9244954f652b8842c2b553c72176b278f64c463e52d40fff8aba385c235c8c9ecf5cc7de4fd78b8bb6d49633ab6",
"scripts": {
"dev": "vite --host",
Expand Down
7 changes: 7 additions & 0 deletions app/src/api/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ export interface ServerSettings {
host: string
port: number
run_mode: 'debug' | 'release'
enable_https: boolean
ssl_cert: string
ssl_key: string
}

export interface DatabaseSettings {
Expand Down Expand Up @@ -54,15 +57,19 @@ export interface NginxSettings {
access_log_path: string
error_log_path: string
config_dir: string
config_path: string
log_dir_white_list: string[]
pid_path: string
test_config_cmd: string
reload_cmd: string
restart_cmd: string
}

export interface NodeSettings {
name: string
secret: string
skip_installation: boolean
demo: boolean
icp_number: string
public_security_number: string
}
Expand Down
2 changes: 1 addition & 1 deletion app/src/components/Chart/UsageProgressLine.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { computed } from 'vue'

const props = withDefaults(defineProps<{
percent: number
percent?: number
}>(), {
percent: 0,
})
Expand Down
1 change: 1 addition & 0 deletions app/src/constants/errors/middleware.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export default {
40000: () => $gettext('Invalid request format'),
40001: () => $gettext('Decryption failed'),
40002: () => $gettext('Form parse failed'),
}
6 changes: 6 additions & 0 deletions app/src/constants/errors/system.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
export default {
40301: () => $gettext('Nginx UI already installed'),
40302: () => $gettext('Installation is not allowed after 10 minutes of system startup'),
40303: () => $gettext('SSL certificate path is required when HTTPS is enabled'),
40304: () => $gettext('SSL key path is required when HTTPS is enabled'),
40305: () => $gettext('SSL certificate file not found'),
40306: () => $gettext('SSL key file not found'),
40307: () => $gettext('SSL certificate file must be under Nginx configuration directory: {0}'),
40308: () => $gettext('SSL key file must be under Nginx configuration directory: {0}'),
}
Loading