diff --git a/api/system/install.go b/api/system/install.go index 533b39ea..bfac832c 100644 --- a/api/system/install.go +++ b/api/system/install.go @@ -2,7 +2,7 @@ package system import ( "github.com/0xJacky/Nginx-UI/api" - "github.com/0xJacky/Nginx-UI/internal/kernal" + "github.com/0xJacky/Nginx-UI/internal/kernel" "github.com/0xJacky/Nginx-UI/model" "github.com/0xJacky/Nginx-UI/query" "github.com/0xJacky/Nginx-UI/settings" @@ -58,7 +58,7 @@ func InstallNginxUI(c *gin.Context) { } // Init model - kernal.InitDatabase() + kernel.InitDatabase() pwd, _ := bcrypt.GenerateFromPassword([]byte(json.Password), bcrypt.DefaultCost) diff --git a/app/components.d.ts b/app/components.d.ts index 89bb9ba5..42e75225 100644 --- a/app/components.d.ts +++ b/app/components.d.ts @@ -49,8 +49,6 @@ declare module 'vue' { APopconfirm: typeof import('ant-design-vue/es')['Popconfirm'] APopover: typeof import('ant-design-vue/es')['Popover'] AProgress: typeof import('ant-design-vue/es')['Progress'] - ARadioButton: typeof import('ant-design-vue/es')['RadioButton'] - ARadioGroup: typeof import('ant-design-vue/es')['RadioGroup'] AResult: typeof import('ant-design-vue/es')['Result'] ARow: typeof import('ant-design-vue/es')['Row'] ASelect: typeof import('ant-design-vue/es')['Select'] diff --git a/app/package.json b/app/package.json index 6b5674b4..627c3db1 100644 --- a/app/package.json +++ b/app/package.json @@ -1,7 +1,7 @@ { "name": "nginx-ui-app-next", "type": "module", - "version": "2.0.0-beta.36", + "version": "2.0.0-beta.37", "packageManager": "pnpm@9.12.2", "scripts": { "dev": "vite --host", @@ -54,10 +54,10 @@ "@antfu/eslint-config": "^3.8.0", "@iconify-json/fa": "1.1.5", "@iconify-json/tabler": "1.1.95", - "@iconify/tools": "3.0.5", + "@iconify/tools": "^4.0.7", "@iconify/types": "^2.0.0", "@iconify/utils": "^2.1.33", - "@iconify/vue": "4.1.1", + "@iconify/vue": "^4.1.2", "@simplewebauthn/types": "^11.0.0", "@types/lodash": "^4.17.12", "@types/nprogress": "^0.2.3", diff --git a/app/pnpm-lock.yaml b/app/pnpm-lock.yaml index 5dee75a9..b3e016cf 100644 --- a/app/pnpm-lock.yaml +++ b/app/pnpm-lock.yaml @@ -127,8 +127,8 @@ importers: specifier: 1.1.95 version: 1.1.95 '@iconify/tools': - specifier: 3.0.5 - version: 3.0.5 + specifier: ^4.0.7 + version: 4.0.7 '@iconify/types': specifier: ^2.0.0 version: 2.0.0 @@ -136,8 +136,8 @@ importers: specifier: ^2.1.33 version: 2.1.33 '@iconify/vue': - specifier: 4.1.1 - version: 4.1.1(vue@3.5.12(typescript@5.6.3)) + specifier: ^4.1.2 + version: 4.1.2(vue@3.5.12(typescript@5.6.3)) '@simplewebauthn/types': specifier: ^11.0.0 version: 11.0.0 @@ -1329,8 +1329,8 @@ packages: '@iconify-json/tabler@1.1.95': resolution: {integrity: sha512-Qg+VpKgSImpA9g2ger17cWIBvirlixUplTXshu/miegBCfaicYEyyX2pCilCJEuujeNVh47+ySD7CoBJS2f6pQ==} - '@iconify/tools@3.0.5': - resolution: {integrity: sha512-NYhdaOK/pPTInlNRQHP1iaOMQtu6XfIjhYh8KBUqAiKlmSWwjWYT4bm8RpNgtgEmYAYrm2PY28A2OGBP35pA1w==} + '@iconify/tools@4.0.7': + resolution: {integrity: sha512-zOJxKIfZn96ZRGGvIWzDRLD9vb2CsxjcLuM+QIdvwWbv6SWhm49gECzUnd4d2P0sq9sfodT7yCNobWK8nvavxQ==} '@iconify/types@2.0.0': resolution: {integrity: sha512-+wluvCrRhXrhyOmRDJ3q8mux9JkKy5SJ/v8ol2tu4FVjyYvtEzkc/3pK15ET6RKg4b4w4BmTk1+gsCUhf21Ykg==} @@ -1338,8 +1338,8 @@ packages: '@iconify/utils@2.1.33': resolution: {integrity: sha512-jP9h6v/g0BIZx0p7XGJJVtkVnydtbgTgt9mVNcGDYwaa7UhdHdI9dvoq+gKj9sijMSJKxUPEG2JyjsgXjxL7Kw==} - '@iconify/vue@4.1.1': - resolution: {integrity: sha512-RL85Bm/DAe8y6rT6pux7D2FJSiUEM/TPfyK7GrbAOfTSwrhvwJW+S5yijdGcmtXouA8MtuH9C7l4hiSE4mLMjg==} + '@iconify/vue@4.1.2': + resolution: {integrity: sha512-CQnYqLiQD5LOAaXhBrmj1mdL2/NCJvwcC4jtW2Z8ukhThiFkLDkutarTOV2trfc9EXqUqRs0KqXOL9pZ/IyysA==} peerDependencies: vue: '>=3' @@ -1514,9 +1514,6 @@ packages: resolution: {integrity: sha512-L7z9BgrNEcYyUYtF+HaEfiS5ebkh9jXqbszz7pC0hRBPaatV0XjSD3+eHrpqFemQfgwiFF0QPIarnIihIDn7OA==} engines: {node: '>=10.13.0'} - '@types/cheerio@0.22.35': - resolution: {integrity: sha512-yD57BchKRvTV+JD53UZ6PD8KWY5g5rvvMLRnZR3EQBCZXiDT/HR+pKpMzFGlWNhFrXlo7VPZXtKvIEwZkAWOIA==} - '@types/cookie@0.6.0': resolution: {integrity: sha512-4Kh9a6B2bQciAhf7FSuMRRkUWecJgJu9nPnx3yzpsfXX/c50REIqpHY4C82bXP90qrLtXtkDxTZosYO3UpOwlA==} @@ -3384,10 +3381,6 @@ packages: resolution: {integrity: sha512-IXO6OCs9yg8tMKzfPZ1YmheJbZCiEsnBdcB03l0OcfK9prKnJb96siuHCr5Fl37/yo9DnKU+TLpxzTUspw9shg==} engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} - local-pkg@0.4.3: - resolution: {integrity: sha512-SFppqq5p42fe2qcZQqqEOiVRXl+WCP1MdT6k7BDEW1j++sp5fIY+/fdRQitvKgB5BrBcmrs5m/L0v2FrU5MY1g==} - engines: {node: '>=14'} - local-pkg@0.5.0: resolution: {integrity: sha512-ok6z3qlYyCDS4ZEU27HaU6x/xZa9Whf8jD4ptH5UZTQYZVYeb9bnZ3ojVhiJNLiXK1Hfc0GNbLXcmZ5plLDDBg==} engines: {node: '>=14'} @@ -6080,19 +6073,21 @@ snapshots: dependencies: '@iconify/types': 2.0.0 - '@iconify/tools@3.0.5': + '@iconify/tools@4.0.7': dependencies: '@iconify/types': 2.0.0 '@iconify/utils': 2.1.33 - '@types/cheerio': 0.22.35 '@types/tar': 6.1.13 + axios: 1.7.7 cheerio: 1.0.0 + domhandler: 5.0.3 extract-zip: 2.0.1 - local-pkg: 0.4.3 + local-pkg: 0.5.0 pathe: 1.1.2 svgo: 3.3.2 tar: 6.2.1 transitivePeerDependencies: + - debug - supports-color '@iconify/types@2.0.0': {} @@ -6109,7 +6104,7 @@ snapshots: transitivePeerDependencies: - supports-color - '@iconify/vue@4.1.1(vue@3.5.12(typescript@5.6.3))': + '@iconify/vue@4.1.2(vue@3.5.12(typescript@5.6.3))': dependencies: '@iconify/types': 2.0.0 vue: 3.5.12(typescript@5.6.3) @@ -6295,10 +6290,6 @@ snapshots: '@trysound/sax@0.2.0': {} - '@types/cheerio@0.22.35': - dependencies: - '@types/node': 22.7.9 - '@types/cookie@0.6.0': {} '@types/debug@4.1.12': @@ -8637,8 +8628,6 @@ snapshots: load-tsconfig@0.2.5: {} - local-pkg@0.4.3: {} - local-pkg@0.5.0: dependencies: mlly: 1.7.2 diff --git a/app/src/version.json b/app/src/version.json index ecfa7a49..e09f2c99 100644 --- a/app/src/version.json +++ b/app/src/version.json @@ -1 +1 @@ -{"version":"2.0.0-beta.36","build_id":1,"total_build":365} \ No newline at end of file +{"version":"2.0.0-beta.37","build_id":1,"total_build":366} \ No newline at end of file diff --git a/go.mod b/go.mod index 2046747a..a35ba12c 100644 --- a/go.mod +++ b/go.mod @@ -35,7 +35,7 @@ require ( github.com/spf13/cast v1.7.0 github.com/stretchr/testify v1.9.0 github.com/tufanbarisyildirim/gonginx v0.0.0-20241013191809-e73b7dd454e8 - github.com/uozi-tech/cosy v1.9.8 + github.com/uozi-tech/cosy v1.9.9 github.com/uozi-tech/cosy-driver-sqlite v0.2.0 go.uber.org/zap v1.27.0 golang.org/x/crypto v0.28.0 diff --git a/go.sum b/go.sum index 6e283a2d..778a2e8c 100644 --- a/go.sum +++ b/go.sum @@ -39,6 +39,7 @@ cloud.google.com/go v0.104.0/go.mod h1:OO6xxXdJyvuJPcEPBLN9BJPD+jep5G1+2U5B5gkRY cloud.google.com/go v0.105.0/go.mod h1:PrLgOJNe5nfE9UMxKxgXj4mD3voiP+YQ6gdt6KMFOKM= cloud.google.com/go v0.107.0/go.mod h1:wpc2eNrD7hXUTy8EKS10jkxpZBjASrORK7goS+3YX2I= cloud.google.com/go v0.110.0/go.mod h1:SJnCLqQ0FCFGSZMUNUf84MV3Aia54kn7pi8st7tMzaY= +cloud.google.com/go v0.116.0 h1:B3fRrSDkLRt5qSHWe40ERJvhvnQwdZiHu0bJOpldweE= cloud.google.com/go/accessapproval v1.4.0/go.mod h1:zybIuC3KpDOvotz59lFe5qxRZx6C75OtwbisN56xYB4= cloud.google.com/go/accessapproval v1.5.0/go.mod h1:HFy3tuiGvMdcd/u+Cu5b9NkO1pEICJ46IR82PoUdplw= cloud.google.com/go/accessapproval v1.6.0/go.mod h1:R0EiYnwV5fsRFiKZkPHr6mwyk2wxUJ30nL4j2pcFY2E= @@ -760,6 +761,7 @@ github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyY github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/census-instrumentation/opencensus-proto v0.3.0/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/census-instrumentation/opencensus-proto v0.4.1/go.mod h1:4T9NM4+4Vw91VeyqjLS6ao50K5bOcLKN6Q42XnYaRYw= +github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= @@ -1674,6 +1676,8 @@ github.com/uozi-tech/cosy v1.9.4 h1:oG5TbrS8XUpZnQ++9gxI5if0++uJ7h9nMPZPNeDgly0= github.com/uozi-tech/cosy v1.9.4/go.mod h1:aQI/OU3EVF125K5ECgSg3+CTfG4cp5XOkr++DEP/Fas= github.com/uozi-tech/cosy v1.9.8 h1:c3xKdG9Pa3PqRVjxr2teDjAGe0PNcFs1X5/fCiROkbY= github.com/uozi-tech/cosy v1.9.8/go.mod h1:aQI/OU3EVF125K5ECgSg3+CTfG4cp5XOkr++DEP/Fas= +github.com/uozi-tech/cosy v1.9.9 h1:hA8R9Q0JuykDG1G6WO62cgi2oxJyONrjdg525Xu7AG0= +github.com/uozi-tech/cosy v1.9.9/go.mod h1:aQI/OU3EVF125K5ECgSg3+CTfG4cp5XOkr++DEP/Fas= github.com/uozi-tech/cosy-driver-mysql v0.2.2 h1:22S/XNIvuaKGqxQPsYPXN8TZ8hHjCQdcJKVQ83Vzxoo= github.com/uozi-tech/cosy-driver-mysql v0.2.2/go.mod h1:EZnRIbSj1V5U0gEeTobrXai/d1SV11lkl4zP9NFEmyE= github.com/uozi-tech/cosy-driver-postgres v0.2.1 h1:OICakGuT+omva6QOJCxTJ5Lfr7CGXLmk/zD+aS51Z2o= diff --git a/img.png b/img.png deleted file mode 100644 index c1c9d3fb..00000000 Binary files a/img.png and /dev/null differ diff --git a/internal/kernal/boot.go b/internal/kernel/boot.go similarity index 98% rename from internal/kernal/boot.go rename to internal/kernel/boot.go index 8cb59659..5a7eb57f 100644 --- a/internal/kernal/boot.go +++ b/internal/kernel/boot.go @@ -1,4 +1,4 @@ -package kernal +package kernel import ( "crypto/rand" @@ -27,7 +27,6 @@ func Boot() { defer recovery() async := []func(){ - settings.Init, InitJsExtensionType, InitDatabase, InitNodeSecret, diff --git a/internal/kernal/register_acme_user.go b/internal/kernel/register_acme_user.go similarity index 96% rename from internal/kernal/register_acme_user.go rename to internal/kernel/register_acme_user.go index 445b5204..3ace3f41 100644 --- a/internal/kernal/register_acme_user.go +++ b/internal/kernel/register_acme_user.go @@ -1,4 +1,4 @@ -package kernal +package kernel import ( "github.com/0xJacky/Nginx-UI/query" diff --git a/internal/kernal/skip_install.go b/internal/kernel/skip_install.go similarity index 99% rename from internal/kernal/skip_install.go rename to internal/kernel/skip_install.go index bc146467..364b6a24 100644 --- a/internal/kernal/skip_install.go +++ b/internal/kernel/skip_install.go @@ -1,4 +1,4 @@ -package kernal +package kernel import ( "github.com/0xJacky/Nginx-UI/model" diff --git a/main.go b/main.go index d33be71a..6933ff8c 100644 --- a/main.go +++ b/main.go @@ -3,34 +3,57 @@ package main import ( "flag" "fmt" - "github.com/0xJacky/Nginx-UI/internal/kernal" - "github.com/0xJacky/Nginx-UI/internal/nginx" + "github.com/0xJacky/Nginx-UI/internal/kernel" "github.com/0xJacky/Nginx-UI/model" "github.com/0xJacky/Nginx-UI/router" "github.com/0xJacky/Nginx-UI/settings" + "github.com/gin-gonic/gin" "github.com/jpillora/overseer" + "github.com/pkg/errors" "github.com/uozi-tech/cosy" + cKernel "github.com/uozi-tech/cosy/kernel" "github.com/uozi-tech/cosy/logger" + cRouter "github.com/uozi-tech/cosy/router" cSettings "github.com/uozi-tech/cosy/settings" + "net/http" "time" ) func Program(confPath string) func(state overseer.State) { return func(state overseer.State) { defer logger.Sync() - + defer logger.Info("Server exited") cosy.RegisterModels(model.GenerateAllModel()...) - cosy.RegisterAsyncFunc(kernal.Boot, router.InitRouter) + cosy.RegisterAsyncFunc(kernel.Boot, router.InitRouter) - if state.Listener != nil { - cosy.SetListener(state.Listener) + // Initialize settings package + settings.Init(confPath) - cosy.Boot(confPath) + // Set gin mode + gin.SetMode(cSettings.ServerSettings.RunMode) - logger.Infof("Nginx configuration directory: %s", nginx.GetConfPath()) + // Initialize logger package + logger.Init(cSettings.ServerSettings.RunMode) + defer logger.Sync() + + if state.Listener == nil { + return + } + // Gin router initialization + cRouter.Init() + + // Kernel boot + cKernel.Boot() + + addr := fmt.Sprintf("%s:%d", cSettings.ServerSettings.Host, cSettings.ServerSettings.Port) + srv := &http.Server{ + Addr: addr, + Handler: cRouter.GetEngine(), + } + if err := srv.Serve(state.Listener); err != nil && !errors.Is(err, http.ErrServerClosed) { + logger.Fatalf("listen: %s\n", err) } - logger.Info("Server exited") } } @@ -39,8 +62,7 @@ func main() { flag.StringVar(&confPath, "config", "app.ini", "Specify the configuration file") flag.Parse() - settings.Migrate(confPath) - cSettings.Init(confPath) + settings.Init(confPath) overseer.Run(overseer.Config{ Program: Program(confPath), diff --git a/settings/server_v1.go b/settings/server_v1.go index 27e78d50..db7d3390 100644 --- a/settings/server_v1.go +++ b/settings/server_v1.go @@ -100,7 +100,7 @@ func mergeStructs(src, dst interface{}) { return } -func Migrate(confPath string) { +func migrate(confPath string) { logger.Init("debug") Conf, err := ini.LoadSources(ini.LoadOptions{ Loose: true, @@ -160,7 +160,7 @@ func Migrate(confPath string) { for name, ptr := range migrated.Iterator() { err = Conf.Section(name).MapTo(ptr) if err != nil { - logger.Error("Migrate.MapTo %s err: %v", name, err) + logger.Error("migrate.MapTo %s err: %v", name, err) } } @@ -187,7 +187,7 @@ func Migrate(confPath string) { for section, ptr := range migrated.Iterator() { err = Conf.Section(section).ReflectFrom(ptr) if err != nil { - logger.Fatalf("Migrate.ReflectFrom %s err: %v", section, err) + logger.Fatalf("migrate.ReflectFrom %s err: %v", section, err) } } diff --git a/settings/server_v1_test.go b/settings/server_v1_test.go index a59c5791..8276024a 100644 --- a/settings/server_v1_test.go +++ b/settings/server_v1_test.go @@ -121,5 +121,5 @@ RPOrigins = http://localhost:3002,http://127.0.0.1:3002` t.Fatalf("Failed to write config to file: %v", err) } - Migrate(confName) + migrate(confName) } diff --git a/settings/settings.go b/settings/settings.go index 4b90f728..bdb81919 100644 --- a/settings/settings.go +++ b/settings/settings.go @@ -64,7 +64,16 @@ func init() { settings.WithoutSonyflake() } -func Init() { +func Init(confPath string) { + migrate(confPath) + + settings.Init(confPath) + + // Set Default Port + if settings.ServerSettings.Port == 0 { + settings.ServerSettings.Port = 9000 + } + for prefix, ptr := range envPrefixMap { parseEnv(ptr, prefix+"_") }