diff --git a/api/certificate/certificate.go b/api/certificate/certificate.go index b2351bc1..62cd47fb 100644 --- a/api/certificate/certificate.go +++ b/api/certificate/certificate.go @@ -25,7 +25,7 @@ func Transformer(certModel *model.Cert) (certificate *APICertificate) { if certModel.SSLCertificatePath != "" { if _, err := os.Stat(certModel.SSLCertificatePath); err == nil { sslCertificationBytes, _ = os.ReadFile(certModel.SSLCertificatePath) - if !cert.IsPublicKey(string(sslCertificationBytes)) { + if !cert.IsCertificate(string(sslCertificationBytes)) { sslCertificationBytes = []byte{} } } @@ -77,9 +77,9 @@ func GetCert(c *gin.Context) { type certJson struct { Name string `json:"name" binding:"required"` - SSLCertificatePath string `json:"ssl_certificate_path" binding:"required,publickey_path"` + SSLCertificatePath string `json:"ssl_certificate_path" binding:"required,certificate_path"` SSLCertificateKeyPath string `json:"ssl_certificate_key_path" binding:"required,privatekey_path"` - SSLCertificate string `json:"ssl_certificate" binding:"omitempty,publickey"` + SSLCertificate string `json:"ssl_certificate" binding:"omitempty,certificate"` SSLCertificateKey string `json:"ssl_certificate_key" binding:"omitempty,privatekey"` ChallengeMethod string `json:"challenge_method"` DnsCredentialID int `json:"dns_credential_id"` diff --git a/api/certificate/router.go b/api/certificate/router.go index 157ce10e..8b8b2bba 100644 --- a/api/certificate/router.go +++ b/api/certificate/router.go @@ -11,7 +11,6 @@ func InitDNSCredentialRouter(r *gin.RouterGroup) { } func InitCertificateRouter(r *gin.RouterGroup) { - r.GET("domain/:name/cert", IssueCert) r.GET("certs", GetCertList) r.GET("cert/:id", GetCert) r.POST("cert", AddCert) @@ -20,3 +19,7 @@ func InitCertificateRouter(r *gin.RouterGroup) { r.GET("certificate/dns_providers", GetDNSProvidersList) r.GET("certificate/dns_provider/:code", GetDNSProvider) } + +func InitCertificateWebSocketRouter(r *gin.RouterGroup) { + r.GET("domain/:name/cert", IssueCert) +} diff --git a/api/config/get.go b/api/config/get.go index 6d359578..a08f3103 100644 --- a/api/config/get.go +++ b/api/config/get.go @@ -1,51 +1,52 @@ package config import ( - "github.com/0xJacky/Nginx-UI/api" - "github.com/0xJacky/Nginx-UI/internal/config" - "github.com/0xJacky/Nginx-UI/internal/nginx" - "github.com/0xJacky/Nginx-UI/query" - "github.com/gin-gonic/gin" - "github.com/sashabaranov/go-openai" - "net/http" - "os" + "github.com/0xJacky/Nginx-UI/api" + "github.com/0xJacky/Nginx-UI/internal/config" + "github.com/0xJacky/Nginx-UI/internal/nginx" + "github.com/0xJacky/Nginx-UI/query" + "github.com/gin-gonic/gin" + "github.com/sashabaranov/go-openai" + "net/http" + "os" ) func GetConfig(c *gin.Context) { - name := c.Param("name") - path := nginx.GetConfPath("/", name) - - stat, err := os.Stat(path) - - if err != nil { - api.ErrHandler(c, err) - return - } - - content, err := os.ReadFile(path) - - if err != nil { - api.ErrHandler(c, err) - return - } - - g := query.ChatGPTLog - chatgpt, err := g.Where(g.Name.Eq(path)).FirstOrCreate() - - if err != nil { - api.ErrHandler(c, err) - return - } - - if chatgpt.Content == nil { - chatgpt.Content = make([]openai.ChatCompletionMessage, 0) - } - - c.JSON(http.StatusOK, config.Config{ - Name: name, - Content: string(content), - ChatGPTMessages: chatgpt.Content, - FilePath: path, - ModifiedAt: stat.ModTime(), - }) + name := c.Param("name") + + path := nginx.GetConfPath("/", name) + + stat, err := os.Stat(path) + + if err != nil { + api.ErrHandler(c, err) + return + } + + content, err := os.ReadFile(path) + + if err != nil { + api.ErrHandler(c, err) + return + } + + g := query.ChatGPTLog + chatgpt, err := g.Where(g.Name.Eq(path)).FirstOrCreate() + + if err != nil { + api.ErrHandler(c, err) + return + } + + if chatgpt.Content == nil { + chatgpt.Content = make([]openai.ChatCompletionMessage, 0) + } + + c.JSON(http.StatusOK, config.Config{ + Name: name, + Content: string(content), + ChatGPTMessages: chatgpt.Content, + FilePath: path, + ModifiedAt: stat.ModTime(), + }) } diff --git a/api/config/list.go b/api/config/list.go index 56e767ed..b5c8b342 100644 --- a/api/config/list.go +++ b/api/config/list.go @@ -35,7 +35,7 @@ func GetConfigs(c *gin.Context) { } case mode&os.ModeSymlink != 0: // is a symbol var targetPath string - targetPath, err = os.Readlink(nginx.GetConfPath(file.Name())) + targetPath, err = os.Readlink(nginx.GetConfPath(dir, file.Name())) if err != nil { logger.Error("Read Symlink Error", targetPath, err) continue @@ -47,7 +47,7 @@ func GetConfigs(c *gin.Context) { logger.Error("Stat Error", targetPath, err) continue } - // but target file is not a dir + // hide the file if it's target file is a directory if targetInfo.IsDir() { continue } diff --git a/api/config/modify.go b/api/config/modify.go index 70b5a611..9d6c8b73 100644 --- a/api/config/modify.go +++ b/api/config/modify.go @@ -30,7 +30,6 @@ func EditConfig(c *gin.Context) { } if content != "" && content != string(origContent) { - // model.CreateBackup(path) err = os.WriteFile(path, []byte(content), 0644) if err != nil { api.ErrHandler(c, err) diff --git a/app/package.json b/app/package.json index 88f602e8..0f2d43ad 100644 --- a/app/package.json +++ b/app/package.json @@ -1,6 +1,6 @@ { "name": "nginx-ui-app-next", - "version": "2.0.0-beta.13", + "version": "2.0.0-beta.14", "type": "module", "scripts": { "dev": "vite", diff --git a/app/src/language/LINGUAS b/app/src/language/LINGUAS index 39b120b5..e6be8ba0 100644 --- a/app/src/language/LINGUAS +++ b/app/src/language/LINGUAS @@ -1 +1 @@ -es fr_FR ru_RU vi_VN zh_CN zh_TW +en zh_CN zh_TW fr_FR es ru_RU vi_VN \ No newline at end of file diff --git a/app/src/language/en/app.po b/app/src/language/en/app.po index bacc54c1..0b5592e0 100644 --- a/app/src/language/en/app.po +++ b/app/src/language/en/app.po @@ -1561,14 +1561,15 @@ msgstr "" msgid "The input is not a SSL Certificate Key" msgstr "Certificate Status" +#: src/views/certificate/CertificateEditor.vue:168 +#, fuzzy +msgid "The path exists, but the file is not a certificate" +msgstr "Certificate Status" + #: src/views/certificate/CertificateEditor.vue:183 msgid "The path exists, but the file is not a private key" msgstr "" -#: src/views/certificate/CertificateEditor.vue:168 -msgid "The path exists, but the file is not a public key" -msgstr "" - #: src/views/domain/cert/components/AutoCertStepOne.vue:45 #, fuzzy msgid "" diff --git a/app/src/language/es/app.po b/app/src/language/es/app.po index 48b54dda..ec764b4a 100644 --- a/app/src/language/es/app.po +++ b/app/src/language/es/app.po @@ -1492,14 +1492,15 @@ msgstr "La entrada no es un Certificado SSL" msgid "The input is not a SSL Certificate Key" msgstr "La entrada no es una clave de certificado SSL" +#: src/views/certificate/CertificateEditor.vue:168 +#, fuzzy +msgid "The path exists, but the file is not a certificate" +msgstr "La ruta existe, pero el archivo no es una clave privada" + #: src/views/certificate/CertificateEditor.vue:183 msgid "The path exists, but the file is not a private key" msgstr "La ruta existe, pero el archivo no es una clave privada" -#: src/views/certificate/CertificateEditor.vue:168 -msgid "The path exists, but the file is not a public key" -msgstr "La ruta existe, pero el archivo no es una clave pública" - #: src/views/domain/cert/components/AutoCertStepOne.vue:45 msgid "" "The server_name in the current configuration must be the domain name you " @@ -1672,6 +1673,9 @@ msgstr "Estás usando la última versión" msgid "You can check Nginx UI upgrade at this page." msgstr "Puede consultar la actualización de Nginx UI en esta página." +#~ msgid "The path exists, but the file is not a public key" +#~ msgstr "La ruta existe, pero el archivo no es una clave pública" + #, fuzzy #~ msgid "Server" #~ msgstr "Información del servidor" diff --git a/app/src/language/fr_FR/app.po b/app/src/language/fr_FR/app.po index 16d1fcf1..5f42b07b 100644 --- a/app/src/language/fr_FR/app.po +++ b/app/src/language/fr_FR/app.po @@ -1559,14 +1559,15 @@ msgstr "" msgid "The input is not a SSL Certificate Key" msgstr "Chemin de la clé du certificat SSL" +#: src/views/certificate/CertificateEditor.vue:168 +#, fuzzy +msgid "The path exists, but the file is not a certificate" +msgstr "Chemin de la clé du certificat SSL" + #: src/views/certificate/CertificateEditor.vue:183 msgid "The path exists, but the file is not a private key" msgstr "" -#: src/views/certificate/CertificateEditor.vue:168 -msgid "The path exists, but the file is not a public key" -msgstr "" - #: src/views/domain/cert/components/AutoCertStepOne.vue:45 #, fuzzy msgid "" diff --git a/app/src/language/messages.pot b/app/src/language/messages.pot index dc5dce4c..9908bb78 100644 --- a/app/src/language/messages.pot +++ b/app/src/language/messages.pot @@ -1508,12 +1508,12 @@ msgstr "" msgid "The input is not a SSL Certificate Key" msgstr "" -#: src/views/certificate/CertificateEditor.vue:183 -msgid "The path exists, but the file is not a private key" +#: src/views/certificate/CertificateEditor.vue:168 +msgid "The path exists, but the file is not a certificate" msgstr "" -#: src/views/certificate/CertificateEditor.vue:168 -msgid "The path exists, but the file is not a public key" +#: src/views/certificate/CertificateEditor.vue:183 +msgid "The path exists, but the file is not a private key" msgstr "" #: src/views/domain/cert/components/AutoCertStepOne.vue:45 diff --git a/app/src/language/ru_RU/app.po b/app/src/language/ru_RU/app.po index 948e372e..58c77d38 100644 --- a/app/src/language/ru_RU/app.po +++ b/app/src/language/ru_RU/app.po @@ -1567,14 +1567,15 @@ msgstr "" msgid "The input is not a SSL Certificate Key" msgstr "Путь к ключу сертификата SSL" +#: src/views/certificate/CertificateEditor.vue:168 +#, fuzzy +msgid "The path exists, but the file is not a certificate" +msgstr "Путь к ключу сертификата SSL" + #: src/views/certificate/CertificateEditor.vue:183 msgid "The path exists, but the file is not a private key" msgstr "" -#: src/views/certificate/CertificateEditor.vue:168 -msgid "The path exists, but the file is not a public key" -msgstr "" - #: src/views/domain/cert/components/AutoCertStepOne.vue:45 #, fuzzy msgid "" diff --git a/app/src/language/vi_VN/app.po b/app/src/language/vi_VN/app.po index ce47eada..9a86d192 100644 --- a/app/src/language/vi_VN/app.po +++ b/app/src/language/vi_VN/app.po @@ -1564,12 +1564,12 @@ msgstr "" msgid "The input is not a SSL Certificate Key" msgstr "" -#: src/views/certificate/CertificateEditor.vue:183 -msgid "The path exists, but the file is not a private key" +#: src/views/certificate/CertificateEditor.vue:168 +msgid "The path exists, but the file is not a certificate" msgstr "" -#: src/views/certificate/CertificateEditor.vue:168 -msgid "The path exists, but the file is not a public key" +#: src/views/certificate/CertificateEditor.vue:183 +msgid "The path exists, but the file is not a private key" msgstr "" #: src/views/domain/cert/components/AutoCertStepOne.vue:45 diff --git a/app/src/language/zh_CN/app.mo b/app/src/language/zh_CN/app.mo index a56cbd92..020dc1e0 100644 Binary files a/app/src/language/zh_CN/app.mo and b/app/src/language/zh_CN/app.mo differ diff --git a/app/src/language/zh_CN/app.po b/app/src/language/zh_CN/app.po index 24d1ad6c..26370f70 100644 --- a/app/src/language/zh_CN/app.po +++ b/app/src/language/zh_CN/app.po @@ -1479,14 +1479,14 @@ msgstr "输入的内容不是 SSL 证书" msgid "The input is not a SSL Certificate Key" msgstr "输入的内容不是 SSL 证书密钥" +#: src/views/certificate/CertificateEditor.vue:168 +msgid "The path exists, but the file is not a certificate" +msgstr "路径存在,但文件不是证书" + #: src/views/certificate/CertificateEditor.vue:183 msgid "The path exists, but the file is not a private key" msgstr "路径存在,但文件不是私钥" -#: src/views/certificate/CertificateEditor.vue:168 -msgid "The path exists, but the file is not a public key" -msgstr "路径存在,但文件不是公钥" - #: src/views/domain/cert/components/AutoCertStepOne.vue:45 msgid "" "The server_name in the current configuration must be the domain name you " @@ -1652,6 +1652,9 @@ msgstr "您使用的是最新版本" msgid "You can check Nginx UI upgrade at this page." msgstr "你可以在这个页面检查Nginx UI的升级。" +#~ msgid "The path exists, but the file is not a public key" +#~ msgstr "路径存在,但文件不是公钥" + #~ msgid "Rename Upstream" #~ msgstr "重新命名 Upstream" diff --git a/app/src/language/zh_TW/app.po b/app/src/language/zh_TW/app.po index f633bd22..d3263ba3 100644 --- a/app/src/language/zh_TW/app.po +++ b/app/src/language/zh_TW/app.po @@ -1526,14 +1526,15 @@ msgstr "" msgid "The input is not a SSL Certificate Key" msgstr "SSL 憑證金鑰路徑" +#: src/views/certificate/CertificateEditor.vue:168 +#, fuzzy +msgid "The path exists, but the file is not a certificate" +msgstr "SSL 憑證金鑰路徑" + #: src/views/certificate/CertificateEditor.vue:183 msgid "The path exists, but the file is not a private key" msgstr "" -#: src/views/certificate/CertificateEditor.vue:168 -msgid "The path exists, but the file is not a public key" -msgstr "" - #: src/views/domain/cert/components/AutoCertStepOne.vue:45 #, fuzzy msgid "" diff --git a/app/src/version.json b/app/src/version.json index 06a27421..c6cd25ba 100644 --- a/app/src/version.json +++ b/app/src/version.json @@ -1 +1 @@ -{"version":"2.0.0-beta.11","build_id":111,"total_build":315} \ No newline at end of file +{"version":"2.0.0-beta.14","build_id":112,"total_build":316} \ No newline at end of file diff --git a/app/src/views/certificate/CertificateEditor.vue b/app/src/views/certificate/CertificateEditor.vue index 158d9748..71b6fb2f 100644 --- a/app/src/views/certificate/CertificateEditor.vue +++ b/app/src/views/certificate/CertificateEditor.vue @@ -164,8 +164,8 @@ const isManaged = computed(() => { :label="$gettext('SSL Certificate Path')" :validate-status="errors.ssl_certificate_path ? 'error' : ''" :help="errors.ssl_certificate_path === 'required' ? $gettext('This field is required') - : errors.ssl_certificate_path === 'publickey_path' - ? $gettext('The path exists, but the file is not a public key') : ''" + : errors.ssl_certificate_path === 'certificate_path' + ? $gettext('The path exists, but the file is not a certificate') : ''" >
{{ data.ssl_certificate_path }}
@@ -193,7 +193,7 @@ const isManaged = computed(() => {