Skip to content

Commit 7be4a70

Browse files
committed
feat: add recursive nameservers settings for dns challenge #372
1 parent d3e9d92 commit 7be4a70

File tree

22 files changed

+4518
-3499
lines changed

22 files changed

+4518
-3499
lines changed

api/api.go

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ import (
44
"errors"
55
"github.com/0xJacky/Nginx-UI/internal/logger"
66
"github.com/gin-gonic/gin"
7-
val "github.com/go-playground/validator/v10"
7+
"github.com/go-playground/validator/v10"
88
"net/http"
99
"reflect"
10+
"regexp"
1011
"strings"
1112
)
1213

@@ -27,7 +28,7 @@ func BindAndValid(c *gin.Context, target interface{}) bool {
2728
if err != nil {
2829
logger.Error("bind err", err)
2930

30-
var verrs val.ValidationErrors
31+
var verrs validator.ValidationErrors
3132
ok := errors.As(err, &verrs)
3233

3334
if !ok {
@@ -44,7 +45,7 @@ func BindAndValid(c *gin.Context, target interface{}) bool {
4445
var path []string
4546

4647
namespace := strings.Split(value.StructNamespace(), ".")
47-
logger.Debug(t.Name(), namespace)
48+
// logger.Debug(t.Name(), namespace)
4849
if t.Name() != "" && len(namespace) > 1 {
4950
namespace = namespace[1:]
5051
}
@@ -67,13 +68,30 @@ func BindAndValid(c *gin.Context, target interface{}) bool {
6768

6869
// findField recursively finds the field in a nested struct
6970
func getJsonPath(t reflect.Type, fields []string, path *[]string) {
70-
f, ok := t.FieldByName(fields[0])
71+
field := fields[0]
72+
// used in case of array
73+
var index string
74+
if field[len(field)-1] == ']' {
75+
re := regexp.MustCompile(`(\w+)\[(\d+)\]`)
76+
matches := re.FindStringSubmatch(field)
77+
78+
if len(matches) > 2 {
79+
field = matches[1]
80+
index = matches[2]
81+
}
82+
}
83+
84+
f, ok := t.FieldByName(field)
7185
if !ok {
7286
return
7387
}
7488

7589
*path = append(*path, f.Tag.Get("json"))
7690

91+
if index != "" {
92+
*path = append(*path, index)
93+
}
94+
7795
if len(fields) > 1 {
7896
subFields := fields[1:]
7997
getJsonPath(f.Type, subFields, path)

app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,5 +71,5 @@
7171
"vite-svg-loader": "^5.1.0",
7272
"vue-tsc": "^1.8.27"
7373
},
74-
"packageManager": "pnpm@8.15.5+sha256.4b4efa12490e5055d59b9b9fc9438b7d581a6b7af3b5675eb5c5f447cee1a589"
74+
"packageManager": "pnpm@9.0.6+sha256.0624e30eff866cdeb363b15061bdb7fd9425b17bc1bb42c22f5f4efdea21f6b3"
7575
}

0 commit comments

Comments
 (0)