mirror of
https://github.com/fatedier/frp.git
synced 2026-01-11 22:23:12 +00:00
Improve the strict configuration validation (#3809)
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
@@ -177,7 +178,11 @@ func (c *TypedProxyConfig) UnmarshalJSON(b []byte) error {
|
||||
if configurer == nil {
|
||||
return fmt.Errorf("unknown proxy type: %s", typeStruct.Type)
|
||||
}
|
||||
if err := json.Unmarshal(b, configurer); err != nil {
|
||||
decoder := json.NewDecoder(bytes.NewBuffer(b))
|
||||
if DisallowUnknownFields {
|
||||
decoder.DisallowUnknownFields()
|
||||
}
|
||||
if err := decoder.Decode(configurer); err != nil {
|
||||
return err
|
||||
}
|
||||
c.ProxyConfigurer = configurer
|
||||
|
||||
Reference in New Issue
Block a user