Feature: add udp-fallback-match option

This commit is contained in:
Dreamacro
2023-01-01 20:12:17 +08:00
parent 2301b909d2
commit a5d54884e0
3 changed files with 16 additions and 4 deletions

View File

@ -19,6 +19,8 @@ import (
icontext "github.com/Dreamacro/clash/context"
"github.com/Dreamacro/clash/log"
"github.com/Dreamacro/clash/tunnel/statistic"
"go.uber.org/atomic"
)
var (
@ -35,6 +37,9 @@ var (
// default timeout for UDP session
udpTimeout = 60 * time.Second
// experimental feature
UDPFallbackMatch = atomic.NewBool(false)
)
func init() {
@ -407,8 +412,8 @@ func match(metadata *C.Metadata) (C.Proxy, C.Rule, error) {
continue
}
if metadata.NetWork == C.UDP && !adapter.SupportUDP() {
log.Debugln("%s UDP is not supported", adapter.Name())
if metadata.NetWork == C.UDP && !adapter.SupportUDP() && UDPFallbackMatch.Load() {
log.Debugln("[Matcher] %s UDP is not supported, skip match", adapter.Name())
continue
}
return adapter, rule, nil