Skip to content

Commit 5b8657d

Browse files
authored
Merge pull request #937 from 0xJacky/feat/https
Feat/https
2 parents b1a7866 + 543c054 commit 5b8657d

40 files changed

+2207
-761
lines changed

.vscode/tasks.json

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,61 @@
4343
"isDefault": true
4444
},
4545
"problemMatcher": []
46+
},
47+
{
48+
"label": "[App] Gettext Extract",
49+
"type": "shell",
50+
"command": "cd app && pnpm gettext:extract",
51+
"isBackground": true,
52+
"presentation": {
53+
"panel": "new"
54+
},
55+
"problemMatcher": []
56+
},
57+
{
58+
"label": "[App] ESLint Fix",
59+
"type": "shell",
60+
"command": "cd app && pnpm lint --fix",
61+
"presentation": {
62+
"panel": "new"
63+
},
64+
"problemMatcher": []
65+
},
66+
{
67+
"label": "[App] Typecheck",
68+
"type": "shell",
69+
"command": "cd app && pnpm typecheck",
70+
"presentation": {
71+
"panel": "new"
72+
},
73+
"problemMatcher": []
74+
},
75+
{
76+
"label": "[App] Build",
77+
"type": "shell",
78+
"command": "cd app && pnpm build",
79+
"presentation": {
80+
"panel": "new"
81+
},
82+
"problemMatcher": []
83+
},
84+
{
85+
"label": "Go Generate",
86+
"type": "shell",
87+
"command": "./gen.sh",
88+
"presentation": {
89+
"panel": "new"
90+
},
91+
"problemMatcher": []
92+
},
93+
{
94+
"label": "Bump Version",
95+
"type": "shell",
96+
"command": "./version.sh",
97+
"presentation": {
98+
"panel": "new"
99+
},
100+
"problemMatcher": []
46101
}
47102
]
48-
}
103+
}

api/settings/settings.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,14 @@ package settings
33
import (
44
"fmt"
55
"net/http"
6+
"time"
67

78
"github.com/0xJacky/Nginx-UI/internal/cron"
89
"github.com/0xJacky/Nginx-UI/internal/nginx"
10+
"github.com/0xJacky/Nginx-UI/internal/system"
911
"github.com/0xJacky/Nginx-UI/settings"
1012
"github.com/gin-gonic/gin"
13+
"github.com/jpillora/overseer"
1114
"github.com/uozi-tech/cosy"
1215
cSettings "github.com/uozi-tech/cosy/settings"
1316
)
@@ -61,6 +64,8 @@ func GetSettings(c *gin.Context) {
6164

6265
func SaveSettings(c *gin.Context) {
6366
var json struct {
67+
App cSettings.App `json:"app"`
68+
Server cSettings.Server `json:"server"`
6469
Auth settings.Auth `json:"auth"`
6570
Cert settings.Cert `json:"cert"`
6671
Http settings.HTTP `json:"http"`
@@ -78,6 +83,22 @@ func SaveSettings(c *gin.Context) {
7883
go cron.RestartLogrotate()
7984
}
8085

86+
// Validate SSL certificates if HTTPS is enabled
87+
needRestart := false
88+
if json.Server.EnableHTTPS != cSettings.ServerSettings.EnableHTTPS {
89+
needRestart = true
90+
}
91+
92+
if json.Server.EnableHTTPS {
93+
err := system.ValidateSSLCertificates(json.Server.SSLCert, json.Server.SSLKey)
94+
if err != nil {
95+
cosy.ErrHandler(c, err)
96+
return
97+
}
98+
}
99+
100+
cSettings.ProtectedFill(cSettings.AppSettings, &json.App)
101+
cSettings.ProtectedFill(cSettings.ServerSettings, &json.Server)
81102
cSettings.ProtectedFill(settings.AuthSettings, &json.Auth)
82103
cSettings.ProtectedFill(settings.CertSettings, &json.Cert)
83104
cSettings.ProtectedFill(settings.HTTPSettings, &json.Http)
@@ -91,5 +112,12 @@ func SaveSettings(c *gin.Context) {
91112
return
92113
}
93114

115+
if needRestart {
116+
go func() {
117+
time.Sleep(2 * time.Second)
118+
overseer.Restart()
119+
}()
120+
}
121+
94122
GetSettings(c)
95123
}

app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "nginx-ui-app-next",
33
"type": "module",
4-
"version": "2.0.0-rc.4",
4+
"version": "2.0.0-rc.5",
55
"packageManager": "pnpm@10.7.0+sha512.6b865ad4b62a1d9842b61d674a393903b871d9244954f652b8842c2b553c72176b278f64c463e52d40fff8aba385c235c8c9ecf5cc7de4fd78b8bb6d49633ab6",
66
"scripts": {
77
"dev": "vite --host",

app/src/api/settings.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ export interface ServerSettings {
99
host: string
1010
port: number
1111
run_mode: 'debug' | 'release'
12+
enable_https: boolean
13+
ssl_cert: string
14+
ssl_key: string
1215
}
1316

1417
export interface DatabaseSettings {
@@ -54,15 +57,19 @@ export interface NginxSettings {
5457
access_log_path: string
5558
error_log_path: string
5659
config_dir: string
60+
config_path: string
5761
log_dir_white_list: string[]
5862
pid_path: string
63+
test_config_cmd: string
5964
reload_cmd: string
6065
restart_cmd: string
6166
}
6267

6368
export interface NodeSettings {
6469
name: string
6570
secret: string
71+
skip_installation: boolean
72+
demo: boolean
6673
icp_number: string
6774
public_security_number: string
6875
}

app/src/components/Chart/UsageProgressLine.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import { computed } from 'vue'
33
44
const props = withDefaults(defineProps<{
5-
percent: number
5+
percent?: number
66
}>(), {
77
percent: 0,
88
})
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
export default {
22
40000: () => $gettext('Invalid request format'),
33
40001: () => $gettext('Decryption failed'),
4+
40002: () => $gettext('Form parse failed'),
45
}

app/src/constants/errors/system.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
export default {
22
40301: () => $gettext('Nginx UI already installed'),
33
40302: () => $gettext('Installation is not allowed after 10 minutes of system startup'),
4+
40303: () => $gettext('SSL certificate path is required when HTTPS is enabled'),
5+
40304: () => $gettext('SSL key path is required when HTTPS is enabled'),
6+
40305: () => $gettext('SSL certificate file not found'),
7+
40306: () => $gettext('SSL key file not found'),
8+
40307: () => $gettext('SSL certificate file must be under Nginx configuration directory: {0}'),
9+
40308: () => $gettext('SSL key file must be under Nginx configuration directory: {0}'),
410
}

0 commit comments

Comments
 (0)