Feature: add udp-fallback-match
option
This commit is contained in:
parent
2301b909d2
commit
a5d54884e0
@ -86,7 +86,9 @@ type Profile struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Experimental config
|
// Experimental config
|
||||||
type Experimental struct{}
|
type Experimental struct {
|
||||||
|
UDPFallbackMatch bool `yaml:"udp-fallback-match"`
|
||||||
|
}
|
||||||
|
|
||||||
// Config is clash config manager
|
// Config is clash config manager
|
||||||
type Config struct {
|
type Config struct {
|
||||||
@ -250,6 +252,9 @@ func UnmarshalRawConfig(buf []byte) (*RawConfig, error) {
|
|||||||
Profile: Profile{
|
Profile: Profile{
|
||||||
StoreSelected: true,
|
StoreSelected: true,
|
||||||
},
|
},
|
||||||
|
Experimental: Experimental{
|
||||||
|
UDPFallbackMatch: true,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := yaml.Unmarshal(buf, rawCfg); err != nil {
|
if err := yaml.Unmarshal(buf, rawCfg); err != nil {
|
||||||
|
@ -104,7 +104,9 @@ func GetGeneral() *config.General {
|
|||||||
return general
|
return general
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateExperimental(c *config.Config) {}
|
func updateExperimental(c *config.Config) {
|
||||||
|
tunnel.UDPFallbackMatch.Store(c.Experimental.UDPFallbackMatch)
|
||||||
|
}
|
||||||
|
|
||||||
func updateDNS(c *config.DNS) {
|
func updateDNS(c *config.DNS) {
|
||||||
if !c.Enable {
|
if !c.Enable {
|
||||||
|
@ -19,6 +19,8 @@ import (
|
|||||||
icontext "github.com/Dreamacro/clash/context"
|
icontext "github.com/Dreamacro/clash/context"
|
||||||
"github.com/Dreamacro/clash/log"
|
"github.com/Dreamacro/clash/log"
|
||||||
"github.com/Dreamacro/clash/tunnel/statistic"
|
"github.com/Dreamacro/clash/tunnel/statistic"
|
||||||
|
|
||||||
|
"go.uber.org/atomic"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -35,6 +37,9 @@ var (
|
|||||||
|
|
||||||
// default timeout for UDP session
|
// default timeout for UDP session
|
||||||
udpTimeout = 60 * time.Second
|
udpTimeout = 60 * time.Second
|
||||||
|
|
||||||
|
// experimental feature
|
||||||
|
UDPFallbackMatch = atomic.NewBool(false)
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@ -407,8 +412,8 @@ func match(metadata *C.Metadata) (C.Proxy, C.Rule, error) {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if metadata.NetWork == C.UDP && !adapter.SupportUDP() {
|
if metadata.NetWork == C.UDP && !adapter.SupportUDP() && UDPFallbackMatch.Load() {
|
||||||
log.Debugln("%s UDP is not supported", adapter.Name())
|
log.Debugln("[Matcher] %s UDP is not supported, skip match", adapter.Name())
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
return adapter, rule, nil
|
return adapter, rule, nil
|
||||||
|
Reference in New Issue
Block a user