Skip to content

Commit

Permalink
Fix AutoCert() panic issue.
Browse files Browse the repository at this point in the history
I forgot to catch the http request error, this might cause an unrecoverable panic.
  • Loading branch information
0xJacky committed May 6, 2022
1 parent 9d3f35b commit 0fe9bf5
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 14 deletions.
2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nginx-ui-frontend",
"version": "1.2.0",
"version": "1.2.2",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
Expand Down
5 changes: 5 additions & 0 deletions frontend/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
<meta content="width=device-width,initial-scale=1.0,user-scalable=0" name="viewport">
<link href="<%= BASE_URL %>favicon.ico" rel="icon">
<title><%= htmlWebpackPlugin.options.title %></title>
<style type="text/css">
body {
width: 100% !important;
}
</style>
</head>
<body>
<noscript>
Expand Down
2 changes: 1 addition & 1 deletion frontend/version.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"version":"1.2.0","build_id":8,"total_build":48}
{"version":"1.2.2","build_id":1,"total_build":49}
17 changes: 6 additions & 11 deletions server/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,17 @@ type ValidError struct {
Message string
}

var trans ut.Translator

func init() {
uni := ut.New(zh.New())
trans, _ = uni.GetTranslator("zh")
v, ok := binding.Validator.Engine().(*val.Validate)
if ok {
_ = zhTranslations.RegisterDefaultTranslations(v, trans)
}
}

func BindAndValid(c *gin.Context, target interface{}) bool {
errs := make(map[string]string)
err := c.ShouldBindJSON(target)
if err != nil {
log.Println("raw err", err)
uni := ut.New(zh.New())
trans, _ := uni.GetTranslator("zh")
v, ok := binding.Validator.Engine().(*val.Validate)
if ok {
_ = zhTranslations.RegisterDefaultTranslations(v, trans)
}

verrs, ok := err.(val.ValidationErrors)

Expand Down
7 changes: 6 additions & 1 deletion server/api/cert.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@ import (
func CertInfo(c *gin.Context) {
domain := c.Param("domain")

key := tool.GetCertInfo(domain)
key, err := tool.GetCertInfo(domain)

if err != nil {
ErrHandler(c, err)
return
}

c.JSON(http.StatusOK, gin.H{
"subject_name": key.Subject.CommonName,
Expand Down

0 comments on commit 0fe9bf5

Please sign in to comment.