mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-08-22 09:36:49 +08:00
Some refines related to direct/freedom and targetStrategy
; More intelligent "useIP"/"ForceIP", enhance "origin" functionality (#5030)
https://github.com/XTLS/Xray-core/pull/5009#issuecomment-3194264277
This commit is contained in:
@@ -2,6 +2,7 @@ package internet
|
||||
|
||||
import (
|
||||
"github.com/xtls/xray-core/common/errors"
|
||||
"github.com/xtls/xray-core/common/net"
|
||||
"github.com/xtls/xray-core/common/serial"
|
||||
)
|
||||
|
||||
@@ -127,3 +128,25 @@ func (s DomainStrategy) FallbackIP4() bool {
|
||||
func (s DomainStrategy) FallbackIP6() bool {
|
||||
return strategy[s][2] == 6
|
||||
}
|
||||
|
||||
func (s DomainStrategy) GetDynamicStrategy(addrFamily net.AddressFamily) DomainStrategy {
|
||||
if addrFamily.IsDomain(){
|
||||
return s
|
||||
}
|
||||
switch s {
|
||||
case DomainStrategy_USE_IP:
|
||||
if addrFamily.IsIPv4() {
|
||||
return DomainStrategy_USE_IP46
|
||||
} else if addrFamily.IsIPv6() {
|
||||
return DomainStrategy_USE_IP64
|
||||
}
|
||||
case DomainStrategy_FORCE_IP:
|
||||
if addrFamily.IsIPv4() {
|
||||
return DomainStrategy_FORCE_IP46
|
||||
} else if addrFamily.IsIPv6() {
|
||||
return DomainStrategy_FORCE_IP64
|
||||
}
|
||||
default:
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
Reference in New Issue
Block a user