fix: structure decode first do strict match
This commit is contained in:
parent
fa1200dffb
commit
b646df14c2
4 changed files with 20 additions and 20 deletions
|
@ -169,12 +169,12 @@ func NewTuic(option TuicOption) (*Tuic, error) {
|
||||||
EnableDatagrams: true,
|
EnableDatagrams: true,
|
||||||
}
|
}
|
||||||
if option.ReceiveWindowConn == 0 {
|
if option.ReceiveWindowConn == 0 {
|
||||||
quicConfig.InitialStreamReceiveWindow = DefaultStreamReceiveWindow / 10
|
quicConfig.InitialStreamReceiveWindow = tuic.DefaultStreamReceiveWindow / 10
|
||||||
quicConfig.MaxStreamReceiveWindow = DefaultStreamReceiveWindow
|
quicConfig.MaxStreamReceiveWindow = tuic.DefaultStreamReceiveWindow
|
||||||
}
|
}
|
||||||
if option.ReceiveWindow == 0 {
|
if option.ReceiveWindow == 0 {
|
||||||
quicConfig.InitialConnectionReceiveWindow = DefaultConnectionReceiveWindow / 10
|
quicConfig.InitialConnectionReceiveWindow = tuic.DefaultConnectionReceiveWindow / 10
|
||||||
quicConfig.MaxConnectionReceiveWindow = DefaultConnectionReceiveWindow
|
quicConfig.MaxConnectionReceiveWindow = tuic.DefaultConnectionReceiveWindow
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(option.Ip) > 0 {
|
if len(option.Ip) > 0 {
|
||||||
|
|
|
@ -49,12 +49,12 @@ func (d *Decoder) Decode(src map[string]any, dst any) error {
|
||||||
key, omitKey, found := strings.Cut(tag, ",")
|
key, omitKey, found := strings.Cut(tag, ",")
|
||||||
omitempty := found && omitKey == "omitempty"
|
omitempty := found && omitKey == "omitempty"
|
||||||
|
|
||||||
|
value, ok := src[key]
|
||||||
|
if !ok {
|
||||||
if d.option.KeyReplacer != nil {
|
if d.option.KeyReplacer != nil {
|
||||||
key = d.option.KeyReplacer.Replace(key)
|
key = d.option.KeyReplacer.Replace(key)
|
||||||
}
|
}
|
||||||
|
|
||||||
value, ok := src[key]
|
|
||||||
if !ok {
|
|
||||||
for _strKey := range src {
|
for _strKey := range src {
|
||||||
strKey := _strKey
|
strKey := _strKey
|
||||||
if d.option.KeyReplacer != nil {
|
if d.option.KeyReplacer != nil {
|
||||||
|
@ -364,9 +364,6 @@ func (d *Decoder) decodeStructFromMap(name string, dataVal, val reflect.Value) e
|
||||||
tagValue = strings.SplitN(tagValue, ",", 2)[0]
|
tagValue = strings.SplitN(tagValue, ",", 2)[0]
|
||||||
if tagValue != "" {
|
if tagValue != "" {
|
||||||
fieldName = tagValue
|
fieldName = tagValue
|
||||||
if d.option.KeyReplacer != nil {
|
|
||||||
fieldName = d.option.KeyReplacer.Replace(fieldName)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
rawMapKey := reflect.ValueOf(fieldName)
|
rawMapKey := reflect.ValueOf(fieldName)
|
||||||
|
@ -374,6 +371,9 @@ func (d *Decoder) decodeStructFromMap(name string, dataVal, val reflect.Value) e
|
||||||
if !rawMapVal.IsValid() {
|
if !rawMapVal.IsValid() {
|
||||||
// Do a slower search by iterating over each key and
|
// Do a slower search by iterating over each key and
|
||||||
// doing case-insensitive search.
|
// doing case-insensitive search.
|
||||||
|
if d.option.KeyReplacer != nil {
|
||||||
|
fieldName = d.option.KeyReplacer.Replace(fieldName)
|
||||||
|
}
|
||||||
for dataValKey := range dataValKeys {
|
for dataValKey := range dataValKeys {
|
||||||
mK, ok := dataValKey.Interface().(string)
|
mK, ok := dataValKey.Interface().(string)
|
||||||
if !ok {
|
if !ok {
|
||||||
|
|
|
@ -17,11 +17,6 @@ import (
|
||||||
"github.com/Dreamacro/clash/transport/tuic"
|
"github.com/Dreamacro/clash/transport/tuic"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
|
||||||
DefaultStreamReceiveWindow = 15728640 // 15 MB/s
|
|
||||||
DefaultConnectionReceiveWindow = 67108864 // 64 MB/s
|
|
||||||
)
|
|
||||||
|
|
||||||
type Listener struct {
|
type Listener struct {
|
||||||
closed bool
|
closed bool
|
||||||
config config.TuicServer
|
config config.TuicServer
|
||||||
|
@ -49,10 +44,10 @@ func New(config config.TuicServer, tcpIn chan<- C.ConnContext, udpIn chan<- *inb
|
||||||
MaxIncomingUniStreams: 1 >> 32,
|
MaxIncomingUniStreams: 1 >> 32,
|
||||||
EnableDatagrams: true,
|
EnableDatagrams: true,
|
||||||
}
|
}
|
||||||
quicConfig.InitialStreamReceiveWindow = DefaultStreamReceiveWindow / 10
|
quicConfig.InitialStreamReceiveWindow = tuic.DefaultStreamReceiveWindow / 10
|
||||||
quicConfig.MaxStreamReceiveWindow = DefaultStreamReceiveWindow
|
quicConfig.MaxStreamReceiveWindow = tuic.DefaultStreamReceiveWindow
|
||||||
quicConfig.InitialConnectionReceiveWindow = DefaultConnectionReceiveWindow / 10
|
quicConfig.InitialConnectionReceiveWindow = tuic.DefaultConnectionReceiveWindow / 10
|
||||||
quicConfig.MaxConnectionReceiveWindow = DefaultConnectionReceiveWindow
|
quicConfig.MaxConnectionReceiveWindow = tuic.DefaultConnectionReceiveWindow
|
||||||
|
|
||||||
tokens := make([][32]byte, len(config.Token))
|
tokens := make([][32]byte, len(config.Token))
|
||||||
for i, token := range config.Token {
|
for i, token := range config.Token {
|
||||||
|
|
|
@ -15,6 +15,11 @@ import (
|
||||||
"github.com/Dreamacro/clash/transport/tuic/congestion"
|
"github.com/Dreamacro/clash/transport/tuic/congestion"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
DefaultStreamReceiveWindow = 15728640 // 15 MB/s
|
||||||
|
DefaultConnectionReceiveWindow = 67108864 // 64 MB/s
|
||||||
|
)
|
||||||
|
|
||||||
func SetCongestionController(quicConn quic.Connection, cc string) {
|
func SetCongestionController(quicConn quic.Connection, cc string) {
|
||||||
switch cc {
|
switch cc {
|
||||||
case "cubic":
|
case "cubic":
|
||||||
|
|
Loading…
Reference in a new issue