mirror of
https://github.com/fatedier/frp.git
synced 2026-04-22 00:49:10 +08:00
refactor: restructure API packages into client/http and server/http with typed proxy/visitor models (#5193)
This commit is contained in:
@@ -16,35 +16,10 @@ package v1
|
||||
|
||||
import (
|
||||
"maps"
|
||||
"sync"
|
||||
|
||||
"github.com/fatedier/frp/pkg/util/util"
|
||||
)
|
||||
|
||||
// TODO(fatedier): Migrate typed config decoding to encoding/json/v2 when it is stable for production use.
|
||||
// The current encoding/json(v1) path cannot propagate DisallowUnknownFields into custom UnmarshalJSON
|
||||
// methods, so we temporarily keep this global strictness flag protected by a mutex.
|
||||
//
|
||||
// https://github.com/golang/go/issues/41144
|
||||
// https://github.com/golang/go/discussions/63397
|
||||
var (
|
||||
DisallowUnknownFields = false
|
||||
DisallowUnknownFieldsMu sync.Mutex
|
||||
)
|
||||
|
||||
// WithDisallowUnknownFields temporarily overrides typed config JSON strictness.
|
||||
// It restores the previous value before returning.
|
||||
func WithDisallowUnknownFields(disallow bool, fn func() error) error {
|
||||
DisallowUnknownFieldsMu.Lock()
|
||||
prev := DisallowUnknownFields
|
||||
DisallowUnknownFields = disallow
|
||||
defer func() {
|
||||
DisallowUnknownFields = prev
|
||||
DisallowUnknownFieldsMu.Unlock()
|
||||
}()
|
||||
return fn()
|
||||
}
|
||||
|
||||
type AuthScope string
|
||||
|
||||
const (
|
||||
|
||||
Reference in New Issue
Block a user