1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2026-06-11 21:49:26 -04:00

report error on unknown fields in jsonv5

This commit is contained in:
Shelikhoo
2025-07-06 00:03:06 +01:00
committed by Xiaokang Wang (Shelikhoo)
parent 5a003982db
commit fadf6bc085

View File

@@ -1,6 +1,7 @@
package v5cfg
import (
"bytes"
"context"
"encoding/json"
"fmt"
@@ -86,7 +87,9 @@ func (c RootConfig) BuildV5(ctx context.Context) (proto.Message, error) {
func loadJSONConfig(data []byte) (*core.Config, error) {
rootConfig := &RootConfig{}
err := json.Unmarshal(data, rootConfig)
rootConfDecoder := json.NewDecoder(bytes.NewReader(data))
rootConfDecoder.DisallowUnknownFields()
err := rootConfDecoder.Decode(rootConfig)
if err != nil {
return nil, newError("unable to load json").Base(err)
}