Skip to content

Commit

Permalink
chore: prepare v2.0.0-beta.14
Browse files Browse the repository at this point in the history
  • Loading branch information
0xJacky authored Feb 6, 2024
2 parents 4e369ba + 66571bc commit 3bbe56c
Show file tree
Hide file tree
Showing 25 changed files with 274 additions and 153 deletions.
6 changes: 3 additions & 3 deletions api/certificate/certificate.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}
}
}
Expand Down Expand Up @@ -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"`
Expand Down
5 changes: 4 additions & 1 deletion api/certificate/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
}
89 changes: 45 additions & 44 deletions api/config/get.go
Original file line number Diff line number Diff line change
@@ -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(),
})
}
4 changes: 2 additions & 2 deletions api/config/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}
Expand Down
1 change: 0 additions & 1 deletion api/config/modify.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion app/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion app/src/language/LINGUAS
Original file line number Diff line number Diff line change
@@ -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
9 changes: 5 additions & 4 deletions app/src/language/en/app.po
Original file line number Diff line number Diff line change
Expand Up @@ -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 ""
Expand Down
12 changes: 8 additions & 4 deletions app/src/language/es/app.po
Original file line number Diff line number Diff line change
Expand Up @@ -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 "
Expand Down Expand Up @@ -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"
Expand Down
9 changes: 5 additions & 4 deletions app/src/language/fr_FR/app.po
Original file line number Diff line number Diff line change
Expand Up @@ -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 ""
Expand Down
8 changes: 4 additions & 4 deletions app/src/language/messages.pot
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 5 additions & 4 deletions app/src/language/ru_RU/app.po
Original file line number Diff line number Diff line change
Expand Up @@ -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 ""
Expand Down
8 changes: 4 additions & 4 deletions app/src/language/vi_VN/app.po
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Binary file modified app/src/language/zh_CN/app.mo
Binary file not shown.
11 changes: 7 additions & 4 deletions app/src/language/zh_CN/app.po
Original file line number Diff line number Diff line change
Expand Up @@ -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 "
Expand Down Expand Up @@ -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"

Expand Down
9 changes: 5 additions & 4 deletions app/src/language/zh_TW/app.po
Original file line number Diff line number Diff line change
Expand Up @@ -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 ""
Expand Down
2 changes: 1 addition & 1 deletion app/src/version.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"version":"2.0.0-beta.11","build_id":111,"total_build":315}
{"version":"2.0.0-beta.14","build_id":112,"total_build":316}
6 changes: 3 additions & 3 deletions app/src/views/certificate/CertificateEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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') : ''"
>
<p v-if="isManaged">
{{ data.ssl_certificate_path }}
Expand Down Expand Up @@ -193,7 +193,7 @@ const isManaged = computed(() => {
<AFormItem
:label="$gettext('SSL Certificate Content')"
:validate-status="errors.ssl_certificate ? 'error' : ''"
:help="errors.ssl_certificate === 'publickey'
:help="errors.ssl_certificate === 'certificate'
? $gettext('The input is not a SSL Certificate') : ''"
>
<CodeEditor
Expand Down
2 changes: 1 addition & 1 deletion app/version.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"version":"2.0.0-beta.11","build_id":111,"total_build":315}
{"version":"2.0.0-beta.14","build_id":112,"total_build":316}
Loading

0 comments on commit 3bbe56c

Please sign in to comment.